Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoJSON.readFeatures throws error when coordinates are empty (since 8.2) #15464

Closed
GastonZalba opened this issue Jan 5, 2024 · 1 comment
Closed
Labels

Comments

@GastonZalba
Copy link

Describe the bug
In Open Layer 8.2, the method readFeatures from GeoJSON throws error if a LineString has empty coordinates. The error was introduced in 4c7bd4a. The error message is:

TypeError: Cannot read properties of undefined (reading 'length')
    at GeoJSON.js:407:47
    at xw (GeoJSON.js:315:18)
    at ww.readFeatureFromObject (GeoJSON.js:125:22)
    at ww.readFeaturesFromObject (GeoJSON.js:175:36)
    at ww.readFeatures (JSONFeature.js:53:17)

To Reproduce

const exampleData =  {
    type: 'FeatureCollection',
    features: [
        {
            type: 'Feature',
            geometry: {
                type: 'LineString',
                coordinates: []
            },
            properties: {}
        }
    ]
};

const features = new GeoJSON().readFeatures(exampleData);

Expected behavior
Parse the feature successfully as previous versions (returning an feature with an empty geometry).

@GastonZalba GastonZalba added the bug label Jan 5, 2024
@ahocevar
Copy link
Member

ahocevar commented Jan 5, 2024

This has been fixed with #15388 already. Please npm install ol@dev until the latest version contains this fix.

@ahocevar ahocevar closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants