发布网友 发布时间:2022-04-25 12:38
共2个回答
热心网友 时间:2024-05-29 19:00
使用第三方jar包 jts包 例子如下面 \x0d\x0a\x0d\x0a//一个面所包含的经纬度(标准的经纬*3600000) \x0d\x0aString str = "POLYGON ((4191412 143703543, 4191481 143702737, 4191494 143702527,4191412 143703543))"; \x0d\x0aWKTReader wkt = new WKTReader(); \x0d\x0aGeometry geojudge1 = wkt.read(str); \x0d\x0aint xpoi = 4191481; \x0d\x0aint ypoi = 143702737; \x0d\x0aGeometry geojudge2 = wkt.read("POINT(" + xpoi + " " + ypoi + "))"); \x0d\x0a\x0d\x0aif(geojudge1.intersects(geojudge2)) { \x0d\x0aSystem.out.println("xpoi、ypoi 在这个面里"); \x0d\x0a} \x0d\x0a\x0d\x0aps:在构成一个面的时候,第一个点的经纬度一定要与最后一个点的经纬度相同。否则会报错误:java.lang.IllegalArgumentException: points must form a closed linestring
热心网友 时间:2024-05-29 19:00
使用第三方jar包 jts包 例子如下面
//一个面所包含的经纬度(标准的经纬*3600000)
String str = "POLYGON ((4191412 143703543, 4191481 143702737, 4191494 143702527,4191412 143703543))";
WKTReader wkt = new WKTReader();
Geometry geojudge1 = wkt.read(str);
int xpoi = 4191481;
int ypoi = 143702737;
Geometry geojudge2 = wkt.read("POINT(" + xpoi + " " + ypoi + "))");
if(geojudge1.intersects(geojudge2)) {
System.out.println("xpoi、ypoi 在这个面里");
}
ps:在构成一个面的时候,第一个点的经纬度一定要与最后一个点的经纬度相同。否则会报错误:java.lang.IllegalArgumentException: points must form a closed linestring