【问题标题】:JAVA distinguish curved line from straight lineJAVA区分曲线和直线
【发布时间】:2015-10-20 12:20:13
【问题描述】:

我遇到了一个问题,我不确定如何判断给定的 (com.esri.arcgis.geometry.Polyline) 折线是否是直的。我的代码适用于直线,但不适用于曲线。我的问题是我不确定如何从折线中获取点列表,并且不确定如何在获得此点列表后检查线是否是直的。代码如下:

 else if (shape instanceof Polyline) {
                    Polyline line = (Polyline) shape;
                    Point lowerLeft = (Point) line.getEnvelope().getLowerLeft();
                    Point upperRight = (Point) line.getEnvelope().getUpperRight();
                    Point midpoint = GeometryUtil.getMidpoint(lowerLeft, upperRight);
                    midpoint.setSpatialReferenceByRef(ActiveMapContainer.getInstance()
                                                              .getMapBean().getSpatialReference());
                    GeometryUtil.projectLatLong(midpoint);

【问题讨论】:

    标签: java esri polyline


    【解决方案1】:

    您可以使用“getLength()”方法获取折线上的点数。 您可以通过“getPoint(int i)”方法获取每个点。

    可能有更好的方法,但我会检查直线是否是直的: 1. 计算第一个点和最后一个点之间的距离。 2. 将其与整个折线的长度进行比较。如果两者相等(可能使用某种可接受的长度差异 - “delta”),则假设直线是直的。如果它们相差大于“delta”的因子,则假设该线不是直的。

    【讨论】:

      猜你喜欢
      • 2018-07-09
      • 2021-05-19
      • 2013-05-30
      • 2017-08-18
      • 1970-01-01
      • 2010-12-25
      • 1970-01-01
      相关资源
      最近更新 更多