1

I have tree bbox as follow: bbox 1, bbox 2, and bbox 3. Now I want to get Final bbox from bbox 1 in OpenLayers 5. How?

enter image description here

  • What is the role of bbox 2 here? – TomazicM Aug 14 at 7:02
  • Subtract bbox 2 and bbox 3 from bbox 1 – Morteza Malvandi Aug 14 at 7:58
  • But in your picture bbox 2 (blue) is not subtracted from Final bbox (green), only bbox 3 (blue) is. – TomazicM Aug 14 at 8:51
  • 1
    @TomazicM I presume the requirement is the bbox of the shaded area? i.stack.imgur.com/4PuC2.png – Mike Aug 14 at 9:09
  • 1
    It's the bbox of the result of removing the overlaps – Mike Aug 14 at 9:56
1

There's no built in method in OpenLayers, you would need to include a third party library such as turf.js

var poly1 = turf.bboxPolygon(bbox1);
var poly2 = turf.bboxPolygon(bbox2);
var poly3 = turf.bboxPolygon(bbox3);
var bbox = turf.bbox(turf.difference(turf.difference(poly1, poly3), poly2));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.