Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript

Home Page:https://turfjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

booleanContains doesn't get good result when detect an unusual polygon

adoin opened this issue · comments

Please provide the following when reporting an issue:

  • [ x] The version of Turf you are using, and any other relevant versions.
    ^7.0.0-alpha.114
  • [ x] GeoJSON data as a [gist file]
const box =  {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          116.36030641999426,
          39.91345040344761
        ],
        [
          116.35987523334947,
          39.9229132365226
        ],
        [
          116.37431998594991,
          39.92252589496024
        ],
        [
          116.36734913519248,
          39.91887370878366
        ],
        [
          116.37266710381155,
          39.91516598561908
        ],
        [
          116.37185083186596,
          39.914325401230776
        ],
        [
          116.36030641999426,
          39.91345040344761
        ]
      ]
    ]
  }
}
const item = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          116.36393557425471,
          39.92003566676075
        ],
        [
          116.36479794754429,
          39.917102758606376
        ],
        [
          116.3681755762618,
          39.917158097668036
        ],
        [
          116.36882235622899,
          39.92047835887995
        ],
        [
          116.36566032083387,
          39.92119772742078
        ],
        [
          116.36393557425471,
          39.92003566676075
        ]
      ]
    ]
  }
}
  • [ x] Snippet of source code or for complex examples use jsfiddle.
    If needed I can create one tomorrow.
  • [ x] Verify this issue hasn't already been reported, or resolved in the latest alpha pre-release.

Snipaste_2024-03-13_22-12-48

How booleanContains(box, item) get true?
If I want a function to detect fully contains item. What should I do.

Hi @adoin . The library turf uses to check this has some bugs. We are going to investigate if there is a better library we can use that will make your example work.