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

Error "Cannot read property 'bbox' of undefined" in GeoJSONReader.read for FeatureCollection containing "bbox" property #390

Open
cdmahoney opened this issue Aug 22, 2019 · 2 comments
Milestone

Comments

@cdmahoney
Copy link

Calling GeoJSONReader read method passing in a FeatureCollection containing a bbox property causes error TypeError: Cannot read property 'bbox' of undefined:

jsts-1.6.1.min.js:formatted:12466 Uncaught TypeError: Cannot read property 'bbox' of undefined
at Ai.FeatureCollection (jsts-1.6.1.min.js:formatted:12466)
at Ai.read (jsts-1.6.1.min.js:formatted:12436)
at qi.read (jsts-1.6.1.min.js:formatted:12618)

The problem is in the FeatureCollection method, where there is a reference to "this.parse" which appears to have been missed out from the changes in issue 256:

    if (obj.bbox)
      featureCollection.bbox = this.parse.bbox.call(this, obj.bbox)

Should be same as in Feature method:

    if (obj.bbox)
      featureCollection.bbox = parse.bbox.call(this, obj.bbox)
@bjornharrtell
Copy link
Owner

May be a valid issue, but can you reproduce it in the latest version (2.0.8)?

@cdmahoney
Copy link
Author

Sure, reproduced in 2.0.8, downloaded with https://unpkg.com/jsts@2.0.8/dist/jsts.min.js.

Test code:

var gjr = new jsts.io.GeoJSONReader();
gjr.read('{ "type": "FeatureCollection", "bbox": [0.16105767174684102, 40.523177071019411, 3.3321981172927941, 42.860690087654696], "features": [] }');

Same error as before:

jsts-2.0.8.min.js:formatted:13675 Uncaught TypeError: Cannot read property 'bbox' of undefined
at Ls.FeatureCollection (jsts-2.0.8.min.js:formatted:13675)
at Ls.read (jsts-2.0.8.min.js:formatted:13645)
at GeoJSONReader.read (jsts-2.0.8.min.js:formatted:13832)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants