### Find Administrative Unit by ID in Dart Source: https://github.com/daohoangson/dvhcvn/blob/master/transformers/dart-dvhcvn/README.md Demonstrates how to find a Level 3 administrative unit (Phường Phúc Xá) by its ID, starting from a Level 1 unit (Hà Nội). This method is useful for navigating the administrative hierarchy. ```dart import 'package:dvhcvn/dvhcvn.dart' as dvhcvn; // ... final haNoi = dvhcvn.findLevel1ById('01'); final baDinh = haNoi.findLevel2ById('001'); final phucXa = baDinh.findLevel3ById('00001'); print(phucXa); // Thành phố Hà Nội > Quận Ba Đình > Phường Phúc Xá ``` -------------------------------- ### Download and Transform Data Script Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This bash script demonstrates how to clone the repository, remove existing data, download new data using a provided script, and then run transformation scripts. Use this to manually update or obtain the latest data. ```bash git clone https://github.com/daohoangson/dvhcvn.git cd dvhcvn # xoá dữ liệu có sẵn rm -rf ./data/* # bắt đầu tải ./downloader/download.sh # chạy các đoạn mã chuyển đổi ./transformers/transform-all.sh ``` -------------------------------- ### Bounding Box Data for Provinces (level1s_bbox.json) Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This JSON file contains only the bounding box (bbox) information for provinces. Each key is a province ID, and the value is an array representing the bounding box coordinates [min_lon, min_lat, max_lon, max_lat]. Use this for quick spatial extent lookups. ```json { "01": [ 105.28500419, 20.5642508770001, 106.020154616, 21.3855144820001 ], "..." } ``` -------------------------------- ### Find Administrative Units by ID in JavaScript Source: https://github.com/daohoangson/dvhcvn/blob/master/transformers/js-dvhcvn/README.md Use the `findLevel1ById`, `findLevel2ById`, and `findLevel3ById` functions to retrieve administrative units by their IDs. Ensure the library is imported correctly. ```javascript import { findLevel1ById } from 'dvhcvn' // ... const haNoi = findLevel1ById('01') const baDinh = haNoi?.findLevel2ById('001') const phucXa = baDinh?.findLevel3ById('00001') console.log(phucXa); // Thành phố Hà Nội > Quận Ba Đình > Phường Phúc Xá ``` -------------------------------- ### Parser API - Basic Name Match Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This curl command demonstrates the basic usage of the parser API to find administrative units matching a given input string. It returns only the names of the matching administrative units. Use this for simple name lookups. ```bash curl https://www.dvhcvn.com/demo/parser/api -d input=hanoi ``` -------------------------------- ### Geographic Boundary Data for Provinces and Districts (gis/*.json) Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This JSON file contains geographic boundary information for a specific province, including its districts. It provides 'coordinates' and 'bbox' (bounding box) for each administrative unit, with types like 'MultiPolygon' or 'Polygon'. Use this for mapping and spatial analysis. ```json { "level1_id": "56", "name": "Tỉnh Khánh Hòa", "level2s": [ { "level2_id": "568", "name": "Thành phố Nha Trang", "coordinates": [ [ [[109.317273127, 12.1642742720001], "... (khoảng 30 cặp toạ độ)"], "... (khoảng 10 đa giác)" ] ], "bbox": [109.110859607, 12.141705888, 109.370714452, 12.3798137530001], "type": "MultiPolygon" }, "..." ], "coordinates": ["... (khoảng 50 đa giác)"], "bbox": [108.669676534, 7.89146445900019, 115.836420367, 12.86823071], "type": "MultiPolygon" } ``` -------------------------------- ### Sorted Administrative Unit Data (sorted.json) Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This JSON file contains administrative unit data for three levels, sorted by name. Each unit is represented as an array with elements for ID, name, prefix, un-accented name, and subordinate units. This format is optimized for size. ```json [ [ "89", "An Giang", "Tỉnh", "An Giang", [ [ "886", "An Phú", "Huyện", "An Phu", [ ["30337", "An Phú", "Thị trấn", "An Phu"], ["30373", "Đa Phước", "Xã", "Da Phuoc"], ["30340", "Khánh An", "Xã", "Khanh An"], "..." ] ], "..." ] ], "..." ] ``` -------------------------------- ### Parser API - Detailed Information Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This curl command shows how to retrieve detailed information about administrative units by setting the 'Content-Type' header to 'text/plain' and providing the input string. Use this when you need full details including IDs and types. ```bash curl https://www.dvhcvn.com/demo/parser/api -H 'Content-Type: text/plain' -d hanoi ``` -------------------------------- ### Province-Level Administrative Unit Data (dvhcvn.json) Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This JSON structure represents administrative units at three levels: province, district, and commune. It includes IDs, names, and types for each level, with nested 'level2s' and 'level3s' arrays for hierarchical data. Use this for a comprehensive view of administrative divisions. ```json { "level1_id": "56", "name": "Tỉnh Khánh Hòa", "type": "Tỉnh", "level2s": [ { "level2_id": "568", "name": "Thành phố Nha Trang", "type": "Thành phố", "level3s": [ { "level3_id": "22363", "name": "Phường Lộc Thọ", "type": "Phường" }, "..." ] }, "..." ] } ``` -------------------------------- ### Parser API - Specific Address Query Source: https://github.com/daohoangson/dvhcvn/blob/master/README.md This curl command demonstrates querying the parser API with a specific address string, including street, district, and city. It returns a JSON array of detailed administrative unit objects. Use this for parsing complex address strings. ```bash curl https://www.dvhcvn.com/demo/parser/api -H 'Content-Type: text/plain' -d 'trung tu, dong da, ha noi' ``` -------------------------------- ### Administrative Divisions API Source: https://github.com/daohoangson/dvhcvn/blob/master/transformers/js-dvhcvn/README.md This section details the functions and classes available for interacting with Vietnam's administrative divisions. You can find divisions by ID or name, and access properties and methods of each administrative level. ```APIDOC ## Global Variables ### `level1s` This is an `array` containing all level 1 administrative units (centrally governed cities / provinces). ## Functions ### `findLevel1ById(id: string): Level1 | undefined` Find a level 1 administrative unit by its ID. ### `findLevel1ByName(name: string): Level1 | undefined` Find a level 1 administrative unit by its name. ## Classes ### `Level1`, `Level2`, `Level3` Each class represents a level of administrative division. **Fields for all levels:** - `id: string` - `name: string` - `type: Type` **Additional fields:** - `Level2` and `Level3` have an additional `parent` field. - `Level1` and `Level2` have an additional `children` field and the methods `findLevelXById` and `findLevelXByName`. **Methods available on `Level1` and `Level2` instances:** ### `findLevelXById(id: string): LevelX | undefined` Find a subordinate administrative unit (Level2 for Level1, Level3 for Level2) by its ID. ### `findLevelXByName(name: string): LevelX | undefined` Find a subordinate administrative unit (Level2 for Level1, Level3 for Level2) by its name. ``` -------------------------------- ### Administrative Unit Data Source: https://github.com/daohoangson/dvhcvn/blob/master/transformers/dart-dvhcvn/README.md Provides access to lists of administrative units at different levels and methods to find them. ```APIDOC ## Administrative Unit Data ### Constants #### `level1s` - **Description**: A `List` containing all Level 1 administrative units (central-affiliated cities/provinces). - **Type**: `List` ### Methods #### `findLevel1ById(String id)` - **Description**: Finds a Level 1 administrative unit by its ID. - **Parameters**: - `id` (String) - Required - The ID of the Level 1 administrative unit. - **Returns**: `Level1` or null if not found. #### `findLevel1ByName(String name)` - **Description**: Finds a Level 1 administrative unit by its name. - **Parameters**: - `name` (String) - Required - The name of the Level 1 administrative unit. - **Returns**: `Level1` or null if not found. ### Classes #### `Level1`, `Level2`, `Level3` - **Description**: Classes representing administrative units at Level 1, Level 2, and Level 3 respectively. - **Fields**: - `id` (String) - The unique identifier for the administrative unit. - `name` (String) - The name of the administrative unit. - `type` (Type) - The type of the administrative unit. - **Level 2 and Level 3 Specific Fields**: - `parent` (Level1 or Level2) - The parent administrative unit. - **Level 1 and Level 2 Specific Fields and Methods**: - `children` (List) - A list of child administrative units. - `findLevelXById(String id)` - Finds a child administrative unit by ID. - `findLevelXByName(String name)` - Finds a child administrative unit by name. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.