mapbox / mapbox/geobuf

shp2geobuf fails with shapefile containing one feature

Open
#36 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug ready
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.