概述
报错信息如下:
org.locationtech.jts.geom.TopologyException: found non-noded intersection between LINESTRING ( 115.081751296 22.877495404, 115.08235485099999 22.877178259000004 )......
查看多边形发现存在自相交的情况:
解决办法:自己和自己做一次叠加分析,将返回结果再和其它多边形进行叠加分析。
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null);
WKTReader reader = new WKTReader(geometryFactory);
String wktPolygon1 = "POLYGON((115.056659208438 22.8705758182769, 115.056659208438 22.8630881201852, 115.075378453668 22.8630881201852, 115.073267702012 22.8676901910949, 115.064758191781 22.8712427237672, 115.060642026572 22.8712427237672, 115.056659208438 22.8705758182769))";
Geometry geometry1 = reader.read(wktPolygon1);
// 图形存在自相交的情况
String wktPolygon2 = "MULTIPOLYGON (((115.081751296 22.877495404, 115.08235485099999 22.877178259000004, 115.08187908699995 22.877199625000003, 115.08186948800005 22.877064256999972, 115.08234682600005 22.877049725000006, 115.08235485099999 22.877178259000004, 115.08253756700003 22.87708225, 115.081394789 22.876617703000022, 115.081393606 22.876618759999985, 115.08134342999995 22.876644435999992, 115.08130771200001 22.876678020999975, 115.08127786700004 22.87672623200001, 115.08107261099997 22.87712563399998, 115.08103419400004 22.877173486000004, 115.08102423900004 22.877191219999986, 115.08102438699996 22.877209929999992, 115.08103463199996 22.87722856900001, 115.08104820799997 22.87724302999999, 115.08118117100003 22.877315925000005, 115.08137075299999 22.87741251800003, 115.081543839 22.877451877999988, 115.08165843200004 22.877471886000023, 115.08169104499996 22.877482059999977, 115.081751296 22.877495404)))";
Geometry geometry2 = reader.read(wktPolygon2);
// 自相交
Geometry geometry2IntersectGeometry2 = geometry2.intersection(geometry2);
Geometry geometry1IntersectGeometry2 = geometry1.intersection(geometry2IntersectGeometry2);
System.out.println(geometry1IntersectGeometry2);
参考文章:
1,Java Geometry计算轨迹与围栏交集效率测试及异常处理
intersection 是通过图形的交点判断的,当一个图形本身存在自相交的情况就会异常,当判断相交的这两不是共有的就会异常
1,修复ploygon
2,
判定多边形(围栏)是否对本身包含
如果为假,则直接通过判断轨迹点是否在围栏内部进行分段计算。
3,自相交下降multi 变为普通的 挖掉自相交的点,以其两端相邻点为边界点
原始:
自相交后:相当于geom自己修复
最后
以上就是霸气灯泡为你收集整理的【GeoTools】geotools空间分析存在自相交情况时的错误解决的全部内容,希望文章能够帮你解决【GeoTools】geotools空间分析存在自相交情况时的错误解决所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复