Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you provide HD Map coordinate encoding and decoding feature from this library #74

Open
kyooryoo opened this issue May 23, 2023 · 1 comment

Comments

@kyooryoo
Copy link

According to the following HERE documentation, HERE HD Map use special encoding method for coordinates:
https://developer.here.com/documentation/here-lanes/dev_guide/topics/hd-map-coordinate-encoding.html
Can you add the feature for encoding and decoding the HERE HD Map coordinates such as follows:

def decode_here_2d_coordinate_int(encoded):
    encoded_bin = bin(int(encoded))[2:].rjust(64, '0')
    lon_bin = encoded_bin[1::2]
    lat_bin = encoded_bin[2::2]
    lat_bin = lat_bin.rjust(32, lat_bin[0])
    lon_uint = int(lon_bin, base=2)
    lat_uint = int(lat_bin, base=2)
    lon_int = struct.unpack('i', struct.pack('I', lon_uint))[0]
    lat_int = struct.unpack('i', struct.pack('I', lat_uint))[0]
    return lat_int, lon_int


def decode_here_2d_coordinate_diffs_offset(encoded_diffs, encoded_reference):
    coords = []
    #lat_int, lon_int = 0, 0
    lat_int, lon_int = decode_here_2d_coordinate_int(encoded_reference)
    for encoded in encoded_diffs:
        diff_lat_int, diff_lon_int = decode_here_2d_coordinate_int(encoded)
        lat_int ^= diff_lat_int
        lon_int ^= diff_lon_int
        lon_deg = lon_int * (360 / 2 ** 32)
        lat_deg = lat_int * (180 / 2 ** 31)
        coords.append((lat_deg, lon_deg))
    return coords
@abdullahselek
Copy link
Owner

@kyooryoo sorry for my late reply but I have so much got to do with other stuff, please feel free to open a PR with your suggested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants