2012-03-08 1170 views
1

我正在實現軌跡點的插值。所以,基本上,我需要沿着從起點到終點的方位角創建幾個點。問題是,我無法在創建點添加到集合:GeoTools:創建一個點並將其添加到featureCollection中

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); 

然而,當我運行此,集合的大小沒有改變,沒有什麼被添加到該集合。 我不知道這裏有什麼問題。

謝謝,

回答

2

Not every implementation of SimpleFeatureCollection is mutable

嘗試另一種方式:

+0

它對我來說是一樣的結果作爲一個問題的來源... – 2013-03-25 14:28:37

+0

原來的問題是_「沒有任何東西被添加到這個集合」_。這是正確的。我說的是將另一個*集合添加到'MapContent'中。 – 2013-03-25 14:33:57

+0

對不起,SimpleFeatureType對象存在一個問題,該對象已經作爲構造函數的形式參數應用於MemoryFeatureCollection,因此沒有顯示任何內容。再次抱歉,您的解決方案可以幫助我。 – 2013-03-25 15:09:21

相關問題