Solr Spatial search with self-intersecting polygons

喜夏-厌秋 提交于 2019-12-11 10:27:46

问题


I’m using Solr 4.3.0 with an up to date version of JTS and spatial4j. As field type in my schema.xml i’m using “location_rpt” like the description in the documentation. Documentation

<field name="standort" type="location_rpt" indexed="true" stored="true" />

Now when my Application create a FilterQuery like this

standort:"IsWithin (POLYGON((16.243972778320312 48.27016879304729, 16.411170959472656 48.268340583150504, 16.44275665283203 48.19058119922813, 16.32396697998047 48.15921534239267,16.243972778320312 48.27016879304729)))

everything works fine. My problem is when im trying to use a more complex polygon (self-intersecting) Solr only shows an Error like this:

org.apache.solr.common.SolrException: com.spatial4j.core.exception.InvalidShapeException: Self-intersection at or near point (16.315572194579204, 48.26688289499306, NaN)

the corresponding query looks like this:

standort:"IsWithin (POLYGON((16.253585815429688 48.27748097861045, 16.506271362304688 48.23427822033628, 16.418380737304688 48.18646123261718, 16.286544799804688 48.28958948415696,16.253585815429688 48.27748097861045)))"

Screen of the Polygon

Are there any workarounds to get self-intersecting polgyon querys to work?


回答1:


No, not really. You can use JTS on the client to clean up your polygon so that when Solr gets it, it's valid. See http://tsusiatsoftware.net/jts/jts-faq/jts-faq.html#G



来源:https://stackoverflow.com/questions/17613561/solr-spatial-search-with-self-intersecting-polygons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!