Help with "Encoded Polyline Algorithm Format"

gibbons

En-Route
Joined
Feb 12, 2005
Messages
3,385
Location
Rogers, Arkansas
Display Name

Display name:
iRide
Ok smart guys and gals, I'm working on a program to build routes to display on google maps. I've gotten carried away and now I'm attempting to use their encoded format (much faster).

Here is a snip from the instructions:

Place the 5-bit chunks into reverse order:
00001 11111 10000 01010 00010 00001

OR each value with 0x20 if another bit chunk follows:
100001 111111 110000 101010 100010 000001

I know how to "OR", but I don't understand the instruction to OR each value with 0x20. I also don't understand the "if another bit chunk follows".

The full instructions can be found here.

Three questions:
1) How do I or something with 0x20?
2) Are you aware of a function in Pascal (Delphi) that would do this?
3) Why am I doing this???
 
Crap, Chip, I woulda been your guy for this, like, 20 years ago.

I am guessing a Jesse or a William or a Troy oughta do the trick.
 
Chip,

Do you have a place to download the list of all airports and navaids with lat/long?

How about all the waypoints that define the Victor and J airways?

I'm thinking a future addition to the download the approach plates would be to select all approaches within X nm of a route.

Joe
 
Ok smart guys and gals, I'm working on a program to build routes to display on google maps. I've gotten carried away and now I'm attempting to use their encoded format (much faster).

Here is a snip from the instructions:

Place the 5-bit chunks into reverse order:
00001 11111 10000 01010 00010 00001

Been a long time. Trying to knock some rust off:

Can I assume you have each 5-bit chunk in a seperate variable? You can store them as 8 bytes, just zero-left-padded (i.e.:

chunk1 := 00000001
chunk2 := 00011111
chunk3 := 00010000
chunk4 := 00001010
chunk5 := 00000010
chunk6 := 00000001

)

If so, the code should (I haven't touched Delphi in over 10 years):

chunk1_bw := chunk1 Or 0x20; // I forget if you express Hex as 0x in Delphi

My brain is having a tough time grokking exactly what they mean by "another bit chunk follows" - in the example stream, you can't divide 33 evenly by five - you have 6 r 3 - so you have 3 bits left over after you "chunk" it up. In that case, since you toss the 00000, you Or it with 0x20.

That's my understanding at least.

Cheers,

-Andrew
 
I bet you guys really impress the girls with pillowtalk! :D
 
Ok smart guys and gals, I'm working on a program to build routes to display on google maps. I've gotten carried away and now I'm attempting to use their encoded format (much faster).

Here is a snip from the instructions:

Place the 5-bit chunks into reverse order:
00001 11111 10000 01010 00010 00001

OR each value with 0x20 if another bit chunk follows:
100001 111111 110000 101010 100010 000001

I know how to "OR", but I don't understand the instruction to OR each value with 0x20. I also don't understand the "if another bit chunk follows".

The full instructions can be found here.

Three questions:
1) How do I or something with 0x20?
2) Are you aware of a function in Pascal (Delphi) that would do this?
3) Why am I doing this???


1) It's been at least 20 years since I touched Pascal but I think the "bitwise OR" operator is two vertical bars "||", but since all the "bit-chunks" (weird name) are less than 20 Hex you could just add 20 Hex (32 decimal) to each assuming each one is in a separate variable. OTOH if the data you are working with is actually ascii strings, you would just concatenate another '1' character to the left end of each string that needs to be "OR'd" with 20 Hex.

2) From the example given I believe the instructions are to apply the "OR with 20 Hex" to all the "bit-chunks except the right most one (it doesn't have another "bit-chunk" after it).

3) I have no clue. Maybe if I had the rest of the instructions you are following I could tell more.

Edit: I found the link you posted to the complete instructions (which are very poorly written IMO). What you are doing is converting Latitude/longitude values into printable ascii strings that are more efficient than the more simple approach using asciii hex. The method used takes 1 to 5 characters per value vs 9 for straight ascii hex.
 
Last edited:
mmm...Delphi, now you're talking my language!!

You're gonna have to write the function yourself, but you should be able to do it ok. You're looking for

bwFirstSection := firstGrouping || $20; (I think that's it, but its been a long, long time........after the game tonight I'll play around and see if that'll help.)
 
1) It's been at least 20 years since I touched Pascal but I think the "bitwise OR" operator is two vertical bars "||", but since all the "bit-chunks" (weird name) are less than 20 Hex you could just add 20 Hex (32 decimal) to each assuming each one is in a separate variable. OTOH if the data you are working with is actually ascii strings, you would just concatenate another '1' character to the left end of each string that needs to be "OR'd" with 20 Hex.

I checked. The Bitwise OR is "or". ;)

http://www.functionx.com/objectpascal/Lesson09.htm
 
My VCR clock is accurate at 12:00 noon OR 12:00 midnight. Does that count?:p

Ignore me. It's 3:09 am on the first day(?) of the graveyard shift to which I have been subjected much to my joy, :rolleyes: for the next four weeks.


I am not awake. And if I were, I still wouldn't have a clue about computerese:D .

G'night, y'all!

Jim
 
Thanks everyone. I didn't get to play with this last night but I hope to tonight. I really do appreciate the help.
 
Chip,

Do you have a place to download the list of all airports and navaids with lat/long?

How about all the waypoints that define the Victor and J airways?

I'm thinking a future addition to the download the approach plates would be to select all approaches within X nm of a route.

Joe


Joe,

I don't have a very good source. My source is pretty much what AOPA has. It's not the FAA's database.
 
If you were doing this in Java or C# I could help you.

Pascal? Forget it... sorry...
 
Back
Top