Skip to content

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

Description

@Userluckytian

@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)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions