Hello,
The spec says ID of a feature is not a MUST but SHOULD be included if there
is a commonly used identifier:
https://tools.ietf.org/html/rfc7946#section-3.2
If a Feature has a commonly used identifier, that identifier
SHOULD be included as a member of the Feature object with the name
"id", and the value of this member is either a JSON string or
number.
I'm not able to create a Feature without specifying an ID with the GeoJSON
plugin of GeoTools.
The *SimpleFeatureBuilder* has a *buildFeature* method but it requires ID,
if its set to null it generates one. But, shouldn't we have a method that
doesn't require an ID or doesn't generate one? Please let me know if I'm
missing something here on how to create a Feature without ID.
SimpleFeatureTypeBuilder tb = new
SimpleFeatureTypeBuilder();
tb.add("geometry", Geometry.class);
tb.add("name", String.class);
tb.setName("test_geometry");
SimpleFeatureType schema = tb.buildFeatureType();
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema);
fb.add(new WKTReader().read("POINT(2 4)"));
fb.add("test");
DefaultFeatureCollection fc = new DefaultFeatureCollection();
// The following line
fc.add(fb.buildFeature("23"));
FeatureJSON fj = new FeatureJSON();
ByteArrayOutputStream os = new ByteArrayOutputStream();
fj.writeFeatureCollection(fc, os);
System.out.println(os.toString());
Tim
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel