iraqi-data 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.ar.md +275 -0
- package/README.md +274 -2
- package/dist/index.d.mts +79 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +327 -0
- package/dist/index.mjs +292 -0
- package/package.json +64 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Karam Al-Dulaimi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ar.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# iraqi-data
|
|
2
|
+
|
|
3
|
+
[English](README.md) | **العربية**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/iraqi-data)
|
|
6
|
+
[](https://github.com/karam-fikre/iraqi-data/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
محافظات العراق وأقضيتها بالعربية والإنجليزية والكردية، جاهزة لنماذج العناوين والقوائم المنسدلة وتطبيقات التوصيل. البحث يفهم الطرق المختلفة التي يكتب بها الناس اسم المكان نفسه: `البصرة` و `البصره` و `Basrah` و `بەسرە` كلها تجد البصرة.
|
|
10
|
+
|
|
11
|
+
يعمل في **Node.js** و**المتصفح** و **React** و **React Native / Expo** و **Vue**، ويأتي مع أنواع TypeScript، وبلا أي اعتماديات.
|
|
12
|
+
|
|
13
|
+
## التثبيت
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install iraqi-data
|
|
17
|
+
# أو
|
|
18
|
+
yarn add iraqi-data
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
حجم الحزمة كاملةً مع البيانات نحو 11 كيلوبايت بعد الضغط (gzip).
|
|
22
|
+
|
|
23
|
+
## الاستخدام
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { governorates, getGovernorate, searchGovernorates } from 'iraqi-data';
|
|
27
|
+
// CommonJS: const { governorates, getGovernorate } = require('iraqi-data');
|
|
28
|
+
|
|
29
|
+
getGovernorate('Basrah');
|
|
30
|
+
// {
|
|
31
|
+
// id: 'basra',
|
|
32
|
+
// iso: 'IQ-BA',
|
|
33
|
+
// ar: 'البصرة',
|
|
34
|
+
// en: 'Basra',
|
|
35
|
+
// ku: 'بەسرە',
|
|
36
|
+
// region: 'federal',
|
|
37
|
+
// capital: { ar: 'البصرة', en: 'Basra', lat: 30.4952, lng: 47.8091 },
|
|
38
|
+
// aliases: ['Basrah']
|
|
39
|
+
// }
|
|
40
|
+
|
|
41
|
+
getGovernorate('هولير')?.ar; // 'أربيل'
|
|
42
|
+
getGovernorate('IQ-NI')?.capital.ar; // 'الموصل'
|
|
43
|
+
getGovernorate('أربيل')?.capital; // { ar: 'أربيل', en: 'Erbil', lat: 36.1912, lng: 44.0094 }
|
|
44
|
+
|
|
45
|
+
searchGovernorates('نجف').map((g) => g.ar); // ['النجف']
|
|
46
|
+
searchGovernorates('ba').map((g) => g.ar); // ['بغداد', 'البصرة', 'بابل', 'الأنبار', 'كربلاء']
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### الأقضية
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { getDistrict, searchDistricts, getDistrictsByGovernorate } from 'iraqi-data';
|
|
53
|
+
|
|
54
|
+
getDistrict('ابو غريب');
|
|
55
|
+
// {
|
|
56
|
+
// id: 'abughraib',
|
|
57
|
+
// governorateId: 'baghdad',
|
|
58
|
+
// pcode: null,
|
|
59
|
+
// ar: 'أبو غريب',
|
|
60
|
+
// en: 'Abu Ghraib',
|
|
61
|
+
// ku: 'ئەبو غرێب',
|
|
62
|
+
// center: { ar: 'أبو غريب', en: 'Abu Ghraib', lat: 33.3145, lng: 44.1682 },
|
|
63
|
+
// aliases: []
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
getDistrict('الدغارة')?.ar; // 'أكد' (الدغارة مركزه)
|
|
67
|
+
getDistrictsByGovernorate('البصرة').length; // 11
|
|
68
|
+
searchDistricts('كر', { governorate: 'بغداد' }).map((d) => d.ar); // ['الكرخ']
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### قوائم العنوان المنسدلة (React)
|
|
72
|
+
|
|
73
|
+
قائمة للمحافظات، وقائمة ثانية تعرض أقضية المحافظة المختارة:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { useState } from 'react';
|
|
77
|
+
import { governorates, getDistrictsByGovernorate } from 'iraqi-data';
|
|
78
|
+
|
|
79
|
+
export function AddressSelect() {
|
|
80
|
+
const [governorate, setGovernorate] = useState('');
|
|
81
|
+
const [district, setDistrict] = useState('');
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<>
|
|
85
|
+
<select value={governorate} onChange={(e) => { setGovernorate(e.target.value); setDistrict(''); }}>
|
|
86
|
+
<option value="">المحافظة</option>
|
|
87
|
+
{governorates.map((g) => (
|
|
88
|
+
<option key={g.id} value={g.id}>{g.ar}</option>
|
|
89
|
+
))}
|
|
90
|
+
</select>
|
|
91
|
+
|
|
92
|
+
<select value={district} onChange={(e) => setDistrict(e.target.value)} disabled={!governorate}>
|
|
93
|
+
<option value="">القضاء</option>
|
|
94
|
+
{getDistrictsByGovernorate(governorate).map((d) => (
|
|
95
|
+
<option key={d.id} value={d.id}>{d.ar}</option>
|
|
96
|
+
))}
|
|
97
|
+
</select>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
استخدم `g.en` / `d.en` أو `g.ku` / `d.ku` للأسماء بالإنجليزية أو الكردية. احفظ المعرّفات (`'baghdad'` و `'abughraib'` …) في قاعدة بياناتك، وليس الأسماء المعروضة. المعرّف لا يتغير أبداً، أما تهجئة الاسم فقد تُصحَّح في إصدار لاحق.
|
|
104
|
+
|
|
105
|
+
## الواجهة البرمجية (API)
|
|
106
|
+
|
|
107
|
+
### `governorates: readonly Governorate[]`
|
|
108
|
+
|
|
109
|
+
كل المحافظات الـ 19: المحافظات الـ 15 في العراق الاتحادي، ثم المحافظات الـ 4 في إقليم كردستان. المصفوفة وعناصرها مجمّدة ولا يمكن تعديلها.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
interface Governorate {
|
|
113
|
+
id: string; // معرّف ثابت للحفظ: 'baghdad'
|
|
114
|
+
iso: string | null; // رمز ISO 3166-2: 'IQ-BG' (null لحلبجة لأنها بلا رمز بعد)
|
|
115
|
+
ar: string; // الاسم بالعربية
|
|
116
|
+
en: string; // الاسم بالإنجليزية
|
|
117
|
+
ku: string; // الاسم بالكردية (السورانية)
|
|
118
|
+
region: 'federal' | 'kurdistan';
|
|
119
|
+
capital: { ar: string; en: string; lat: number; lng: number }; // مركز المحافظة وإحداثياته
|
|
120
|
+
aliases: string[]; // تهجئات أخرى: 'Basrah' و 'Arbil' و 'Hawler'
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `getGovernorate(query: string): Governorate | undefined`
|
|
125
|
+
|
|
126
|
+
تجد محافظة واحدة بالـ `id` أو رمز ISO أو اسمها الكامل بأي لغة، بما في ذلك التهجئات الأخرى. تُرجع `undefined` إذا لم تجد شيئاً. الأسماء الناقصة لا تُطابَق؛ استخدم `searchGovernorates` لها.
|
|
127
|
+
|
|
128
|
+
### `searchGovernorates(query: string): Governorate[]`
|
|
129
|
+
|
|
130
|
+
تجد كل محافظة يحتوي اسمها على نص البحث، للإكمال التلقائي. المطابقات التامة أولاً، ثم الأسماء التي تبدأ بنص البحث، ثم البقية. البحث الفارغ يُرجع `[]`.
|
|
131
|
+
|
|
132
|
+
### `getGovernoratesByRegion(region: 'federal' | 'kurdistan'): Governorate[]`
|
|
133
|
+
|
|
134
|
+
محافظات العراق الاتحادي أو محافظات إقليم كردستان.
|
|
135
|
+
|
|
136
|
+
### `districts: readonly District[]`
|
|
137
|
+
|
|
138
|
+
كل الأقضية الـ 182، مرتّبة حسب المحافظة بترتيب `governorates` نفسه، ثم حسب الاسم الإنجليزي. المصفوفة وعناصرها مجمّدة ولا يمكن تعديلها.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
interface District {
|
|
142
|
+
id: string; // معرّف ثابت للحفظ: 'abughraib'
|
|
143
|
+
governorateId: string; // معرّف المحافظة: 'baghdad'
|
|
144
|
+
pcode: string | null; // رمز OCHA (P-code): 'IQG08Q01' (null إذا لم تعدّه OCHA قضاءً)
|
|
145
|
+
ar: string; // الاسم بالعربية
|
|
146
|
+
en: string; // الاسم بالإنجليزية
|
|
147
|
+
ku: string; // الاسم بالكردية (السورانية)
|
|
148
|
+
center: { ar: string; en: string; lat: number; lng: number }; // مركز القضاء وإحداثياته
|
|
149
|
+
aliases: string[]; // تهجئات وأسماء أخرى: 'الدغارة' لأكد
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `getDistrict(query: string): District | undefined`
|
|
154
|
+
|
|
155
|
+
تجد قضاءً واحداً بالـ `id` أو رمز P-code أو اسمه الكامل بأي لغة، بما في ذلك التهجئات الأخرى. تعمل مثل `getGovernorate`.
|
|
156
|
+
|
|
157
|
+
### `searchDistricts(query: string, options?: { governorate?: string }): District[]`
|
|
158
|
+
|
|
159
|
+
تجد كل قضاء يحتوي اسمه على نص البحث، بترتيب `searchGovernorates` نفسه. مرّر `governorate` (أي قيمة تقبلها `getGovernorate`) للبحث في أقضية تلك المحافظة فقط.
|
|
160
|
+
|
|
161
|
+
### `getDistrictsByGovernorate(governorate: string): District[]`
|
|
162
|
+
|
|
163
|
+
أقضية محافظة واحدة، تُحدَّد بأي قيمة تقبلها `getGovernorate`: `'basra'` أو `'البصرة'` أو `'IQ-BA'`. تُرجع `[]` لمحافظة غير معروفة.
|
|
164
|
+
|
|
165
|
+
### `normalize(text: string): string`
|
|
166
|
+
|
|
167
|
+
الدالة التي يستخدمها البحث لمقارنة الأسماء. هي مُصدَّرة لتقارن بها قيمك المحفوظة بالطريقة نفسها.
|
|
168
|
+
|
|
169
|
+
| تتجاهل | مثال |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| أشكال الهمزة | `أ إ آ` ← `ا` |
|
|
172
|
+
| التاء المربوطة والألف المقصورة | `ة` ← `ه`، `ى` ← `ي` |
|
|
173
|
+
| التشكيل والتطويل | `البَصْرَة` ← `بصره` |
|
|
174
|
+
| أداة التعريف | `البصرة` و `Al-Basrah` و `As Sulaymaniyah` |
|
|
175
|
+
| الحروف الكردية المكتوبة بلوحة مفاتيح عربية | `سلێمانی` = `سليماني`، `دهۆک` = `دهوك` |
|
|
176
|
+
| شكلا الهاء المستخدمان في الكردية | `ھەولێر` = `هەولێر` |
|
|
177
|
+
| حالة الأحرف والمسافات والشرطات | `Dhi Qar` = `dhiqar` |
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
normalize('Al-Qadisiyyah'); // 'qadisiyyah'
|
|
181
|
+
normalize('البَصْرَة'); // 'بصره'
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## البيانات
|
|
185
|
+
|
|
186
|
+
### المحافظات
|
|
187
|
+
|
|
188
|
+
| العربية | الإنجليزية | الكردية | المركز | الإحداثيات | ISO | الإقليم |
|
|
189
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
190
|
+
| بغداد | Baghdad | بەغدا | بغداد | 33.3062, 44.3872 | IQ-BG | اتحادي |
|
|
191
|
+
| البصرة | Basra | بەسرە | البصرة | 30.4952, 47.8091 | IQ-BA | اتحادي |
|
|
192
|
+
| نينوى | Nineveh | نەینەوا | الموصل | 36.3416, 43.1291 | IQ-NI | اتحادي |
|
|
193
|
+
| الأنبار | Anbar | ئەنبار | الرمادي | 33.4260, 43.2999 | IQ-AN | اتحادي |
|
|
194
|
+
| صلاح الدين | Salah al-Din | سەلاحەدین | تكريت | 34.6158, 43.6786 | IQ-SD | اتحادي |
|
|
195
|
+
| كركوك | Kirkuk | کەرکووک | كركوك | 35.4719, 44.3954 | IQ-KI | اتحادي |
|
|
196
|
+
| ديالى | Diyala | دیالە | بعقوبة | 33.7447, 44.6328 | IQ-DI | اتحادي |
|
|
197
|
+
| واسط | Wasit | واسیت | الكوت | 32.5147, 45.8189 | IQ-WA | اتحادي |
|
|
198
|
+
| بابل | Babil | بابل | الحلة | 32.4822, 44.4328 | IQ-BB | اتحادي |
|
|
199
|
+
| كربلاء | Karbala | کەربەلا | كربلاء | 32.5984, 44.0158 | IQ-KA | اتحادي |
|
|
200
|
+
| النجف | Najaf | نەجەف | النجف | 32.0010, 44.3300 | IQ-NA | اتحادي |
|
|
201
|
+
| القادسية | Al-Qadisiyyah | قادسیە | الديوانية | 31.9892, 44.9247 | IQ-QA | اتحادي |
|
|
202
|
+
| المثنى | Muthanna | موسەننا | السماوة | 31.3079, 45.2827 | IQ-MU | اتحادي |
|
|
203
|
+
| ذي قار | Dhi Qar | زیقار | الناصرية | 31.0440, 46.2399 | IQ-DQ | اتحادي |
|
|
204
|
+
| ميسان | Maysan | مەیسان | العمارة | 31.8498, 47.1496 | IQ-MA | اتحادي |
|
|
205
|
+
| أربيل | Erbil | هەولێر | أربيل | 36.1912, 44.0094 | IQ-AR | كردستان |
|
|
206
|
+
| السليمانية | Sulaymaniyah | سلێمانی | السليمانية | 35.5571, 45.4426 | IQ-SU | كردستان |
|
|
207
|
+
| دهوك | Duhok | دهۆک | دهوك | 36.8543, 42.9925 | IQ-DA | كردستان |
|
|
208
|
+
| حلبجة | Halabja | هەڵەبجە | حلبجة | 35.1792, 45.9874 | — | كردستان |
|
|
209
|
+
|
|
210
|
+
أقرّ مجلس النواب العراقي حلبجة محافظةً تاسعة عشرة للعراق عام 2025. ليس لها رمز ISO 3166-2 بعد، لذلك قيمة `iso` لها `null`.
|
|
211
|
+
|
|
212
|
+
الإحداثيات هي وسط مدينة مركز كل محافظة، مأخوذة من [OpenStreetMap](https://www.openstreetmap.org) (والكوت والديوانية من [Wikidata](https://www.wikidata.org))، ومقرّبة إلى 4 منازل عشرية (نحو 11 متراً). تختلف المصادر في تحديد وسط المدينة بما يصل إلى 3 كم تقريباً، لذا استخدمها لدبابيس الخرائط وحساب المسافات، وليس كعناوين دقيقة.
|
|
213
|
+
|
|
214
|
+
### الأقضية
|
|
215
|
+
|
|
216
|
+
| المحافظة | الأقضية |
|
|
217
|
+
| --- | --- |
|
|
218
|
+
| بغداد | أبو غريب، الأعظمية، ذات السلاسل، الكاظمية، الكرخ، المدائن، المحمودية، الراشدية، الرصافة، الصدر الأولى، الصدر الثانية، التاجي، الطارمية، الزوراء، الزهور |
|
|
219
|
+
| البصرة | أبو الخصيب، البصرة، الدير، الفاو، الهارثة، المدينة، القرنة، الصادق، سفوان، شط العرب، الزبير |
|
|
220
|
+
| نينوى | البعاج، الحمدانية، الحضر، مخمور، الموصل، الشيخان، سنجار، تلعفر، تلكيف |
|
|
221
|
+
| الأنبار | القائم، العامرية، عانة، الفلوجة، الحبانية، حديثة، هيت، الكرمة، العبور، الرمادي، راوة، الرطبة |
|
|
222
|
+
| صلاح الدين | العلم، آمرلي، بيجي، بلد، الضلوعية، الدور، الدجيل، سامراء، الشرقاط، تكريت، طوز خورماتو |
|
|
223
|
+
| كركوك | داقوق، الدبس، الحويجة، كركوك |
|
|
224
|
+
| ديالى | بلدروز، بعقوبة، الخالص، خانقين، كفري، مندلي، المنصورية، المقدادية |
|
|
225
|
+
| واسط | الأحرار، العزيزية، بدرة، الحي، الكوت، الموفقية، النعمانية، الصويرة، الزبيدية |
|
|
226
|
+
| بابل | الهاشمية، الحلة، الكفل، كوثى، المحاويل، المسيب، القاسم |
|
|
227
|
+
| كربلاء | عين التمر، الهندية، الحر، الحسينية، الجدول الغربي، كربلاء |
|
|
228
|
+
| النجف | الكوفة، المناذرة، المشخاب، النجف |
|
|
229
|
+
| القادسية | عفك، أكد، البدير، الديوانية، غماس، الحمزة، المهناوية، السنية، الشافعية، الشامية، الشنافية، السدير، سومر |
|
|
230
|
+
| المثنى | الهلال، الخضر، المجد، النجمي، الرميثة، السلمان، السماوة، السوير، الوركاء |
|
|
231
|
+
| ذي قار | البطحاء، الجبايش، الدواية، الفجر، الفهود، الغراف، الإصلاح، كرمة بني سعيد، الناصرية، النصر، قلعة سكر، الرفاعي، سيد دخيل، الشطرة، سوق الشيوخ |
|
|
232
|
+
| ميسان | علي الغربي، العمارة، الكحلاء، كميت، الميمونة، المجر الكبير، قلعة صالح |
|
|
233
|
+
| أربيل | عنكاوة، جومان، دشت أربيل، أربيل، حرير، خبات، خليفان، كويسنجق، ميركسور، بيرمام، قوشتبة، راوندوز، شقلاوة، سيدكان، سوران |
|
|
234
|
+
| السليمانية | بازيان، جمجمال، دربندخان، دوكان، حاجياوة، كلار، ماوت، بنجوين، بشدر، قرة داغ، رانية، سيد صادق، شهرزور، شاربازير، السليمانية |
|
|
235
|
+
| دهوك | عقرة، العمادية، بردرش، باتيفا، دهوك، سميل، زاخو |
|
|
236
|
+
| حلبجة | بمو، بيارة، حلبجة، خورمال، سيروان |
|
|
237
|
+
|
|
238
|
+
الأسماء الكردية ورموز P-code والإحداثيات لكل قضاء موجودة في [`src/districts.json`](src/districts.json).
|
|
239
|
+
|
|
240
|
+
القائمة هي التي اعتمدها التعداد العام للسكان لعام 2024:
|
|
241
|
+
|
|
242
|
+
- العراق الاتحادي يتبع [المجموعة الإحصائية السنوية 2024](https://cosit.gov.iq/documents/AAS2024/01.pdf) للجهاز المركزي للإحصاء، التي تذكر كل قضاء ونواحيه. أقضية كثيرة استُحدثت بعد 2019، مثل الصدر الأولى والثانية في بغداد، ومعظم أقضية ذي قار والقادسية.
|
|
243
|
+
- إقليم كردستان يتبع أقضية تعداد 2024، وهي تطابق تقسيمات حكومة الإقليم (سوران وبيرمام وسيدكان وحاجياوة…). حلبجة محافظة مستقلة بخمسة أقضية، وليست جزءاً من السليمانية.
|
|
244
|
+
- كفري وخانقين والشيخان يعدّها التعداد في محافظة اتحادية وأخرى في الإقليم معاً. هنا تُذكر مرة واحدة، في ديالى ونينوى. أما عقرة وبردرش ففي دهوك، كما يذكرها الجهاز المركزي للإحصاء.
|
|
245
|
+
|
|
246
|
+
`pcode` هو رمز القضاء في [الحدود الإدارية لـ OCHA](https://data.humdata.org/dataset/cod-ab-irq)، وهي من عام 2019. الأقضية المستحدثة بعدها، أو التي تعدّها OCHA نواحيَ (أبو غريب والتاجي)، قيمة `pcode` لها `null`.
|
|
247
|
+
|
|
248
|
+
`center` هو مركز القضاء، أي البلدة التي يُدار منها. غالباً تحمل اسم القضاء نفسه، لكن ليس دائماً: مركز المدائن سلمان باك، ومركز بشدر قلعة دزة. بعض الأقضية ليس لها بلدة مستقلة، مثل أحدث أقضية بغداد (الصدر الأولى والثانية والزوراء والزهور) وبمو في حلبجة، لذا نقطتها وسط المنطقة. الإحداثيات من OpenStreetMap، ومقرّبة إلى 4 منازل عشرية.
|
|
249
|
+
|
|
250
|
+
## المصادر
|
|
251
|
+
|
|
252
|
+
- قائمة الأقضية: [المجموعة الإحصائية السنوية 2024](https://cosit.gov.iq/documents/AAS2024/01.pdf) ونتائج تعداد 2024 كما نشرها موقع [City Population](https://www.citypopulation.de/en/iraq/admin/)
|
|
253
|
+
- رموز P-code للأقضية: [OCHA / الجهاز المركزي للإحصاء](https://data.humdata.org/dataset/cod-ab-irq)، بترخيص [CC BY-IGO](https://creativecommons.org/licenses/by/3.0/igo/)
|
|
254
|
+
- الإحداثيات: © المساهمون في [OpenStreetMap](https://www.openstreetmap.org/copyright)، و [Wikidata](https://www.wikidata.org)
|
|
255
|
+
|
|
256
|
+
## الخطط القادمة
|
|
257
|
+
|
|
258
|
+
- النواحي
|
|
259
|
+
|
|
260
|
+
## المساهمة
|
|
261
|
+
|
|
262
|
+
التصحيحات مرحّب بها جداً، خصوصاً التهجئات الكردية، والتهجئات الشائعة الأخرى التي يجب إضافتها إلى `aliases`. افتح issue أو pull request يعدّل الملف [`src/governorates.json`](src/governorates.json) أو [`src/districts.json`](src/districts.json).
|
|
263
|
+
|
|
264
|
+
### التطوير
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npm install
|
|
268
|
+
npm test # تشغيل الاختبارات
|
|
269
|
+
npm run typecheck # فحص الأنواع
|
|
270
|
+
npm run build # بناء dist/ (CommonJS و ES modules)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## الترخيص
|
|
274
|
+
|
|
275
|
+
[MIT](LICENSE) © Karam Al-Dulaimi
|
package/README.md
CHANGED
|
@@ -1,3 +1,275 @@
|
|
|
1
|
-
#
|
|
1
|
+
# iraqi-data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** | [العربية](README.ar.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/iraqi-data)
|
|
6
|
+
[](https://github.com/karam-fikre/iraqi-data/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
The governorates of Iraq and their districts in Arabic, English and Kurdish, ready for address forms, dropdowns and delivery apps. Lookup and search understand the different ways people spell the same place: `البصرة`, `البصره`, `Basrah` and `بەسرە` all find Basra.
|
|
10
|
+
|
|
11
|
+
Works in **Node.js**, the **browser**, **React**, **React Native / Expo** and **Vue**, with TypeScript types included. No dependencies.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install iraqi-data
|
|
17
|
+
# or
|
|
18
|
+
yarn add iraqi-data
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The whole package, data included, is about 11 KB gzipped.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { governorates, getGovernorate, searchGovernorates } from 'iraqi-data';
|
|
27
|
+
// CommonJS: const { governorates, getGovernorate } = require('iraqi-data');
|
|
28
|
+
|
|
29
|
+
getGovernorate('Basrah');
|
|
30
|
+
// {
|
|
31
|
+
// id: 'basra',
|
|
32
|
+
// iso: 'IQ-BA',
|
|
33
|
+
// ar: 'البصرة',
|
|
34
|
+
// en: 'Basra',
|
|
35
|
+
// ku: 'بەسرە',
|
|
36
|
+
// region: 'federal',
|
|
37
|
+
// capital: { ar: 'البصرة', en: 'Basra', lat: 30.4952, lng: 47.8091 },
|
|
38
|
+
// aliases: ['Basrah']
|
|
39
|
+
// }
|
|
40
|
+
|
|
41
|
+
getGovernorate('هولير')?.en; // 'Erbil'
|
|
42
|
+
getGovernorate('IQ-NI')?.capital.en; // 'Mosul'
|
|
43
|
+
getGovernorate('Erbil')?.capital; // { ar: 'أربيل', en: 'Erbil', lat: 36.1912, lng: 44.0094 }
|
|
44
|
+
|
|
45
|
+
searchGovernorates('نجف').map((g) => g.en); // ['Najaf']
|
|
46
|
+
searchGovernorates('ba').map((g) => g.en); // ['Baghdad', 'Basra', 'Babil', 'Anbar', 'Karbala']
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Districts
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { getDistrict, searchDistricts, getDistrictsByGovernorate } from 'iraqi-data';
|
|
53
|
+
|
|
54
|
+
getDistrict('ابو غريب');
|
|
55
|
+
// {
|
|
56
|
+
// id: 'abughraib',
|
|
57
|
+
// governorateId: 'baghdad',
|
|
58
|
+
// pcode: null,
|
|
59
|
+
// ar: 'أبو غريب',
|
|
60
|
+
// en: 'Abu Ghraib',
|
|
61
|
+
// ku: 'ئەبو غرێب',
|
|
62
|
+
// center: { ar: 'أبو غريب', en: 'Abu Ghraib', lat: 33.3145, lng: 44.1682 },
|
|
63
|
+
// aliases: []
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
getDistrict('الدغارة')?.en; // 'Akkad' (Daghara is its seat)
|
|
67
|
+
getDistrictsByGovernorate('البصرة').length; // 11
|
|
68
|
+
searchDistricts('كر', { governorate: 'baghdad' }).map((d) => d.en); // ['Karkh']
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Address dropdowns (React)
|
|
72
|
+
|
|
73
|
+
A governorate dropdown, and a district dropdown that lists the chosen governorate's districts:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { useState } from 'react';
|
|
77
|
+
import { governorates, getDistrictsByGovernorate } from 'iraqi-data';
|
|
78
|
+
|
|
79
|
+
export function AddressSelect() {
|
|
80
|
+
const [governorate, setGovernorate] = useState('');
|
|
81
|
+
const [district, setDistrict] = useState('');
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<>
|
|
85
|
+
<select value={governorate} onChange={(e) => { setGovernorate(e.target.value); setDistrict(''); }}>
|
|
86
|
+
<option value="">Governorate</option>
|
|
87
|
+
{governorates.map((g) => (
|
|
88
|
+
<option key={g.id} value={g.id}>{g.en}</option>
|
|
89
|
+
))}
|
|
90
|
+
</select>
|
|
91
|
+
|
|
92
|
+
<select value={district} onChange={(e) => setDistrict(e.target.value)} disabled={!governorate}>
|
|
93
|
+
<option value="">District</option>
|
|
94
|
+
{getDistrictsByGovernorate(governorate).map((d) => (
|
|
95
|
+
<option key={d.id} value={d.id}>{d.en}</option>
|
|
96
|
+
))}
|
|
97
|
+
</select>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Use `g.ar` / `d.ar` or `g.ku` / `d.ku` for an Arabic or Kurdish form. Store the ids (`'baghdad'`, `'abughraib'`, …) in your database, not the display names. Ids never change, while a name's spelling may be corrected in a later version.
|
|
104
|
+
|
|
105
|
+
## API
|
|
106
|
+
|
|
107
|
+
### `governorates: readonly Governorate[]`
|
|
108
|
+
|
|
109
|
+
All 19 governorates: the 15 of federal Iraq, then the 4 of the Kurdistan Region. The array and its objects are frozen.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
interface Governorate {
|
|
113
|
+
id: string; // stable id to store: 'baghdad'
|
|
114
|
+
iso: string | null; // ISO 3166-2 code: 'IQ-BG' (null for Halabja, which has none yet)
|
|
115
|
+
ar: string; // Arabic name
|
|
116
|
+
en: string; // English name
|
|
117
|
+
ku: string; // Kurdish (Sorani) name
|
|
118
|
+
region: 'federal' | 'kurdistan';
|
|
119
|
+
capital: { ar: string; en: string; lat: number; lng: number }; // capital city and its center
|
|
120
|
+
aliases: string[]; // other spellings: 'Basrah', 'Arbil', 'Hawler'
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `getGovernorate(query: string): Governorate | undefined`
|
|
125
|
+
|
|
126
|
+
Finds one governorate by its id, ISO code, or full name in any language, including the aliases. Returns `undefined` if nothing matches. Partial names don't match; use `searchGovernorates` for those.
|
|
127
|
+
|
|
128
|
+
### `searchGovernorates(query: string): Governorate[]`
|
|
129
|
+
|
|
130
|
+
Finds every governorate whose name contains the query, for autocomplete. Exact matches come first, then names that start with the query, then the rest. An empty query returns `[]`.
|
|
131
|
+
|
|
132
|
+
### `getGovernoratesByRegion(region: 'federal' | 'kurdistan'): Governorate[]`
|
|
133
|
+
|
|
134
|
+
The governorates of federal Iraq or of the Kurdistan Region.
|
|
135
|
+
|
|
136
|
+
### `districts: readonly District[]`
|
|
137
|
+
|
|
138
|
+
All 182 districts (أقضية), grouped by governorate in the same order as `governorates`, then sorted by English name. The array and its objects are frozen.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
interface District {
|
|
142
|
+
id: string; // stable id to store: 'abughraib'
|
|
143
|
+
governorateId: string; // the governorate's id: 'baghdad'
|
|
144
|
+
pcode: string | null; // OCHA P-code: 'IQG08Q01' (null if OCHA doesn't list it as a district)
|
|
145
|
+
ar: string; // Arabic name
|
|
146
|
+
en: string; // English name
|
|
147
|
+
ku: string; // Kurdish (Sorani) name
|
|
148
|
+
center: { ar: string; en: string; lat: number; lng: number }; // the town the district is run from
|
|
149
|
+
aliases: string[]; // other spellings and names: 'Daghara' for Akkad
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `getDistrict(query: string): District | undefined`
|
|
154
|
+
|
|
155
|
+
Finds one district by its id, P-code, or full name in any language, including the aliases. Works like `getGovernorate`.
|
|
156
|
+
|
|
157
|
+
### `searchDistricts(query: string, options?: { governorate?: string }): District[]`
|
|
158
|
+
|
|
159
|
+
Finds every district whose name contains the query, ranked like `searchGovernorates`. Pass `governorate` (anything `getGovernorate` accepts) to search only that governorate's districts.
|
|
160
|
+
|
|
161
|
+
### `getDistrictsByGovernorate(governorate: string): District[]`
|
|
162
|
+
|
|
163
|
+
The districts of one governorate, found by anything `getGovernorate` accepts: `'basra'`, `'البصرة'`, `'IQ-BA'`. Returns `[]` for an unknown governorate.
|
|
164
|
+
|
|
165
|
+
### `normalize(text: string): string`
|
|
166
|
+
|
|
167
|
+
The function lookup and search use to compare names. It's exported so you can compare your own stored values the same way.
|
|
168
|
+
|
|
169
|
+
| Ignores | Example |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| Hamza forms | `أ إ آ` → `ا` |
|
|
172
|
+
| Taa marbuta and alef maqsura | `ة` → `ه`, `ى` → `ي` |
|
|
173
|
+
| Tashkeel and tatweel | `البَصْرَة` → `بصره` |
|
|
174
|
+
| The article | `البصرة`, `Al-Basrah`, `As Sulaymaniyah` |
|
|
175
|
+
| Kurdish letters typed on an Arabic keyboard | `سلێمانی` = `سليماني`, `دهۆک` = `دهوك` |
|
|
176
|
+
| The two forms of heh used in Kurdish | `ھەولێر` = `هەولێر` |
|
|
177
|
+
| Case, spaces, hyphens | `Dhi Qar` = `dhiqar` |
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
normalize('Al-Qadisiyyah'); // 'qadisiyyah'
|
|
181
|
+
normalize('البَصْرَة'); // 'بصره'
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Data
|
|
185
|
+
|
|
186
|
+
### Governorates
|
|
187
|
+
|
|
188
|
+
| Arabic | English | Kurdish | Capital | Coordinates | ISO | Region |
|
|
189
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
190
|
+
| بغداد | Baghdad | بەغدا | Baghdad | 33.3062, 44.3872 | IQ-BG | federal |
|
|
191
|
+
| البصرة | Basra | بەسرە | Basra | 30.4952, 47.8091 | IQ-BA | federal |
|
|
192
|
+
| نينوى | Nineveh | نەینەوا | Mosul | 36.3416, 43.1291 | IQ-NI | federal |
|
|
193
|
+
| الأنبار | Anbar | ئەنبار | Ramadi | 33.4260, 43.2999 | IQ-AN | federal |
|
|
194
|
+
| صلاح الدين | Salah al-Din | سەلاحەدین | Tikrit | 34.6158, 43.6786 | IQ-SD | federal |
|
|
195
|
+
| كركوك | Kirkuk | کەرکووک | Kirkuk | 35.4719, 44.3954 | IQ-KI | federal |
|
|
196
|
+
| ديالى | Diyala | دیالە | Baqubah | 33.7447, 44.6328 | IQ-DI | federal |
|
|
197
|
+
| واسط | Wasit | واسیت | Kut | 32.5147, 45.8189 | IQ-WA | federal |
|
|
198
|
+
| بابل | Babil | بابل | Hillah | 32.4822, 44.4328 | IQ-BB | federal |
|
|
199
|
+
| كربلاء | Karbala | کەربەلا | Karbala | 32.5984, 44.0158 | IQ-KA | federal |
|
|
200
|
+
| النجف | Najaf | نەجەف | Najaf | 32.0010, 44.3300 | IQ-NA | federal |
|
|
201
|
+
| القادسية | Al-Qadisiyyah | قادسیە | Diwaniyah | 31.9892, 44.9247 | IQ-QA | federal |
|
|
202
|
+
| المثنى | Muthanna | موسەننا | Samawah | 31.3079, 45.2827 | IQ-MU | federal |
|
|
203
|
+
| ذي قار | Dhi Qar | زیقار | Nasiriyah | 31.0440, 46.2399 | IQ-DQ | federal |
|
|
204
|
+
| ميسان | Maysan | مەیسان | Amarah | 31.8498, 47.1496 | IQ-MA | federal |
|
|
205
|
+
| أربيل | Erbil | هەولێر | Erbil | 36.1912, 44.0094 | IQ-AR | kurdistan |
|
|
206
|
+
| السليمانية | Sulaymaniyah | سلێمانی | Sulaymaniyah | 35.5571, 45.4426 | IQ-SU | kurdistan |
|
|
207
|
+
| دهوك | Duhok | دهۆک | Duhok | 36.8543, 42.9925 | IQ-DA | kurdistan |
|
|
208
|
+
| حلبجة | Halabja | هەڵەبجە | Halabja | 35.1792, 45.9874 | — | kurdistan |
|
|
209
|
+
|
|
210
|
+
Halabja was approved as Iraq's 19th governorate by the Iraqi parliament in 2025. It doesn't have an ISO 3166-2 code yet, so its `iso` is `null`.
|
|
211
|
+
|
|
212
|
+
Coordinates are the center of each capital city, from [OpenStreetMap](https://www.openstreetmap.org) (Kut and Diwaniyah from [Wikidata](https://www.wikidata.org)), rounded to 4 decimal places (about 11 m). Sources place a city's center differently by up to about 3 km, so use them for map pins and distances, not as exact addresses.
|
|
213
|
+
|
|
214
|
+
### Districts
|
|
215
|
+
|
|
216
|
+
| Governorate | Districts |
|
|
217
|
+
| --- | --- |
|
|
218
|
+
| Baghdad | Abu Ghraib, Adhamiya, Dhat al-Salasil, Kadhimiya, Karkh, Mada'in, Mahmudiya, Rashidiya, Rusafa, Sadr City 1, Sadr City 2, Taji, Tarmiya, Zawraa, Zuhur |
|
|
219
|
+
| Basra | Abu al-Khasib, Basra, Dair, Faw, Hartha, Madina, Qurna, Sadiq, Safwan, Shatt al-Arab, Zubair |
|
|
220
|
+
| Nineveh | Ba'aj, Hamdaniya, Hatra, Makhmur, Mosul, Shekhan, Sinjar, Tal Afar, Tel Kaif |
|
|
221
|
+
| Anbar | Al-Qa'im, Amiriyah, Anah, Fallujah, Habbaniyah, Haditha, Hit, Karma, Obour, Ramadi, Rawa, Rutba |
|
|
222
|
+
| Salah al-Din | Al-Alam, Amerli, Baiji, Balad, Dhuluiya, Dour, Dujail, Samarra, Shirqat, Tikrit, Tuz Khurmatu |
|
|
223
|
+
| Kirkuk | Daquq, Dibis, Hawija, Kirkuk |
|
|
224
|
+
| Diyala | Balad Ruz, Baqubah, Khalis, Khanaqin, Kifri, Mandali, Mansuriya, Muqdadiya |
|
|
225
|
+
| Wasit | Ahrar, Aziziyah, Badra, Hai, Kut, Muwaffaqiya, Numaniyah, Suwaira, Zubaidiya |
|
|
226
|
+
| Babil | Hashimiya, Hillah, Kifl, Kutha, Mahawil, Musayyib, Qasim |
|
|
227
|
+
| Karbala | Ain al-Tamr, Hindiya, Hur, Husseiniya, Jadwal al-Gharbi, Karbala |
|
|
228
|
+
| Najaf | Kufa, Manathera, Mishkhab, Najaf |
|
|
229
|
+
| Al-Qadisiyyah | Afak, Akkad, Budair, Diwaniyah, Ghammas, Hamza, Mhanawiya, Saniya, Shafi'iya, Shamiya, Shinafiya, Sudair, Sumer |
|
|
230
|
+
| Muthanna | Hilal, Khidhir, Majd, Najmi, Rumaitha, Salman, Samawah, Suwair, Warka |
|
|
231
|
+
| Dhi Qar | Batha, Chibayish, Dawaya, Fajr, Fuhud, Gharraf, Islah, Karmat Bani Sa'id, Nasiriyah, Nasr, Qal'at Sukkar, Rifai, Sayyid Dakhil, Shatra, Suq al-Shuyukh |
|
|
232
|
+
| Maysan | Ali al-Gharbi, Amarah, Kahla, Kumait, Maimouna, Majar al-Kabir, Qal'at Salih |
|
|
233
|
+
| Erbil | Ainkawa, Choman, Dashti Hawler, Erbil, Harir, Khabat, Khalifan, Koya, Mergasor, Pirmam, Qushtapa, Rawanduz, Shaqlawa, Sidakan, Soran |
|
|
234
|
+
| Sulaymaniyah | Bazyan, Chamchamal, Darbandikhan, Dukan, Haji Awa, Kalar, Mawat, Penjwen, Pshdar, Qaradagh, Ranya, Said Sadiq, Sharazoor, Sharbazher, Sulaymaniyah |
|
|
235
|
+
| Duhok | Akre, Amedi, Bardarash, Batifa, Duhok, Simele, Zakho |
|
|
236
|
+
| Halabja | Bamo, Byara, Halabja, Khurmal, Sirwan |
|
|
237
|
+
|
|
238
|
+
Arabic and Kurdish names, P-codes and coordinates for each are in [`src/districts.json`](src/districts.json).
|
|
239
|
+
|
|
240
|
+
The list is the one Iraq's 2024 census used:
|
|
241
|
+
|
|
242
|
+
- Federal Iraq follows the [2024 Annual Statistical Abstract](https://cosit.gov.iq/documents/AAS2024/01.pdf) of the Central Statistical Organization (COSIT), which lists every district with its sub-districts. Many districts are new since 2019, such as Sadr City 1 and 2 in Baghdad, and most of Dhi Qar's and Al-Qadisiyyah's.
|
|
243
|
+
- The Kurdistan Region follows the districts of the 2024 census, which match the Kurdistan Regional Government's own divisions (Soran, Pirmam, Sidakan, Haji Awa…). Halabja is its own governorate with five districts, not part of Sulaymaniyah.
|
|
244
|
+
- Kifri, Khanaqin and Shekhan are counted in both a federal and a Kurdistan governorate by the census. They're listed once here, in Diyala and Nineveh. Akre and Bardarash are in Duhok, as COSIT lists them.
|
|
245
|
+
|
|
246
|
+
`pcode` is the district's P-code in the [OCHA administrative boundaries](https://data.humdata.org/dataset/cod-ab-irq), which are from 2019. Districts created since then, or that OCHA counts as sub-districts (Abu Ghraib, Taji), have `pcode: null`.
|
|
247
|
+
|
|
248
|
+
Each `center` is the town the district is run from. It's often a town of the same name, but not always: Mada'in is run from Salman Pak, and Pshdar from Qaladiza. A few districts have no separate town, such as Baghdad's newest (Sadr City 1 and 2, Zawraa, Zuhur) and Bamo in Halabja, so their point is the middle of the area. Coordinates are from OpenStreetMap, rounded to 4 decimal places.
|
|
249
|
+
|
|
250
|
+
## Sources
|
|
251
|
+
|
|
252
|
+
- District list: [COSIT Annual Statistical Abstract 2024](https://cosit.gov.iq/documents/AAS2024/01.pdf) and the 2024 census results, as published by [City Population](https://www.citypopulation.de/en/iraq/admin/)
|
|
253
|
+
- District P-codes: [OCHA / Iraq Central Statistics Office](https://data.humdata.org/dataset/cod-ab-irq), [CC BY-IGO](https://creativecommons.org/licenses/by/3.0/igo/)
|
|
254
|
+
- Coordinates: © [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors, and [Wikidata](https://www.wikidata.org)
|
|
255
|
+
|
|
256
|
+
## Roadmap
|
|
257
|
+
|
|
258
|
+
- Sub-districts (نواحي)
|
|
259
|
+
|
|
260
|
+
## Contributing
|
|
261
|
+
|
|
262
|
+
Corrections are very welcome, especially Kurdish spellings and other common spellings that should be added as aliases. Open an issue or a pull request that edits [`src/governorates.json`](src/governorates.json) or [`src/districts.json`](src/districts.json).
|
|
263
|
+
|
|
264
|
+
### Development
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
npm install
|
|
268
|
+
npm test # run the tests
|
|
269
|
+
npm run typecheck # check the types
|
|
270
|
+
npm run build # build dist/ (CommonJS and ES modules)
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
[MIT](LICENSE) © Karam Al-Dulaimi
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
type Region = "federal" | "kurdistan";
|
|
2
|
+
/** A town, with the latitude and longitude of its center */
|
|
3
|
+
interface Town {
|
|
4
|
+
readonly ar: string;
|
|
5
|
+
readonly en: string;
|
|
6
|
+
readonly lat: number;
|
|
7
|
+
readonly lng: number;
|
|
8
|
+
}
|
|
9
|
+
interface Governorate {
|
|
10
|
+
/** Stable id to store in a database, such as "baghdad" */
|
|
11
|
+
readonly id: string;
|
|
12
|
+
/** ISO 3166-2 code, or null for a governorate that doesn't have one yet (Halabja) */
|
|
13
|
+
readonly iso: string | null;
|
|
14
|
+
readonly ar: string;
|
|
15
|
+
readonly en: string;
|
|
16
|
+
/** Kurdish (Sorani) */
|
|
17
|
+
readonly ku: string;
|
|
18
|
+
/** Federal Iraq or the Kurdistan Region */
|
|
19
|
+
readonly region: Region;
|
|
20
|
+
/** The governorate's capital city, with the latitude and longitude of its center */
|
|
21
|
+
readonly capital: Town;
|
|
22
|
+
/** Other spellings people use: Basrah, Arbil, Hawler */
|
|
23
|
+
readonly aliases: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
interface District {
|
|
26
|
+
/** Stable id to store in a database, such as "abughraib" */
|
|
27
|
+
readonly id: string;
|
|
28
|
+
/** Id of the governorate the district is in, such as "baghdad" */
|
|
29
|
+
readonly governorateId: string;
|
|
30
|
+
/**
|
|
31
|
+
* OCHA P-code, or null for a district that OCHA's 2019 data doesn't list:
|
|
32
|
+
* one created since, or one it counts as a sub-district (Abu Ghraib)
|
|
33
|
+
*/
|
|
34
|
+
readonly pcode: string | null;
|
|
35
|
+
readonly ar: string;
|
|
36
|
+
readonly en: string;
|
|
37
|
+
/** Kurdish (Sorani) */
|
|
38
|
+
readonly ku: string;
|
|
39
|
+
/** The town the district is run from, with the latitude and longitude of its center */
|
|
40
|
+
readonly center: Town;
|
|
41
|
+
/** Other spellings people use, and other names: Daghara for Akkad */
|
|
42
|
+
readonly aliases: readonly string[];
|
|
43
|
+
}
|
|
44
|
+
/** All 19 governorates: the 15 of federal Iraq, then the 4 of the Kurdistan Region */
|
|
45
|
+
declare const governorates: readonly Governorate[];
|
|
46
|
+
/** All districts, grouped by governorate in the same order as `governorates` */
|
|
47
|
+
declare const districts: readonly District[];
|
|
48
|
+
/** Reduces a name to the form used for comparing: "Al-Basrah" → "basrah", "البَصرة" → "بصره" */
|
|
49
|
+
declare function normalize(text: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Finds a governorate by its id, ISO code, or name in any language, ignoring
|
|
52
|
+
* spelling differences: "Basrah", "البصره" and "IQ-BA" all return Basra.
|
|
53
|
+
*/
|
|
54
|
+
declare function getGovernorate(query: string): Governorate | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Finds every governorate whose name contains the query, for autocomplete.
|
|
57
|
+
* Exact matches come first, then names that start with the query.
|
|
58
|
+
*/
|
|
59
|
+
declare function searchGovernorates(query: string): Governorate[];
|
|
60
|
+
/** Governorates in federal Iraq or in the Kurdistan Region */
|
|
61
|
+
declare function getGovernoratesByRegion(region: Region): Governorate[];
|
|
62
|
+
/**
|
|
63
|
+
* Finds a district by its id, P-code, or name in any language, ignoring
|
|
64
|
+
* spelling differences: "Abu Ghraib", "ابو غريب" and "abughraib" all return
|
|
65
|
+
* Abu Ghraib.
|
|
66
|
+
*/
|
|
67
|
+
declare function getDistrict(query: string): District | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Finds every district whose name contains the query, for autocomplete.
|
|
70
|
+
* Exact matches come first, then names that start with the query. Pass a
|
|
71
|
+
* governorate (any query `getGovernorate` accepts) to search only its districts.
|
|
72
|
+
*/
|
|
73
|
+
declare function searchDistricts(query: string, options?: {
|
|
74
|
+
governorate?: string;
|
|
75
|
+
}): District[];
|
|
76
|
+
/** The districts of a governorate, found by any query `getGovernorate` accepts */
|
|
77
|
+
declare function getDistrictsByGovernorate(governorate: string): District[];
|
|
78
|
+
|
|
79
|
+
export { type District, type Governorate, type Region, type Town, districts, getDistrict, getDistrictsByGovernorate, getGovernorate, getGovernoratesByRegion, governorates, normalize, searchDistricts, searchGovernorates };
|