Open letmaik opened 8 years ago
Just found an example where it doesn't work:
var loops = [
[ [ -1, 55 ], [ 21, 55 ], [ 21, 51 ], [ -1, 51 ] ],
[ [ 15, 51 ], [ 35, 51 ], [ 35, 47 ], [ 15, 47 ] ]
]
var classifyPoint = require('point-in-big-polygon')(loops)
assert.equal(classifyPoint([20,50]), -1) // fails, is 1
One edge of each loop is touching each other. Could that be the problem?
Currently point-in-big-polygon assumes that there are no self intersections or double points in the polygon.
If you want to classify a point against many polygons you should use point-in-region instead.
If you have a bunch of non-overlapping polygons, is it possible to use this library by collecting all loops of all polygons instead of checking each polygon separately in a for loop?
For example this seems to work:
In the example in the README, the second loop is given in anti-clockwise order, whereas in my example both are in clockwise order. Is that the trick? Do all holes have to be in anti-clockwise order otherwise?