#3041·turf

booleanValid incorrectly returns true for coordinates outside valid range (e.g., >180)

Author: UserluckytianCreated Mar 18, 2026Updated May 27, 2026

@turf/turf: v7.3.0

booleanValid 函数目前不检查坐标值的有效范围(如经度 > 180 或纬度 > 90),这可能导致下游应用在处理这些“几何有效但数值无效”的数据时出错

译: booleanValid currently does not check the valid range of coordinate values (such as longitude > 180 or latitude > 90), which may lead to errors in downstream applications when processing these "geometrically valid but numerically invalid" data

复现步骤(reproduction steps)

javascript
const geom = {
    "type": "Feature",
    "geometry": {
        "type": "Polygon",
        "coordinates": [[[181, 181], [181, 182], [182, 182], [182, 181], [181, 181]]]
    }
};
const result = turf.booleanValid(geom); // 期望是 false,但实际返回 true(The expectation is false, but the actual return is true)
console.log(result);

codepen

https://codepen.io/userluckytian/pen/myrmNeP