If the bbox of overpass-layer changes just in its width (i.e. southern and northern edge remaining exactly the same), then the following error occurs in @turf/difference (version 6.0.2 as set in the lock file, and included in dist version)
Uncaught Error: Each LinearRing of a Polygon must have 4 or more Positions.
at Object.polygon (overpass-layer.js:3354)
at Object.difference (overpass-layer.js:3027)
at KnownArea.check (overpass-layer.js:35693)
at RequestBBox.needLoad (overpass-layer.js:34479)
at RequestBBox.mayFinish (overpass-layer.js:34483)
at overpass-layer.js:32280
at Array.forEach (<anonymous>)
at OverpassFrontend._overpassProcess (overpass-layer.js:32275)
at OverpassFrontend.<anonymous> (overpass-layer.js:32605)
at overpass-layer.js:23185
KnownArea.check calls difference with two bbox'es, and in this special constellation it fails. Minimal demo script:
const difference = require("@turf/difference")
const a = {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[9.95908498764038,49.7960939701678],[9.978911876678467,49.7960939701678],[9.978911876678467,49.79909957355378],[9.95908498764038,49.79909957355378],[9.95908498764038,49.7960939701678]]]}}
const b = {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[9.96085524559021,49.7960939701678],[9.977141618728638,49.7960939701678],[9.977141618728638,49.79909957355378],[9.96085524559021,49.79909957355378],[9.96085524559021,49.7960939701678]]]}}
console.log(difference(a, b));
This can also be reproduced with the overpass-layer demos, by e.g. opening the browser console to the right of the layer and then shrink the console after initial loading has completed.
The latest version of @turf/difference (6.3.0) has this fixed already, hence it'd suffice to simply update this dependency and rebuild.
If the bbox of overpass-layer changes just in its width (i.e. southern and northern edge remaining exactly the same), then the following error occurs in
@turf/difference
(version 6.0.2 as set in the lock file, and included in dist version)KnownArea.check
calls difference with two bbox'es, and in this special constellation it fails. Minimal demo script:This can also be reproduced with the overpass-layer demos, by e.g. opening the browser console to the right of the layer and then shrink the console after initial loading has completed.
The latest version of
@turf/difference
(6.3.0) has this fixed already, hence it'd suffice to simply update this dependency and rebuild.