开源项目:https://github.com/locationtech/jts
网站:https://projects.eclipse.org/projects/locationtech
网站:https://locationtech.github.io/jts/
Java文档(jts-core):https://locationtech.github.io/jts/javadoc/
Java文档(jts-io-common):https://locationtech.github.io/jts/javadoc-io/index.html
使用指南:https://github.com/locationtech/jts/blob/master/USING.md
依赖
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.18.2</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-io</artifactId>
<version>1.18.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.locationtech.jts.io</groupId>
<artifactId>jts-io-common</artifactId>
<version>1.18.2</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts</artifactId>
<version>1.18.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-modules</artifactId>
<version>1.18.2</version>
<type>pom</type>
</dependency>
常用功能
1、几何体转WKT。
import org.locationtech.jts.geom.*;
import org.locationtech.jts.io.WKTWriter;
public class Application {
public static void main(String[] args) {
Coordinate coord = new Coordinate();
coord.setX(10);
coord.setY(20);
GeometryFactory factory = new GeometryFactory();
Point point = factory.createPoint(coord);
WKTWriter writer = new WKTWriter();
System.out.println(writer.write(point));
}
}
2、WKT转几何体。