maven依赖
<dependency> <groupId>com.vividsolutions</groupId> <artifactId>jts</artifactId> <version>1.13</version> </dependency>
public static void main(String[] args) {
// the first coordinate and last one is equal, as we need to close the line string.
Coordinate[] coordinates2 = new Coordinate[]{
new Coordinate("经纬度"),
new Coordinate("经纬度"),
new Coordinate("经纬度"};
Coordinate coordinate2 = new Coordinate("经纬度");
GeometryFactory geometryFactory = new GeometryFactory();
Point point = geometryFactory.createPoint(coordinate2);
Polygon polygon = geometryFactory.createPolygon(coordinates2);
boolean within = polygon.within(point);
System.out.println("判断坐标是否包含2:" + within);
}