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

Collections GeoTools:创建点并将其添加到featureCollection,collections,gis,point,geotools,Collections,Gis,Point,Geotools,我正在实现轨迹点的插值。所以,基本上,我需要沿着从起点到终点的方位角创建几个点。问题是,我无法将创建的点添加到集合: SimpleFeatureType featureType = featureSource.getSchema(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); SimpleFeatureBuilder featureBuilder = new SimpleFeat

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

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); 
但是,当我运行此操作时,集合大小不会更改,并且不会向该集合添加任何内容。 我不确定这里有什么问题

谢谢,

尝试另一种方式:

  • 创建并向其中添加您的点
  • 然后使用将其添加到
    MapContent

最初的问题是“此集合中没有添加任何内容”。没错。我要说的是将另一个集合添加到
MapContent
。很抱歉,SimpleFeatureType对象存在问题,该对象已作为构造函数的形式参数应用于MemoryFeatureCollection,因此,没有显示任何内容。再次抱歉,您的解决方案帮助了我。