100% SPEC Parity • Zero-Dependency • MEF Open Data

Cambodia Administrative Geo Data

បណ្ណាល័យទិន្នន័យភូមិសាស្ត្ររដ្ឋបាលកម្ពុជា (ខេត្ត ស្រុក ឃុំ ភូមិ) ស្រាល និងគ្មាន runtime dependency។ ដំណើរការដូចគ្នាបេះបិទលើ JavaScript, Python, និង PHP ដោយផ្អែកលើការផ្ទៀងផ្ទាត់តេស្តជាក់លាក់ spec/conformance.json។

Lightweight, zero-dependency library for Cambodia's administrative divisions (provinces, districts, communes, villages). Identical behavior across JavaScript, Python, and PHP guaranteed by spec/conformance.json.

JavaScript / TypeScript

សាកល្បង Dropdown ផ្ទាល់ Interactive Live Demo

ដំណើរការផ្ទាល់លើ browser ដោយទាញចេញពី https://cdn.jsdelivr.net/npm/cambodia-geo/+esm ផ្ទាល់ (គ្មាន Bundler គ្មាន Build Step)។

Running directly in-browser using the native ESM CDN import without build tools.

អាសយដ្ឋានដែលបានរើស៖ Selected Address: មិនទាន់មានការជ្រើសរើសនៅឡើយទេ

លក្ខណៈបច្ចេកទេស និងស្តង់ដាររួម Specification Standards (SPEC.md)

បណ្ណាល័យទាំង ៣ ត្រូវបានបង្កើតឡើងតាមបទបញ្ញត្តិរួម SPEC.md ដោយមានច្បាប់ច្បាស់លាស់ក្នុងការ Parse និង Search ទិន្នន័យ៖

All three libraries strictly adhere to the unified SPEC.md with clear parsing and matching rules:

Unicode NFC Normalisation Unicode NFC Normalisation លុប space, សញ្ញាដាច់ៗ (- ' . ,) និង zero-width chars (U+200B ដល់ U+200D) ធានាការស្វែងរកមិនខុស។ Strips whitespace, punctuation, and zero-width spaces (U+200B..U+200D) for fail-safe matching.
លេខកូដ និង លេខខ្មែរ Codes & Khmer Digits យល់ដឹងស្វ័យប្រវត្តិនូវលេខកូដអក្សរឡាតាំង និងលេខខ្មែរ (ឧទាហរណ៍ "១៧", "017", 17 គឺស្មើគ្នា)។ Handles Arabic & Khmer numerals seamlessly ("១៧", "017", and 17 are equivalent).
Search Ranking 0-2 Search Ranking 0-2 តម្រៀបលទ្ធផលស្វែងរកតាម៖ 0 (ត្រូវចំ), 1 (ផ្តើមដោយពាក្យស្វែងរក), 2 (មានផ្ទុកពាក្យស្វែងរក)។ Results ranked by priority: 0 (Exact match), 1 (Starts with), 2 (Contains query).
Upstream MEF Quirks Upstream MEF Quirks ការពារកំហុសទិន្នន័យដើមក្រសួង MEF (ដូចជាលេខកូដភូមិជាន់គ្នា ឬឃុំ 120913) ដោយមិនគាំង code ឡើយ។ Gracefully handles upstream MEF quirks (duplicate village codes, commune 120913) without errors.

ការដំឡើង & ESM CDN Installation & ESM CDN Usage

1. JavaScript / TypeScript

ប្រើជាមួយ bundlers (Vite, Rollup, Webpack, esbuild, Turbopack, Rspack) និង meta-frameworks (Next.js, Nuxt.js, Nest.js) ឬ ប្រើ ESM CDN លើ browser ផ្ទាល់ដោយមិនបាច់ bundle៖

Install for modern bundlers (Vite, Rollup, Webpack, Turbopack) & frameworks (Next.js, Nuxt.js), or import directly using native ESM CDN without any bundler:

npm package
npm install cambodia-geo
Browser ESM Direct Import (No Bundler Needed)
<script type="module">
  import { provinces, districts } from 'https://cdn.jsdelivr.net/npm/cambodia-geo/+esm';
  console.log(provinces());
</script>

2. Python (PyPI)

តម្រូវការ Python 3.9+ គ្មាន dependency ខាងក្រៅឡើយ ហើយទិន្នន័យផ្ទុកជា frozen dataclasses (type safe)។

Requires Python 3.9+, zero dependencies, typed frozen dataclasses.

pip package
pip install cambodia-geo

3. PHP (Composer)

តម្រូវការ PHP 8.1+ ដំណើរការលឿនបំផុត (~3ms ជាមួយ OPcache) គាំទ្រទាំង Laravel, Symfony និង WordPress។

Requires PHP 8.1+, blazing fast (~3ms with OPcache), compatible with Laravel & Symfony.

composer package
composer require bsthen/cambodia-geo

កូដគំរូសង្ខេប Code Examples

import { provinces, districts, communes, villages, getProvince, search } from 'cambodia-geo';

// 1. ស្វែងរកតាមលំដាប់ថ្នាក់ (Hierarchical listings)
provinces();                                    // គ្រប់ខេត្ត/រាជធានី
districts('Siemreap');                          // ស្រុកក្នុងខេត្តសៀមរាប
communes('17', 'Angkor Thum');                  // ឃុំក្នុងស្រុកអង្គរធំ
villages('សៀមរាប', 1702, 'ជប់តាត្រាវ');           // ភូមិក្នុងឃុំ

// 2. Single Record Lookup & Search
const p = getProvince('សៀមរាប');                 // { code: '17', nameKh: '...', nameEn: '...' }
search('angkor', { level: 'district' });        // ស្វែងរកតាមឈ្មោះ ឬកូដ
import cambodia_geo as kh

# 1. ស្វែងរកតាមលំដាប់ថ្នាក់ (Hierarchical listings)
kh.provinces()                                  # គ្រប់ខេត្ត/រាជធានី
kh.districts("Siemreap")                        # ស្រុកក្នុងខេត្តសៀមរាប
kh.communes("17", "Angkor Thum")                # ឃុំក្នុងស្រុក
kh.villages("សៀមរាប", 1702, "ជប់តាត្រាវ")         # ភូមិក្នុងឃុំ

# 2. Single Record Lookup & Search
p = kh.get_province("សៀមរាប")                    # Dataclass: code, name_kh, name_en
kh.get_district("Angkor Thum", province="Siemreap")
kh.search("angkor")                             # ស្វែងរកទូទាំងប្រទេស
use CambodiaGeo\Geo;

// 1. ស្វែងរកតាមលំដាប់ថ្នាក់ (Hierarchical listings)
Geo::provinces();                               // គ្រប់ខេត្ត/រាជធានី
Geo::districts('Siemreap');                     // ស្រុកក្នុងខេត្តសៀមរាប
Geo::communes('17', 'Angkor Thum');             // ឃុំក្នុងស្រុក
Geo::villages('សៀមរាប', 1702, 'ជប់តាត្រាវ');      // ភូមិក្នុងឃុំ

// 2. Single Record Lookup & Search
$p = Geo::getProvince('សៀមរាប');                 // Province: $p->code, $p->nameKh, $p->nameEn
Geo::getDistrict('Angkor Thum', province: 'Siemreap');
Geo::search('angkor', level: 'district');       // ស្វែងរកតាមឈ្មោះ ឬកូដ