java - 如何在Java JTS中找到给定线段的平行线(源代码行上方和下方的平行线)?

标签 java geometry jts

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

坐标[]坐标=新坐标(新坐标(经纬度),新坐标(经纬度));

源代码行->

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

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

最佳答案

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

关于java - 如何在Java JTS中找到给定线段的平行线(源代码行上方和下方的平行线)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46319815/

相关文章:

java - 在与外部同步相同的对象上进行内部同步

swift - 删除或编辑用户位置蓝色脉冲圆圈

apache-spark - JTS 拓扑套件中的 STRtree : bulk load data and build index

android - build.gradle 上的 JTS Topology Suite 1.15.0

java - Wicket 表格和后退按钮问题

java - 填充主链接下的链接时出现问题,Selenium Webdriver

node.js - 无法删除多边形之间的区域交叉点

java - 如何在 JTS 中将 jts.geom.Geometry 对象的坐标从 Lat、Long 转换为 Long、Lat

java - 在 HTML 文档上添加结束标签以便应用 XSLT 的简单方法

mysql - 使用 CONCAT/GROUP CONCAT 合并 mysql 中的多行