Skip to content

Non-ideal bearing and DNP, and wrong offset calculations #9

@prayerful007

Description

@prayerful007

Hi, I have realized that you have calculated bearing and DNP non-ideally, and offsets wrongly.

You have treated all the 'bands' as precise numbers by adding 0.5, which is not ideal, as the band was there to allow buffering when mapping the OpenLR code to a map, where the target map may differ from the source map (which the OpenLR codes were encoded from).

Below are calculations by decoding "CwEbJx48NiKaN/J7BMIibQEC"
For example, a DNP is stored by 8 bits, so a total of 256 bands are available for the defined max length 15,000 meters. Hence each band is 15000/256 = 58.59375 meters.
The DNP byte of this OpenLR is "0b00110111" (55th band), is actually a distance between 58.59375 * 55 and 58.59375 * 56, which is >=3222 m and < 3281 m (rounded)
You gave a precise middle number 58.59375 * (55 +0.5 ) = 3252 m.
This 3252 m is the middle between 3222 and 3281, which is not ideal.

Moreover, this approach should not be applied to the calculation of the offsets.
Offsets are not 'bands', they are the actual fraction of the referred road distance, stored in 8 bits.
So you should not add 0.5 to the offset fraction
Furthermore, you used the higher value of the distance band in your calculation, making the result wrong.

The negative offset coefficient is stored as 2 (0b00000010), which is the fraction of the total distance = 2/256 = 0.0078125,
The correct negative offset is a distance between 0.0078125 * 3222 and 0.0078125 * 3281, which is >= 25.17 m and <25.63 m
By using your calculation, you used: (2 +0.5 )/256 * 3281 = 32 m, which is wrong.

The correct positive offset is a distance between 0.00390625 * 3222 and 0.00390625 * 3281, which is >= 12.59 m and <12.81 m
Your result is 19 m, which is wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions