TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/kass507/panama-postal/llms.txt
Use this file to discover all available pages before exploring further.
encode() function takes a latitude and longitude and returns the geographic body of a Panama postal code — the portion that encodes location in the grid hierarchy, without the 2-character estafeta prefix. You can control the precision of the result by passing one of four level values. The default level is "PICO", which produces the highest-resolution 8-character body, formatted with a hyphen to match the style used on the official postal code site.
Function Signature
Parameters
Latitude of the point to encode, in decimal degrees. The grid origin is at latitude
10.0°N, and the encoded body represents an offset southward from that origin. Values outside the encodable grid are accepted without error — the resulting code may decode to a point outside Panama.Longitude of the point to encode, in decimal degrees. The grid origin is at longitude
-83.5°. The encoded body represents an offset eastward from that origin.Precision level for the output. Controls how many character pairs are generated and how the result is formatted. Must be one of:
Raises
| Value | Output characters | Formatted length | Precision |
|---|---|---|---|
"MACRO" | 2 | XX (2 chars) | ~15,800 m |
"MICRO" | 4 | XXXX (4 chars) | ~660 m |
"NANO" | 6 | XXX-XXX (7 chars with hyphen) | ~26 m |
"PICO" | 8 | XXX-XXXXX (9 chars with hyphen) | ~3.3 m |
ValueError if the value is not one of the four strings above. The error message is "Nivel inválido: <value>".Return Value
A formatted string containing the geographic body of the postal code, without the estafeta prefix. The length and format depend on thelevel chosen — see the table above.
For
"NANO" and "PICO" levels, a hyphen is inserted after the 3rd character of the body string. This matches the formatting used on the official Panama postal code site (codigospostalespanama.gob.pa), where a 10-character full code (2-char prefix + 8-char body) is displayed with the hyphen falling at position 5 — which lands at character 3 of the body portion.Grid Origin
All encoding is computed as an offset from a fixed grid origin:- Origin latitude:
10.0°N - Origin longitude:
−83.5°