【问题标题】:How to find a parallel line for a given line segment (both the parallel line which is above and below of my source line) in Java JTS?java - 如何在Java JTS中找到给定线段的平行线(我的源线上方和下方的平行线)?
【发布时间】:2018-03-01 09:11:04
【问题描述】:

如何在 Java JTS (JTS Topology Suite) 中找到给定线段的平行线(我的源线上方和下方的平行线)? 输入:我的源代码行有 Points(long & lat) 坐标1(经度、纬度)---------------------------- 坐标2(经度、纬度)

Coordinate[] coordinate= new Coordinate(new Coordinate(Long, Lat), new Coordinate(Long, Lat));

源码->

LineSegment sourceLine =new GeometryFactory().createLineString(coordinate);

现在我必须在它的上方和下方找到一条与源线平行的线。

【问题讨论】:

    标签: java geometry jts


    【解决方案1】:

    在起点计算方位B0
    将轴承旋转 90 度 B01=B0+90 并使用轴承 B1 在所需距离处获得点 P01
    对终点做同样的事情(注意方位略有不同),得到点P11PO1-P11 是第一行

    -90 roteted 的轴承做同样的事情,构建第二行

    Here are formulas 获取给定距离和方位的方位和指向

    【讨论】:

      【解决方案2】:

      为此目的,LineSegment 上有一个 pointAlongOffset(double segmentLengthFraction, double offsetDistance) 方法。示例:

      // source line from given start and end coordinate
      LineSegment sourceLine = new LineSegment(startCoordinate, endCoordinate);
      
      // left from start- to end-point (note negative offset distance!)
      Coordinate startLeft = sourceLine.pointAlongOffset(0, -parallelDistance);
      Coordinate endLeft = sourceLine.pointAlongOffset(1, -parallelDistance);
      LineString leftLine = new GeometryFactory().createLineString(new Coordinate[]{startLeft, endLeft});
      // right from start- to end-point (note positive offset distance!)
      Coordinate startRight = sourceLine.pointAlongOffset(0, parallelDistance);
      Coordinate endRight = sourceLine.pointAlongOffset(1, parallelDistance);
      LineString rightLine = new GeometryFactory().createLineString(new Coordinate[]{startRight, endRight});
      

      【讨论】:

        猜你喜欢
        • 2022-06-28
        • 1970-01-01
        • 2017-04-23
        • 1970-01-01
        • 2021-12-25
        • 1970-01-01
        • 2013-01-18
        • 1970-01-01
        • 2017-06-07
        相关资源
        最近更新 更多