1

我有这个多边形:

const polygon = JSON.parse('{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[6.26950853,50.72473626],[6.26953794,50.72468996],[6.2695546,50.7246512],[6.26949169,50.72468741],[6.26948194,50.72469389],[6.26946154,50.72470787],[6.26949172,50.72474162],[6.26950853,50.72473626]]]}}');

这个边界框:

const bbox = JSON.parse('{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[6.511887823915231,50.950514414615334],[6.512896634823051,50.53594214902105],[5.98503728350704,50.53594214902105],[5.98604609441486,50.950514414615334],[6.511887823915231,50.950514414615334]]]}}');

我想知道多边形是否与边界框相交

为此,我使用了turf.js中的booleanOverlap

turf.booleanOverlap(polygon, bbox);

它返回false

这是为什么?这绝对是在边界框内。

4

1 回答 1

2

啊,我明白了。文件说

“比较两个相同尺寸的几何,如果它们的交集导致几何不同但尺寸相同,则返回真。[...]”

我的多边形完全在边界框内。据我所知,交叉点(如文档所述)包含另一个多边形内的多边形。booleanOverlap所做的只是检查它是否重叠。我认为文档在这里有点误导,因为它让用户认为其中booleanOverlap包含一个内部。

于 2018-03-26T16:51:28.653 回答