pak_geodata library
Comprehensive, typed, offline geographic data for all areas and cities in Pakistan.
Pure Dart with zero runtime dependencies.
Classes
- CityBounds
- Axis-aligned geographical bounding box for a city.
- Coordinates
- Geographic latitude and longitude coordinates in decimal degrees.
- NearestAreaOptions
- Options to configure nearest area spatial query.
- NearestAreaResult
- Result of nearest area spatial calculation.
- PakistanArea
- A neighborhood, sector, suburb, or locality in Pakistan.
- PakistanCity
- A verified city or urban center in Pakistan.
- PakistanProvince
- A province or administrative territory of Pakistan.
- SearchOptions
- Options to configure area text search query.
- SearchResult
- Matched area result from search ranking.
Constants
-
cityColloquialAliases
→ const Map<
String, List< String> > - City-level colloquial abbreviations, nicknames, and Urdu aliases.
- earthRadiusKm → const double
- Mean spherical Earth radius in kilometers (IUGG recommended value).
-
pakistanAreas
→ const List<
PakistanArea> -
pakistanCities
→ const List<
PakistanCity> -
pakistanProvinces
→ const List<
PakistanProvince>
Functions
-
findAreaByPostalCode(
String postalCode) → PakistanArea? - Resolves the primary area associated with a 5-digit Pakistan Post postal code.
-
findAreasByPostalCode(
String postalCode) → List< PakistanArea> - Returns all areas sharing a given 5-digit Pakistan Post postal code.
-
getAllAreas(
) → List< PakistanArea> - Returns all 3,953 verified areas across Pakistan.
-
getAllCities(
) → List< PakistanCity> - Returns all 79 verified cities across Pakistan.
-
getAllProvinces(
) → List< PakistanProvince> - Returns all 7 verified provinces and administrative territories of Pakistan.
-
getAreaById(
String id) → PakistanArea? - Finds an area by its unique identifier (e.g. 'lahore-dha-phase-5').
-
getAreasByCity(
String cityId) → List< PakistanArea> - Returns all verified areas within a given city.
-
getCitiesByProvince(
String provinceId) → List< PakistanCity> - Retrieves all cities belonging to a specified province.
-
getCityById(
String id) → PakistanCity? - Finds a city by its slug identifier (e.g. 'lahore', 'karachi', 'islamabad'). Lookup is case and whitespace insensitive.
-
getNearestArea(
Coordinates target, {String? cityId, String? provinceId, double? maxRadiusKm, NearestAreaOptions? options, List< PakistanArea> ? candidateAreas}) → NearestAreaResult? -
Finds the nearest verified area to
targetcoordinates. -
getProvinceById(
String id) → PakistanProvince? - Finds a province by its unique identifier (e.g. 'punjab', 'sindh', 'islamabad-ict'). Lookup is case and whitespace insensitive.
-
haversineDistanceKm(
Coordinates c1, Coordinates c2) → double - Calculates the great-circle distance between two geographic coordinates using the spherical Earth Haversine formula with radius R = 6371.0088 km.
-
isPointInBoundingBox(
Coordinates coords, CityBounds? bounds) → bool - Checks if a coordinate point falls inside a city's bounding box.
-
normalizeUrduText(
String text) → String - Applies standard Urdu NLP normalization rules:
-
searchAreas(
String query, {String? cityId, String? provinceId, int limit = 20, SearchOptions? options, List< PakistanArea> ? candidateAreas}) → List<SearchResult> - Searches Pakistan areas using structured matching and ranking: Exact match > Prefix match > Urdu match > Alias match > Substring / Token match > Fuzzy match.
-
stripUrduDiacritics(
String text) → String - Removes Arabic/Urdu diacritical marks (Tashkeel), Tatweel, and Superscript Alef.
-
toWesternDigits(
String text) → String - Converts Eastern Arabic-Indic (۰-۹) and Standard Arabic-Indic (٠-٩) numerals to standard Western ASCII digits (0-9).