Dears.
I want to add some points (read from memory or files) onto an existing layer 
(read from a shapefile). 
Firstly, the app will open a shapefile (as tutorial does) and a layer of lines 
shows up. Then,
the code for adding a new layer:
final SimpleFeatureType NODETYPE = DataUtilities.createType("Location",
                "the_geom:Point:srid=4326," + // <- the geometry attribute: 
Point type
                "id:String," +   // <- a String attribute
                "number:Integer"   // a number attribute
        );
Style style = createNodeStyle();
 List<SimpleFeature> nodeFeatures = new ArrayList<SimpleFeature>();
     
 GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();


 SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(NODETYPE);
Iterator nodeIte = graph.nodes.entrySet().iterator();
while (nodeIte.hasNext()) {


Map.Entry entry = (Map.Entry) nodeIte.next();
String id = (String) entry.getKey();
Node node = (Node) entry.getValue();


com.vividsolutions.jts.geom.Point point = geometryFactory
.createPoint(node.coordinate);


featureBuilder.add(point);
featureBuilder.add(id);
featureBuilder.add(0);
SimpleFeature feature = featureBuilder.buildFeature(null);
nodeFeatures.add(feature);
}
SimpleFeatureCollection featureCollection = new ListFeatureCollection(NODETYPE, 
nodeFeatures);
MapContent map = mapFrame.getMapContent();
map.layers().add(new FeatureLayer(featureCollection, style));
-------------------------------------------------------------------------------------------------
mapFrame is the main frame which has opened the shapefile
After above operation, I can see a new layer is added to the MaplayerTable, but 
the nodes can not show up.
Plus, the coordinates of the nodes are correct, because if I add those nodes to 
a new JMapFrame, they can show up successfully.
Can anyone help me?
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to