I did not found any function to check if a polygon is inside another polygon, therefore I tried to implement a function using booleanPointInPolygon and booleanCrosses: a polygon inside another polygon must have all its points in the polygon AND have no line crossing a line of the polygon.
Unfortunately, while testing I noted that the booleanCrosses gives weird results. Then, I tested the example on the website, but if you simply invert the arguments, it does not work. I believe that if line1 crosses line2, then line2 crosses line1 ... or am I crazy? ^^
const line1 = turf.lineString([
[-2, 2],
[4, 2],
]);
const line2 = turf.lineString([
[1, 1],
[1, 2],
[1, 3],
[1, 4],
]);
console.log('CROSS', turf.booleanCrosses(line1, line2), turf.booleanCrosses(line2, line1));
// gives "true, false"
// :(
I did not found any function to check if a polygon is inside another polygon, therefore I tried to implement a function using booleanPointInPolygon and booleanCrosses: a polygon inside another polygon must have all its points in the polygon AND have no line crossing a line of the polygon.
Unfortunately, while testing I noted that the booleanCrosses gives weird results. Then, I tested the example on the website, but if you simply invert the arguments, it does not work. I believe that if line1 crosses line2, then line2 crosses line1 ... or am I crazy? ^^
const line1 = turf.lineString([
[-2, 2],
[4, 2],
]);
const line2 = turf.lineString([
[1, 1],
[1, 2],
[1, 3],
[1, 4],
]);
console.log('CROSS', turf.booleanCrosses(line1, line2), turf.booleanCrosses(line2, line1));
// gives "true, false"
// :(