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.
decode() function is the core entry point for converting a Panama postal code string into structured geographic data. It accepts codes with or without an estafeta prefix, handles hyphens and spaces automatically, normalizes to uppercase, and returns a DecodedPostal dataclass with the latitude and longitude at the center of the matched grid cell — or None when the code cannot be parsed.
Function Signature
Parameters
A Panama postal code string to decode. Hyphens and spaces are stripped automatically before parsing. The string is also converted to uppercase, so lowercase input is accepted.Accepted formats:
"ACC99-PJ42W"— 10-char code with estafeta prefix and hyphen"ACC99PJ42W"— 10-char code with estafeta prefix, no hyphen"M9C9A-G4434"— 10-char code, alternate prefix"M9C9AG4434"— same, no hyphen- Shorter body-only codes (
2,4,6, or8clean characters)
Return Value
Returns aDecodedPostal dataclass on success, or None if the code is invalid.
Normalization Rules
Before decoding,decode() passes the input through an internal _normalize() step that enforces the following rules:
- Hyphens (
-) and spaces are stripped, and the result is converted to uppercase. - Every remaining character must belong to the base-30 alphabet:
23456789ABCDEFGHJKLMNPQRSTVWXZ. Note that the lettersI,O,U, andYare not in the alphabet and will cause the code to be rejected. - The cleaned string must be no longer than 10 characters.
- If exactly 10 characters remain, the first 2 are the estafeta prefix and the remaining 8 form the geographic body.
- For strings shorter than 10 characters, the body length must be even:
2,4,6, or8characters. Odd-length bodies are rejected.
Decoding Levels
The geographic body is decoded in successive 2-character pairs, each subdividing the previous cell:| Pairs used | Level | Body length | Precision |
|---|---|---|---|
| Chars 0–1 only | MACRO | 2 | ~15,800 m |
| Chars 0–3 | MICRO | 4 | ~660 m |
| Chars 0–5 | NANO | 6 | ~26 m |
| Chars 0–7 | PICO | 8 | ~3.3 m |