« Using system SSL Cert… | Home | Required keys for inf… »

Encoded Polyline Algorithm Format

When you work with Google Maps, you may run into their encoding algorithm for coordinates, It is a variation of Base64 specific for encoding floating point numbers in small character chunks.

For MBS FileMaker Plugin, we just add two new functions:

Math.PolylineEncode to encode the number and Math.PolylineDecode to decode it.

e.g. MBS("Math.PolylineEncode"; 38.5) returns _p~iF which than can be decoded with Math.PolylineDecode function.

To build a poly line, you encode the first value, followed with delta numbers.
e.g. given this points: Points: (38.5, -120.2), (40.7, -120.95), (43.252, -126.453)

You chain the calls to our plugin to encode each number:

MBS("Math.PolylineEncode"; 38.5) & MBS("Math.PolylineEncode"; -120.20) &
MBS("Math.PolylineEncode"; 40.7 - 38.5) & MBS("Math.PolylineEncode"; -120.95 - -120.2) &
MBS("Math.PolylineEncode"; 43.252 - 40.7) & MBS("Math.PolylineEncode"; -126.453 - -120.95)

For the given example points, this returns _p~iF~ps|U_ulLnnqC_mqNvxq`@ for all 6 values together. Please note that 2nd and following numbers are deltas.

If you need to know how long an encoded number is, please check ASCII values. The last character is always < 96, e.g. a capital letter.

See Google Development Website
31 03 19 - 12:17