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,