简体   繁体   中英

$geoIntersects does not work when there is self intersect

I below scenario i am getting perfect result for mongo $geoIntersec query在此处输入图片说明

But for below scenario where I am not getting result correct result in Mongo DB $geoIntersect query在此处输入图片说明

I think mongo does not allow self intersetion which is indecated in image in red color.

Is there any other way to get result?

According to mongodb documentation it does not support intersecting polygons. What it supports are these

  1. Polygons with a Single Ring
  2. Polygons with Multiple Rings
  3. MultiPolygon

Kindly refer to this in case you need to know more

Well, yes Mongodb does not allow self-intersecting polygons. you can store them. but wont be able to perform any spatial indexing on them, or use $geointersects etc. You need to resolve the polygons first. There is a npm module for this turf-kinks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM