Parsing the encode result is broken in CLI

Open
#71 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
cli

Research direction

Start with bin/polyline.bin.js and reproduce the issue using the supplied polyline.json input and --encode command. Compare its output with the shown GeoJSON node-script result, then trace the CLI input or output parser. Done means the CLI produces the expected encoded polyline for this input and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Description

bug

When attempting to save the result from the endcode flag, the outputted result is not the same as the outputted result from the GeoJSON node script. There is an issue with the parser of the input or output.

Steps to reproduce:

  1. polyline.json file includes:

[[-114.05130386352539,51.112359778280194],[-114.05130386352539,51.11947193091105],[-114.05611038208008,51.12324308281078][-114.06538009643555,51.126152046793365], [-114.0736198425293,51.12916855668462]]

  1. using : cat polyline.json | ./bin/polyline.bin.js --encode > encoded-poly.txt:

result in encoded-poly.txt:

"??????????_}hQ?????_qo]?~flW?_seK?~|hQ?_}hQ?_qo]?~reK?~|hQ?_seK?~|hQ?_}hQ?~reK?_{rc@?????~flW???????_ibE?_ibE?_seK?_glW?~reK???_ibE?~zrc@?_{rc@?~nyo@?_ibE?_oyo@?~po]?????????????????????????????????????_}hQ?????_qo]?~flW?_seK?~|hQ?_}hQ?_qo]?~reK?~|hQ?_seK?~|hQ?_}hQ?~reK?_{rc@?????~flW???????_oyo@?~po]?_}hQ?~zrc@?_oyo@?~zrc@?~|hQ?_y|u@?~nyo@???~hbE?_qo]?????????????????????????????????????_}hQ?????_qo]?_ibE?~po]???~hbE?_}hQ?_qo]?~zrc@?~reK?_oyo@?~nyo@???_oyo@?????~flW?????_ibE?_ibE?~hbE?_seK?~hbE?~|hQ?_oyo@?~zrc@?_{rc@?~dvi@?~hbE?_evi@?_ibE?????????????????????????????????????_}hQ?????_{rc@?~hbE?~reK?_qo]?~nyo@???_y|u@?~|hQ?~reK?~hbE?_seK?????????~flW?????_ibE?_glW?~po]?_glW?~|hQ?~reK?_glW?_seK?_ibE?_seK?~zrc@???_}hQ?~hbE?????????????????????????????????????_}hQ?????_evi@?~flW?_}hQ?~po]?_oyo@?~hbE?~flW?~reK?_}hQ?~|hQ?_evi@?~zrc@?????~flW?????_ibE?_evi@?~nyo@?_qo]?_seK?~|hQ???_ibE???_seK?~flW?_seK?~flW???????"

Compare to the result from the GeoJSON node script:

const polyline = require('@mapbox/polyline')
undefined
polyline.fromGeoJSON({ "type": "Feature",
... "geometry": {
..... "type": "LineString",
..... "coordinates": [[-114.05130386352539,51.112359778280194], [-114.05130386352539,51.11947193091105],[-114.05611038208008,51.12324308281078], [-114.06538009643555,51.126152046793365],[-114.0736198425293,51.12916855668462] ]
..... },
... "properties": {}
... });
'g{}vHrsbwTmk@?qV]eQ|x@{Qnr@'

Dominant language
JavaScript
Stars
674
Forks
101
PR merge metrics
No merged PRs in 30d

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.

More from mapbox/polyline

All issues in mapbox/polyline

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.