GeoTools:创建一个点并将其添加到featureCollection

时间:2012-03-08 23:29:22

标签: collections gis point geotools

我正在实施轨迹点的插值。所以,基本上,我需要沿着方位角从起点到目的点创建几个点。问题是,我无法在集合中添加创建的点:

SimpleFeatureType featureType = featureSource.getSchema(); 

GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); 
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType); 

SimpleFeatureCollection collection = featureSource.getFeatures(); 

/* Irrelevant code here 
----------------------- 
*/ 

Point2D newPt = setPointByAzimuth(startingPointCoords, azimuth, distance_to_next_point); 

Point pointToCollection = geometryFactory.createPoint(new Coordinate(newPt.getX(), newPt.getY())); 

featureBuilder.add(pointToCollection); //not quite sure what this does 

SimpleFeature feature = featureBuilder.buildFeature(null);       

collection.add(feature); 

但是,当我运行它时,集合大小不会更改,也不会向此集合添加任何内容。 我不知道这里有什么问题。

谢谢,

1 个答案:

答案 0 :(得分:2)

Not every implementation of SimpleFeatureCollection is mutable

尝试另一种方式: