SimpleFeatureTypeBuilder with more than geometry attribute
----------------------------------------------------------
Key: GEOT-3092
URL: http://jira.codehaus.org/browse/GEOT-3092
Project: GeoTools
Issue Type: Bug
Components: core feature
Affects Versions: 2.6.3
Environment: Windows XP
Reporter: Guillaume
When there are features with different geometries on a layer and the features
contains at least another attribute except the geometry, only one geometry will
be applied to all features (the first geometry).
The collection below will consider the second feature as a polygon but normally
it's a LineString.
But if the "name" attribute is not added to the SimpleFeatureTypeBuilder, this
phenomenon doesn't appear and it works well.
FeatureCollection<SimpleFeatureType, SimpleFeature> newCollection =
FeatureCollections.newCollection();
// First Feature
GeometryFactory geoFact =
JTSFactoryFinder.getGeometryFactory(null);
SimpleFeatureTypeBuilder typeBuilder = new
SimpleFeatureTypeBuilder();
typeBuilder.setName("Geometry");
typeBuilder.add("geometry", Polygon.class);
typeBuilder.add("name", String.class);
SimpleFeatureType type = typeBuilder.buildFeatureType();
Coordinate coord1 = new Coordinate(0, 0);
Coordinate coord2 = new Coordinate(0, 1);
Coordinate coord3 = new Coordinate(1, 1);
Coordinate coord4 = new Coordinate(1, 0);
Coordinate[] coords = new Coordinate[] {coord1, coord2, coord3,
coord4, coord1};
LinearRing ring = geoFact.createLinearRing(coords);
SimpleFeatureBuilder featureBuilder = new
SimpleFeatureBuilder(type);
featureBuilder.add(geoFact.createPolygon(ring, null));
featureBuilder.add("1");
newCollection.add(featureBuilder.buildFeature("1"));
// Second Feature
typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("Geometry");
typeBuilder.add("geometry", LineString.class);
typeBuilder.add("name", String.class);
type = typeBuilder.buildFeatureType();
coord1 = new Coordinate(2, 2);
coord2 = new Coordinate(3, 3);
coord3 = new Coordinate(2, 3);
coords = new Coordinate[] {coord1, coord2, coord3};
LineString line = geoFact.createLineString(coords);
featureBuilder = new SimpleFeatureBuilder(type);
featureBuilder.add(line);
featureBuilder.add("1");
newCollection.add(featureBuilder.buildFeature("2"));
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel