shp2geobuf fails with shapefile containing one feature
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
``` bash
shp2geobuf data/polygon.shp > data/polygon.geobuf
/Users/artem/Projects/mapbox/geobuf/encode.js:50
if (obj.type === 'FeatureCollection') {
^
TypeError: Cannot read property 'type' of undefined
at analyze (/Users/artem/Projects/mapbox/geobuf/encode.js:50:12)
at encode (/Users/artem/Projects/mapbox/geobuf/encode.js:26:5)
at /Users/artem/Projects/mapbox/geobuf/bin/shp2geobuf:8:26
at /Users/artem/Projects/mapbox/geobuf/node_modules/shapefile/index.js:14:23
at /Users/artem/Projects/mapbox/geobuf/node_modules/shapefile/read.js:26:29
at notify (/Users/artem/Projects/mapbox/geobuf/node_modules/shapefile/node_modules/queue-async/queue.js:45:26)
at /Users/artem/Projects/mapbox/geobuf/node_modules/shapefile/node_modules/queue-async/queue.js:35:11
at /Users/artem/Projects/mapbox/geobuf/node_modules/shapefile/read.js:17:33
at /Users/artem/Projects/mapbox/geobuf/node_modules/shapefile/index.js:70:27
at readRecordHeader (/Users/artem/Projects/mapbox/geobuf/node_modules/shapefile/shp.js:34:40)
```
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
Reproduce the command shown with data/polygon.shp, then read bin/shp2geobuf and encode.js, especially analyze at the reported failure. Trace the one-feature input through the CLI and encoding path; done means the command completes without the TypeError and produces data/polygon.geobuf.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100