Polyline icon indicating copy to clipboard operation
Polyline copied to clipboard

Zero-length polyline decodes as only one coordinate

Open 1ec5 opened this issue 4 years ago • 0 comments

Decoding a zero-length polyline consisting of two coincident endpoints returns an array of only one CLLocationCoordinate2D, which would be a malformed line string:

decodePolyline("s{byuArigzhF", precision: 1e6)
▿ Optional<LineString>
  ▿ some : LineString
    ▿ coordinates : 1 element
      ▿ 0 : CLLocationCoordinate2D
        - latitude : 45.516746
        - longitude : -122.605738

By comparison, the @mapbox/polyline 1.1.0 NPM package decodes the same string to GeoJSON as a line string with two coordinates:

polyline.decode('s{byuArigzhF', 6);
{"type":"LineString","coordinates":[[-122.605738,45.516746],[-122.605738,45.51674]]}

1ec5 avatar Sep 08 '20 23:09 1ec5