[Bug] GeoJsonLayer with binary data does not draw closed polygons
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 14.6k
- Forks
- 2.3k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 42
Description
Description
When using GeoJsonLayer to draw Polygons from binary data, closed shapes are not joined on the last position. For wide stroke widths, this causes a notched corner where line caps from the first and last vertex meet at different angles.
When the same polygon is provided via json data, the polygon is closed with no line caps.
Possible cause
The createLayerPropsFromBinary method in the GeoJsonLayer module explicitly sets _pathType = 'open' as the final part of parsing stroke geometry to pass to PathLayer. Unfortunately, because of how this is done, I couldn't figure out how to override it in my calling code.
I'm not sure why this is set, although I'm sure there's a good reason. This line appears in the initial commit to support binary data: https://github.com/visgl/deck.gl/commit/f11ee4f4cf673d6f1ee048f3785eac072fc9cd9a#diff-d1664e13173d9407c92e7ee39e9ff8aae2e325ab4c3a34cc1b091f8c44f7c4d4.
In the same commit a note in the docs was left which may be related?
- In binary format, there are some rendering issues with polygons or multipolygons which contain holes (the holes won't appear as expected), we're working to fix it for the next release.
The description of PathLayer's _pathType attribute (https://deck.gl/docs/api-reference/layers/path-layer#_pathtype) suggests that leaving this unset may cause better performance, so it would be great to be able to enable/disable this depending on your individual use case if you trust the quality of your data.
Just wanted to add a small note to say that this library is really amazing and has allowed me to accomplish so much in such a short time, all your hard work is truly appreciated!
Flavors
- Script tag
- React
- Python/Jupyter notebook
- MapboxOverlay
- GoogleMapsOverlay
- CartoLayer
- ArcGIS
Expected Behavior
Stroke on closed polygons should have corners drawn at the final position regardless of how the data is provided.
Steps to Reproduce
https://codepen.io/aethrXor/pen/MWMLvPQ?editors=0010
This repro defines a single GeoJson Polygon feature, and uses geojsonToBinary to convert it to binary. Two layers are created, one with the json data, one with the binary. Toggling visibility between the two layers, you can see a notch in the bottom right corner when the binary layer is visible.
Environment
- Framework version: deck.gl@9.0.28
- Browser: Chrome
- OS: Linux
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/layers/src/geojson-layer/geojson-layer-props.ts at createLayerPropsFromBinary and compare its stroke geometry handling with the JSON path used by GeoJsonLayer. Reproduce the issue with the linked CodePen and verify that the binary and JSON versions render closed polygon corners consistently, including with wide strokes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100