@code-plate/iran-cities 1.1.0 → 1.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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 1.2.0
4
+ - **Added:** numeric `id` for provinces and cities (globally unique, stable); `isCapital`, `capitalId`, province `phoneCode`.
5
+ - **Added:** `coordinates: { lat, lng, confidence }` for 1152 cities (GeoNames, CC BY 4.0); `confidence` is `'high' | 'medium' | 'low'`.
6
+ - **Added:** `getCityById`, `getProvinceById`, `getCitiesByName`, `getCapital`, `getCapitals`, `getProvinceByPhoneCode`; lookups accept numeric ids.
7
+ - **Added:** `npm run validate` data-integrity checks.
8
+ - **Fixed:** duplicate «گلوگاه» entry in Mazandaran removed (1253 -> 1252 cities); `useCitySearch` / `useProvinceSearch` no longer re-run on inline `options`.
9
+ - **Corrected data (old names/slugs still resolve):** city 402 `sowme'eh-sara` -> `sowmeeh-sara` (fa: صومعه سرا); city 672 `هلشی` -> `halashi` (fa: هلشی). Ids unchanged.
10
+ - **Corrected coordinates:** Ahvaz and Kermanshah capital coordinates fixed (source table was ~110 km / ~60 km off).
package/NOTICE.md ADDED
@@ -0,0 +1,21 @@
1
+ # Attribution / منابع و مجوز داده‌ها
2
+
3
+ Coordinates (`lat`/`lng`) in `src/data.json` are point locations from **GeoNames** (https://www.geonames.org),
4
+ licensed under **Creative Commons Attribution 4.0** (CC BY 4.0). Attribution to GeoNames is required.
5
+
6
+ - Source file: GeoNames Iran dump `IR.zip` (https://download.geonames.org/export/dump/IR.zip), supplied by the package author on 2026-10-07.
7
+ - The 31 provincial-capital coordinates were supplied by the package author (Wikipedia table), cross-checked against GeoNames;
8
+ two were corrected (Ahvaz, Kermanshah).
9
+ - Each city was matched to a GeoNames populated place by normalized Persian name within the same province
10
+ (province mapped through GeoNames admin1 codes), with a Latin-name fallback. Abandoned/destroyed/historical places were excluded.
11
+
12
+ The following public datasets were used **only to cross-check the match** (no values were copied from them unless they equal the GeoNames value):
13
+
14
+ | Dataset | Used for | License |
15
+ |---|---|---|
16
+ | sajaddp/list-of-cities-in-Iran | cross-check; official county seats (GeoNames-derived) | repo: GPL-3.0; coordinate records: CC BY 4.0 (GeoNames) |
17
+ | dr5hn/countries-states-cities-database | cross-check only | ODbL-1.0 |
18
+ | jafaripur/iran-locality-database | cross-check only | none stated |
19
+ | mhndev/iran-geography | cross-check only | none stated |
20
+
21
+ This is a summary, not legal advice.
package/README.fa.md CHANGED
@@ -98,7 +98,7 @@ getCapital('khuzestan'); // => { id: 674, en: 'ahvaz', isCapital: true, c
98
98
  getCapitals(); // ۳۱ مرکز استان
99
99
  getProvinceByPhoneCode('021'); // => تهران ('21' و 21 هم قبول است)
100
100
  getCity('نجف‌آباد').phoneCode; // => '031' (کد استانِ شهر)
101
- getCity('اهواز').coordinates; // => { lat, lng } | برای شهرهای غیرمرکز استان: undefined
101
+ getCity('اهواز').coordinates; // => { lat, lng, confidence } | برای شهرهای غیرمرکز استان: undefined
102
102
 
103
103
  // آمار کلی
104
104
  getStats(); // { provinceCount: 31, cityCount: 1252 }
@@ -270,7 +270,7 @@ export class IranLocationsService {
270
270
  ### تایپ‌ها
271
271
 
272
272
  ```ts
273
- interface Coordinates { lat: number; lng: number; }
273
+ interface Coordinates { lat: number; lng: number; confidence: 'high' | 'medium' | 'low'; }
274
274
  interface City { id: number; isCapital: boolean; coordinates?: Coordinates; slug: string; en: string; fa: string; }
275
275
  interface Province { id: number; en: string; fa: string; phoneCode: string; capitalId: number; cities: City[]; }
276
276
  interface FlatCity extends City { provinceId: number; provinceEn: string; provinceFa: string; phoneCode: string; }
@@ -288,7 +288,7 @@ npm run validate # اعتبارسنجی یکپارچگی data.json (id، slug،
288
288
  npm test # validate + typecheck
289
289
  ```
290
290
 
291
- > **مختصات:** برای ۳۷۰ شهر (۳۱ مرکز استان + عمدتاً مراکز شهرستان) موجود است و فقط وقتی ثبت شده که حداقل دو منبع مستقل روی آن توافق داشته‌اند (جزئیات در `reports/`). برای بقیه `coordinates` برابر `undefined` است و هیچ مقدار تقریبی جایگزین نمی‌شود. منبع داده: GeoNames (CC BY 4.0)، فایل `NOTICE.md`.
291
+ > **مختصات:** برای ۱۱۵۲ شهر از ۱۲۵۲ شهر موجود است (`coordinates: { lat, lng, confidence }`). `confidence` سه مقدار دارد: `'high'` (۹۷۷ شهر) یعنی منبع مستقل دیگری هم همان نقطه را تأیید کرده؛ `'medium'` (۹۸ شهر) یعنی نام شهر در GeoNames یکتا و شهر واقعی بوده ولی تأیید مستقل نداشته؛ `'low'` (۷۷ شهر) یعنی فقط تطبیق نام در GeoNames هست و مکانِ مطابق کوچک یا بدون جمعیت ثبت شده یا نام تقریبی تطبیق داده شده (فقط برای نمایش تقریبی؛ خطای چند تا ده‌ها کیلومتر محتمل است). برای ۱۰۰ شهر باقی‌مانده `coordinates` برابر `undefined` است و هیچ مقدار تقریبی جایگزین نمی‌شود (فهرست و دلیل: `reports/coordinates-not-imported.csv`). منبع داده: GeoNames (CC BY 4.0)، فایل `NOTICE.md`.
292
292
 
293
293
  ## لایسنس
294
294
 
package/README.md CHANGED
@@ -98,7 +98,7 @@ getCapital('khuzestan'); // => { id: 674, en: 'ahvaz', isCapital: true, c
98
98
  getCapitals(); // the 31 provincial capitals
99
99
  getProvinceByPhoneCode('021'); // => Tehran ('21' and 21 work too)
100
100
  getCity('نجف‌آباد').phoneCode; // => '031' (area code of the city's province)
101
- getCity('اهواز').coordinates; // => { lat, lng } | undefined for non-capital cities
101
+ getCity('اهواز').coordinates; // => { lat, lng, confidence } | undefined for non-capital cities
102
102
 
103
103
  // Overall stats
104
104
  getStats(); // { provinceCount: 31, cityCount: 1252 }
@@ -270,7 +270,7 @@ export class IranLocationsService {
270
270
  ### Types
271
271
 
272
272
  ```ts
273
- interface Coordinates { lat: number; lng: number; }
273
+ interface Coordinates { lat: number; lng: number; confidence: 'high' | 'medium' | 'low'; }
274
274
  interface City { id: number; isCapital: boolean; coordinates?: Coordinates; slug: string; en: string; fa: string; }
275
275
  interface Province { id: number; en: string; fa: string; phoneCode: string; capitalId: number; cities: City[]; }
276
276
  interface FlatCity extends City { provinceId: number; provinceEn: string; provinceFa: string; phoneCode: string; }
@@ -288,7 +288,7 @@ npm run validate # data integrity checks for data.json (ids, slugs, capitals, a
288
288
  npm test # validate + typecheck
289
289
  ```
290
290
 
291
- > **Coordinates:** available for 370 cities (31 provincial capitals + mostly county seats), recorded only when at least two independent sources agree (details in `reports/`). For every other city `coordinates` is `undefined`; no approximate values are filled in. Data source: GeoNames (CC BY 4.0), see `NOTICE.md`.
291
+ > **Coordinates:** available for 1152 of 1252 cities (`coordinates: { lat, lng, confidence }`). `confidence` has three levels: `'high'` (977 cities) – an independent source confirms the same point; `'medium'` (98) – the name is unique in GeoNames and the place is city-like, but no independent confirmation; `'low'` (77) – only a name match in GeoNames, where the matched place is small/unpopulated or the name match was approximate (approximate display only; errors of several to tens of km are possible). For the remaining 100 cities `coordinates` is `undefined`; no approximate values are filled in (list and reasons: `reports/coordinates-not-imported.csv`). Data source: GeoNames (CC BY 4.0), see `NOTICE.md`.
292
292
 
293
293
  ## License
294
294