raphaelmor / Polyline

Polyline encoder / decoder in swift
MIT License
299 stars 50 forks source link

Zero-length polyline decodes as only one coordinate #59

Open 1ec5 opened 4 years ago

1ec5 commented 4 years ago

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]]}