How to Convert Between HERE HDLM 2D Coordinates and WGS84 Latitude/Longitude ?
---
How to Convert Between HERE HDLM 2D Coordinates and WGS84 Latitude/Longitude?
=============================================================================
---
Unable to Interpret HDLM Coordinates or Compare HDLM Data with GPS Coordinates
==============================================================================
Symptoms
--------
You may encounter one or more of the following:
HDLM geometry contains large integer coordinate values instead of standard latitude/longitude coordinates.
HDLM locations cannot be directly visualised in GIS or mapping applications.
GPS traces do not appear to align with HDLM geometry.
Decoded HDLM coordinates resolve to unexpected geographic locations.
Conversion between WGS84 and HDLM coordinates produces inconsistent results.
HDLM lane, geometry, or localisation data requires validation against external mapping systems.
---
Quick Answer
------------
HERE HD Live Map (HDLM) stores geographic positions as a compact signed 64-bit integer rather than standard WGS84 latitude and longitude values. To visualise or analyse HDLM data, engineers must decode the interleaved longitude and latitude bit structure and apply the appropriate scaling formulas to obtain WGS84 coordinates.
---
Applicable Products
-------------------
HERE HD Live Map (HDLM)
HDLM RDF Content
HDLM Geometry Data
HDLM Lane Model
HDLM Localisation Datasets
---
HDLM Coordinate Encoding Overview
=================================
HDLM stores a geographic location as a single 64-bit signed integer. Internally, longitude is represented as a 32-bit value and latitude is represented as a 31-bit value. These longitude and latitude bits are interleaved into one 63-bit stream, with the highest bit reserved as the sign bit.
Longitude bits (32)
Latitude bits (31)
Interleave bits
64-bit signed integer
---
HDLM to WGS84 Conversion
========================
Step 1: Convert the HDLM Coordinate to Binary
---------------------------------------------
Example HDLM coordinate:
4354955124161939766
Binary representation:
0011110001101111111010001001110010100100011100001000100100110110
---
Step 2: Remove the Leading Sign Bit
-----------------------------------
011110001101111111010001001110010100100011100001000100100110110
---
Step 3: Separate Longitude and Latitude Bits
--------------------------------------------
Read the payload from left to right:
Bit 1 → Longitude
Bit 2 → Latitude
Bit 3 → Longitude
Bit 4 → Latitude
Continue until all bits have been processed.
Longitude bits:
01101011100001100010110000010110
Latitude bits:
1100111111010101100010010100101
---
Step 4: Convert Binary Values to Integers
-----------------------------------------
Longitude integer:
1803955222
Latitude integer:
-404044635
Latitude must be decoded as a signed 31-bit integer.
---
Step 5: Convert Integers to Degrees
-----------------------------------
Latitude:
latitude = latitude_int × (180 / 2^31)
Longitude:
longitude = longitude_int × (360 / 2^32)
Result:
Latitude = -33.866630075499415
Longitude = 151.20577996596694
---
WGS84 to HDLM Conversion
========================
The reverse conversion follows the same logic in the opposite direction.
Step 1: Convert Degrees to Integer Representation
-------------------------------------------------
latitude_int = floor(latitude / (180 / 2^31))
longitude_int = floor(longitude / (360 / 2^32))
---
Step 2: Convert Integers to Binary
----------------------------------
Generate:
A 31-bit signed latitude value
A 32-bit longitude value
---
Step 3: Interleave the Bits
---------------------------
longitude_bit_1
latitude_bit_1
longitude_bit_2
latitude_bit_2
...
---
Step 4: Add the Leading Sign Bit
--------------------------------
Prepend the sign bit to create the final HDLM coordinate.
---
Conversion Formula Reference
============================
HDLM to WGS84
-------------
latitude = latitude_int × (180 / 2^31)
longitude = longitude_int × (360 / 2^32)
WGS84 to HDLM
-------------
latitude_int = floor(latitude / (180 / 2^31))
longitude_int = floor(longitude / (360 / 2^32))
---
Python Reference Implementation
===============================
import math
def hdlm_coord_to_wgs84(hdlm_coord: int) -> tuple[float, float]:
"""
Convert a HERE HDLM 2D Coordinate to WGS84 latitude/longitude.
Returns: (latitude, longitude)
"""
binary_string = format(hdlm_coord & ((1 << 64) - 1), "064b")
payload = binary_string[1:]
longitude_bits = payload[0::2]
latitude_bits = payload[1::2]
longitude_int = int(longitude_bits, 2)
latitude_raw = int(latitude_bits, 2)
if latitude_raw >= (1 << 30):
latitude_int = latitude_raw - (1 << 31)
else:
latitude_int = latitude_raw
latitude = latitude_int (180 / math.pow(2, 31))
longitude = longitude_int * (360 / math.pow(2, 32))
return latitude, longitude
def wgs84_to_hdlm_coord(latitude: float, longitude: float) -> int:
"""
Convert WGS84 latitude/longitude to an HDLM 2D Coordinate.
"""
latitude_int = math.floor(
latitude / (180 / math.pow(2, 31))
)
longitude_int = math.floor(
longitude / (360 / math.pow(2, 32))
)
latitude_bits = format(
latitude_int + (1 << 31),
"031b"
)
longitude_bits = format(
longitude_int,
"032b"
)
interleaved = "".join(
lon + lat
for lon, lat in zip(
longitude_bits,
latitude_bits
)
)
binary_string = "0" + interleaved + "0"
return int(binary_string, 2)
---
Verification Example
====================
Input HDLM coordinate:
4354955124161939766
Expected output:
Latitude = -33.866630075499415
Longitude = 151.20577996596694
If your implementation produces these values (or values differing only by normal floating-point precision), the decoding process is functioning correctly.
---
Expected Behaviour
------------------
* HDLM coordinates can be decoded into valid WGS84 latitude and longitude values.
* Converted coordinates can be displayed in GIS applications.
* HDLM geometry can be compared against GPS traces and external map data.
* Small rounding differences may occur due to integer quantisation.
---
Unexpected Behaviour
--------------------
Further investigation may be required if:
* Latitude falls outside the range of -90 to +90 degrees.
* Longitude falls outside the range of -180 to +180 degrees.
* Decoded coordinates appear in an unexpected geographic region.
* Bit ordering has been altered during implementation.
* Signed latitude handling is not applied correctly.
* The coordinate is not processed as a full 64-bit value before decoding.
---
Additional Notes
----------------
* HDLM coordinates are specific to HERE HD Live Map datasets.
* HDLM coordinates are not directly compatible with standard GIS coordinate formats.
* Always validate implementations using known reference coordinates.
* Pay close attention to signed latitude handling and bit interleaving logic.
* Validate conversion logic before applying it to large-scale data processing workflows.
---
Searchable Keywords / Tags
--------------------------
HERE HDLM, HD Live Map, HDLM coordinate conversion, HDLM 2D coordinate, WGS84 conversion, latitude longitude decoding, HDLM geometry, RDF geometry, lane model, localisation data, GIS visualisation, coordinate encoding, coordinate decoding, GPS trace validation, map data analysis, HERE HD map data, geospatial conversion, HDLM troubleshooting, coordinate validation, HD Live Map geometry analysis
Updated 3 days ago