【问题标题】:how to simplify a line using JTS?如何使用 JTS 简化线路?
【发布时间】:2015-06-02 12:41:37
【问题描述】:

我有一个List<Coordinate>,它代表一条路线。

我想用 JTS 来简化它。

我看到的方法很少,但我不确定哪一种最适合我的需求:

1) 如何将我的坐标转换为几何图形(线?)

TopologyPreservingSimplifier(Geometry inputGeom) 

void    setDistanceTolerance(double distanceTolerance) 

Geometry    getResultGeometry() 

2)

DouglasPeuckerLineSimplifier(Coordinate[] pts) 

 void   setDistanceTolerance(double distanceTolerance) 

 Coordinate[]   simplify() 

static Coordinate[] simplify(Coordinate[] pts, double distanceTolerance) 

3) 也许是这个?

TopologyPreservingSimplifier.simplify(geom, threshold-in-degrees-that-depends-on-the-length);

【问题讨论】:

    标签: java geometry line coordinates jts


    【解决方案1】:

    要简化一条线,您首先必须有一条线。因此,首先使用 GeometryFactory 实例的 createLineString(Coordinate[]) 方法构建您的 LineString。

    然后只需使用 DouglasPeuckerSimplifier (您不需要只保留一条线的拓扑,起点和终点都是那里的拓扑,它们不会改变)。如果您想稍后使用它,您将不得不再次将结果转换为 LineString。而且您必须选择适当的容差。

    LineString lss = (LineString) DouglasPeuckerSimplifier.simplify(ls, tolerance);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-09
      • 2021-03-22
      • 1970-01-01
      • 2021-07-19
      • 1970-01-01
      • 1970-01-01
      • 2011-09-17
      • 1970-01-01
      相关资源
      最近更新 更多