2

I am implementing an interpolation of trajectory points. So, basically, I need to create several points along the azimuth from a starting point to a destination point. The problem is, I can't add a created point to a collection:

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

However, when I run this, the collection size does not change and nothing gets added to this collection. I am not sure what's the problem here.

Thanks,

porter
  • 21
  • 4

1 Answers1

3

Not every implementation of SimpleFeatureCollection is mutable.

Try another way:

Victor Sergienko
  • 13,115
  • 3
  • 57
  • 91
  • The original problem is _"nothing gets added to this collection"_. That's correct. What I'm telling is to add *another* collection to the `MapContent`. – Victor Sergienko Mar 25 '13 at 14:33
  • Sorry, there were a problem with SimpleFeatureType object which has been applied to the MemoryFeatureCollection as formal parameter at constructor, thus, nothing was shown. Sorry once again, Your solution helps me. – Yuriy Chernyshov Mar 25 '13 at 15:09