flexible-polyline icon indicating copy to clipboard operation
flexible-polyline copied to clipboard

'Decode' function for python doesn't have 'precision' parameter

Open alexisad opened this issue 3 years ago • 1 comments

Regarding this: https://developer.here.com/documentation/here-lanes/dev_guide/topics/hd-map-coordinate-encoding.html Platform data topologies have 7 digits of precision after the decimal point. But decode function by default returns only 5 digits after the decimal point.

Please add 'precision' parameter in the 'decode' function. Thanks

alexisad avatar Oct 06 '22 12:10 alexisad

The decoded precision depends on the precision used when encoding the polyline. The encoder has a default of 5 digits of precision but there is a parameter to change that:

import flexpolyline as fp
input = [
    (50.1022829, 8.6982122),
    (50.1020076, 8.6956695),
    (50.1006313, 8.6914960),
    (50.0987800, 8.6875156),
]
res = fp.encode(input, precision=7)
print(fp.decode(res))

Output:

[(50.1022829, 8.6982122), (50.1020076, 8.6956695), (50.1006313, 8.691496), (50.09878, 8.6875156)]

gtsystem avatar Oct 25 '22 12:10 gtsystem

I recommend to close this feature request.

  1. As Giuseppe commented, the number of available decimals depends on the precision specified during encoding, not the decoding.
  2. "Reducing" the precision of the decoded coordinates is basically a 1-liner in Python. e.g:
        pts = fp.decode(s)
        pts = [(round(lat, 3), round(lng, 3)) for lat, lng in pts]

This doesn't justify adding 'precision' and 'precision3d' arguments to the 'decode' method.

frankgae avatar Jun 06 '24 12:06 frankgae