gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:54:55 32 4
gpt4 key购买 nike

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

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

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

谢谢,

最佳答案

Not every implementation of SimpleFeatureCollection is mutable .

尝试另一种方式:

  • 创建 new DefaultFeatureCollection 并添加您的积分;
  • 然后将其添加到 MapContent addLayer .
  • 关于collections - GeoTools:创建一个点并将其添加到 featureCollection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9626719/

    32 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com