Write Dimension Field When Encoding
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
#### Problem
The encoder only writes the dimension field if [dim != 2](https://github.com/mapbox/geobuf/blob/daad5e039f842f4d4f24ed7d59f31586563b71b8/encode.js#L31), otherwise, no dimension is written when encoded. While this works fine for the JS decoder (because it forces [dim = 2](https://github.com/mapbox/geobuf/blob/daad5e039f842f4d4f24ed7d59f31586563b71b8/decode.js#L12) when decoding), this can lead to decoding issues when decoding outside of the JS decoder. I recently ran into this issue and upon searching this and the pygeobuf repo, I posted a similar explanation of the issue, including:
1. Decoding in the Python Implementation of Geobuf: [Pygeobuf](https://github.com/pygeobuf/pygeobuf/issues/59)
2. Decoding from [PostGIS](https://github.com/mapbox/geobuf/issues/128)
#### Proposed Solution
When encoding, allow dimensions to be an argument that a user can insert, otherwise, default to 2 rather than not writing the dimension field. This way all encoded data defaults to a 2D space (unless otherwise noted), which makes the geobuf data easier to decode outside the JS decoder.
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 with encode.js around line 31 and compare it with decode.js around line 12, then review the linked Pygeobuf and PostGIS reports for compatibility expectations. The change is done when encoding writes a default dimension of 2 while allowing another dimension to be supplied, without breaking decoding behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100