@winrisef/world-cities 0.1.136 → 0.1.137
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/README.md +20 -3
- package/data/search/00.json +1 -0
- package/data/search/01.json +1 -0
- package/data/search/02.json +1 -0
- package/data/search/03.json +1 -0
- package/data/search/04.json +1 -0
- package/data/search/05.json +1 -0
- package/data/search/06.json +1 -0
- package/data/search/07.json +1 -0
- package/data/search/08.json +1 -0
- package/data/search/09.json +1 -0
- package/data/search/0a.json +1 -0
- package/data/search/0b.json +1 -0
- package/data/search/0c.json +1 -0
- package/data/search/0d.json +1 -0
- package/data/search/0e.json +1 -0
- package/data/search/0f.json +1 -0
- package/data/search/10.json +1 -0
- package/data/search/11.json +1 -0
- package/data/search/12.json +1 -0
- package/data/search/13.json +1 -0
- package/data/search/14.json +1 -0
- package/data/search/15.json +1 -0
- package/data/search/16.json +1 -0
- package/data/search/17.json +1 -0
- package/data/search/18.json +1 -0
- package/data/search/19.json +1 -0
- package/data/search/1a.json +1 -0
- package/data/search/1b.json +1 -0
- package/data/search/1c.json +1 -0
- package/data/search/1d.json +1 -0
- package/data/search/1e.json +1 -0
- package/data/search/1f.json +1 -0
- package/data/search/20.json +1 -0
- package/data/search/21.json +1 -0
- package/data/search/22.json +1 -0
- package/data/search/23.json +1 -0
- package/data/search/24.json +1 -0
- package/data/search/25.json +1 -0
- package/data/search/26.json +1 -0
- package/data/search/27.json +1 -0
- package/data/search/28.json +1 -0
- package/data/search/29.json +1 -0
- package/data/search/2a.json +1 -0
- package/data/search/2b.json +1 -0
- package/data/search/2c.json +1 -0
- package/data/search/2d.json +1 -0
- package/data/search/2e.json +1 -0
- package/data/search/2f.json +1 -0
- package/data/search/30.json +1 -0
- package/data/search/31.json +1 -0
- package/data/search/32.json +1 -0
- package/data/search/33.json +1 -0
- package/data/search/34.json +1 -0
- package/data/search/35.json +1 -0
- package/data/search/36.json +1 -0
- package/data/search/37.json +1 -0
- package/data/search/38.json +1 -0
- package/data/search/39.json +1 -0
- package/data/search/3a.json +1 -0
- package/data/search/3b.json +1 -0
- package/data/search/3c.json +1 -0
- package/data/search/3d.json +1 -0
- package/data/search/3e.json +1 -0
- package/data/search/3f.json +1 -0
- package/data/search/40.json +1 -0
- package/data/search/41.json +1 -0
- package/data/search/42.json +1 -0
- package/data/search/43.json +1 -0
- package/data/search/44.json +1 -0
- package/data/search/45.json +1 -0
- package/data/search/46.json +1 -0
- package/data/search/47.json +1 -0
- package/data/search/48.json +1 -0
- package/data/search/49.json +1 -0
- package/data/search/4a.json +1 -0
- package/data/search/4b.json +1 -0
- package/data/search/4c.json +1 -0
- package/data/search/4d.json +1 -0
- package/data/search/4e.json +1 -0
- package/data/search/4f.json +1 -0
- package/data/search/50.json +1 -0
- package/data/search/51.json +1 -0
- package/data/search/52.json +1 -0
- package/data/search/53.json +1 -0
- package/data/search/54.json +1 -0
- package/data/search/55.json +1 -0
- package/data/search/56.json +1 -0
- package/data/search/57.json +1 -0
- package/data/search/58.json +1 -0
- package/data/search/59.json +1 -0
- package/data/search/5a.json +1 -0
- package/data/search/5b.json +1 -0
- package/data/search/5c.json +1 -0
- package/data/search/5d.json +1 -0
- package/data/search/5e.json +1 -0
- package/data/search/5f.json +1 -0
- package/data/search/60.json +1 -0
- package/data/search/61.json +1 -0
- package/data/search/62.json +1 -0
- package/data/search/63.json +1 -0
- package/data/search/64.json +1 -0
- package/data/search/65.json +1 -0
- package/data/search/66.json +1 -0
- package/data/search/67.json +1 -0
- package/data/search/68.json +1 -0
- package/data/search/69.json +1 -0
- package/data/search/6a.json +1 -0
- package/data/search/6b.json +1 -0
- package/data/search/6c.json +1 -0
- package/data/search/6d.json +1 -0
- package/data/search/6e.json +1 -0
- package/data/search/6f.json +1 -0
- package/data/search/70.json +1 -0
- package/data/search/71.json +1 -0
- package/data/search/72.json +1 -0
- package/data/search/73.json +1 -0
- package/data/search/74.json +1 -0
- package/data/search/75.json +1 -0
- package/data/search/76.json +1 -0
- package/data/search/77.json +1 -0
- package/data/search/78.json +1 -0
- package/data/search/79.json +1 -0
- package/data/search/7a.json +1 -0
- package/data/search/7b.json +1 -0
- package/data/search/7c.json +1 -0
- package/data/search/7d.json +1 -0
- package/data/search/7e.json +1 -0
- package/data/search/7f.json +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A worldwide geographic database of countries, administrative regions, cities and city-level equivalents, with Chinese and English names, Mandarin pinyin, and WGS84 coordinates. Country-specific JSON files can be loaded on demand, with zero runtime dependencies.
|
|
4
4
|
|
|
5
|
-
[简体中文](#简体中文) · [Coverage](COVERAGE.md) · [Data attribution](NOTICE.md)
|
|
5
|
+
[Live demo / 在线展示](https://winrisef.github.io/world-cities/) · [简体中文](#简体中文) · [Coverage](COVERAGE.md) · [Data attribution](NOTICE.md)
|
|
6
6
|
|
|
7
7
|
The administrative rosters are based almost entirely on official national sources, supplemented by other public geographic references for cross-checking and filling gaps. Names, data formats and representative coordinates are normalized across countries.
|
|
8
8
|
|
|
@@ -49,13 +49,28 @@ const results = cityList.filter(city =>
|
|
|
49
49
|
Load JSON directly without installing the package. Pin a version to keep the data consistent:
|
|
50
50
|
|
|
51
51
|
```js
|
|
52
|
-
const base = 'https://cdn.jsdelivr.net/npm/@winrisef/world-cities@0.1.
|
|
52
|
+
const base = 'https://cdn.jsdelivr.net/npm/@winrisef/world-cities@0.1.137/data'
|
|
53
53
|
const countries = await fetch(`${base}/countries.json`).then(r => r.json())
|
|
54
54
|
const cities = await fetch(`${base}/cities/CN.json`).then(r => r.json())
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
You can also serve the packaged `data/` directory yourself and change `base` accordingly.
|
|
58
58
|
|
|
59
|
+
### Global search routing
|
|
60
|
+
|
|
61
|
+
Search a name before downloading country files. The 128 `data/search/` shards map normalized name prefixes to country codes; fetch only the matching countries' city and region files.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const term = 'Lhasa'.normalize('NFKD').replace(/\p{M}/gu, '').toLowerCase().replace(/[^\p{L}\p{N}]/gu, '')
|
|
65
|
+
const chars = [...term]
|
|
66
|
+
const prefix = chars.slice(0, /\p{Script=Han}/u.test(chars[0]) ? 1 : 2)
|
|
67
|
+
const shard = (prefix.reduce((n, c) => n * 31 + c.codePointAt(0), 0) % 128).toString(16).padStart(2, '0')
|
|
68
|
+
const entries = await fetch(`${base}/search/${shard}.json`).then(r => r.json())
|
|
69
|
+
const codes = new Set(entries.filter(([name]) => name.startsWith(term)).flatMap(([, ids]) => ids.match(/../g)))
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Use at least two non-Han characters, or one Chinese character. Each row is `[normalizedName, concatenatedCountryCodes]`; the actual place records remain in the country files.
|
|
73
|
+
|
|
59
74
|
## Data structure
|
|
60
75
|
|
|
61
76
|
| Path | Fields |
|
|
@@ -64,6 +79,7 @@ You can also serve the packaged `data/` directory yourself and change `base` acc
|
|
|
64
79
|
| `data/regions/{ISO2}.json` | `id`, `country`, `code`, `zh`, `en`, `pinyin`; optional `aliases`, `children` |
|
|
65
80
|
| `data/cities/{ISO2}.json` | `id`, `country`, `region`, `kind`, `zh`, `en`, `pinyin`, `lat`, `lon`; optional `subregion`, `officialId`, `aliases` |
|
|
66
81
|
| `data/coverage.json` | Record totals, name coverage and per-country verification status |
|
|
82
|
+
| `data/search/{00..7f}.json` | Normalized names and country-code routing index |
|
|
67
83
|
|
|
68
84
|
- `region` refers to a first-level administrative region ID, or is `null` when no applicable region exists or one cannot be reliably determined.
|
|
69
85
|
- `subregion` may refer to an entry in `children`, or contain a lower-level name or code from the source roster. Treat `id` values as opaque strings.
|
|
@@ -111,7 +127,7 @@ npm install @winrisef/world-cities
|
|
|
111
127
|
- Node.js:通过 `countryFiles('CN')` 获取省级行政区和城市 JSON 的 URL,再读取数据,按 `zh`、`en`、`pinyin` 和 `aliases` 字段搜索。
|
|
112
128
|
- 浏览器:直接请求固定版本的 CDN JSON,或自行部署 `data/`,无需引入库。
|
|
113
129
|
|
|
114
|
-
完整代码示例见上方 [Usage](#usage)
|
|
130
|
+
完整代码示例见上方 [Usage](#usage)。全球地名检索可先调用[搜索索引](#global-search-routing),再按需加载国家数据。
|
|
115
131
|
|
|
116
132
|
### 数据结构
|
|
117
133
|
|
|
@@ -121,6 +137,7 @@ npm install @winrisef/world-cities
|
|
|
121
137
|
| `data/regions/{ISO2}.json` | `id`, `country`, `code`, `zh`, `en`, `pinyin`,可选 `aliases`, `children` |
|
|
122
138
|
| `data/cities/{ISO2}.json` | `id`, `country`, `region`, `kind`, `zh`, `en`, `pinyin`, `lat`, `lon`,可选 `subregion`, `officialId`, `aliases` |
|
|
123
139
|
| `data/coverage.json` | 数据总量、名称覆盖率、逐国核验状态 |
|
|
140
|
+
| `data/search/{00..7f}.json` | 地名搜索索引,仅返回匹配的国家代码 |
|
|
124
141
|
|
|
125
142
|
- `region` 指向一级行政区 ID;不适用或无法可靠确定一级行政区时为 `null`。
|
|
126
143
|
- `subregion` 可以是所属 `children` 记录的 ID,也可能是来源名录中的下级行政区名称或代码。`id` 应视为不透明字符串。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[["ddonau","ATDE"],["hhohho","SZ"],["llacaze","UY"],["llacuna","ES"],["llacunala","ES"],["llado","ES"],["lladorre","ES"],["lladurs","ES"],["llagonne","FR"],["llagosta","ES"],["llagostala","ES"],["llagostera","ES"],["llaillay","CL"],["llallagua","BO"],["llamasdelaribera","ES"],["llambicampbell","AR"],["llambilles","ES"],["llamellin","PE"],["llampaies","ES"],["llanada","CO"],["llanars","ES"],["llanca","ES"],["llanera","ES"],["llaneraderanes","ES"],["llanes","ES"],["llangreulangreo","ES"],["llano","DOESMXUSVE"],["llanodebureba","ES"],["llanodecatival","PA"],["llanodeolmedo","ES"],["llanogrande","MX"],["llanos","DOES"],["llanosdearidane","ES"],["llanosdearidanelos","ES"],["llanosdelcaudillo","ES"],["llanosdetormes","ES"],["llanosdetormeslos","ES"],["llanquihue","CL"],["llanquin","AR"],["llardecans","ES"],["llarga","ES"],["llargala","ES"],["llata","PE"],["llauri","ES"],["llauro","FR"],["llavaneres","ES"],["llave","MX"],["llavianapoladelaviana","ES"],["llavorsi","ES"],["lledo","ES"],["lleida","ES"],["llemena","ES"],["llera","ESMX"],["lleradecanales","MX"],["lleras","CO"],["llerena","ARES"],["llers","ES"],["llert","ES"],["llesdecerdanya","ES"],["lliber","ES"],["llica","BO"],["llicadamunt","ES"],["llicadevall","ES"],["llierca","ES"],["llimiana","ES"],["llinars","ES"],["llinarsdelvalles","ES"],["lliria","ES"],["llivia","ES"],["llo","FR"],["lloar","ES"],["lloarel","ES"],["llobera","ES"],["llobrega","ES"],["llobregat","ES"],["llobregatel","ES"],["llobregatl","ES"],["lloc","PE"],["llocdurgell","ES"],["llocnoudelacorona","ES"],["llocnoudenfenollet","ES"],["llocnoudesantjeroni","ES"],["llodio","ES"],["llogaiadalguema","ES"],["llombai","ES"],["llorac","ES"],["llorcha","ES"],["lloredo","ES"],["llorencdelamuga","ES"],["llorencdelpenedes","ES"],["llorencdemorunys","ES"],["llorencdescardassar","ES"],["llorencdhortons","ES"],["llorencsavall","ES"],["llorente","ES"],["lloretdemar","ES"],["lloretdevistalegre","ES"],["lloribonmati","ES"],["lloro","CO"],["llosa","ES"],["llosaderanes","ES"],["llosaderanesla","ES"],["llosala","ES"],["lloseta","ES"],["llosses","ES"],["llossesles","ES"],["llotes","FR"],["lloydminster","CA"],["lluancoluanco","ES"],["lluarca","ES"],["llubi","ES"],["lluc","ES"],["lluca","ES"],["llucanes","ES"],["llucena","ES"],["llucenalucenadelcid","ES"],["llucmajor","ES"],["lluis","ES"],["llupia","FR"],["llutxent","ES"],["ttari","TT"],["ttcha","TT"],["ttctt","TT"],["ttdmn","TT"],["tte1manueliralafernandez","PY"],["ttmrc","TT"],["ttped","TT"],["ttpos","TT"],["ttprt","TT"],["ttptf","TT"],["ttsfo","TT"],["ttsge","TT"],["ttsip","TT"],["ttsjl","TT"],["tttob","TT"],["tttup","TT"],["xxdeseptiembre","AR"],["xxiii","IT"],["اهديل","MA"],["اهر","IR"],["اهرم","IR"],["اهل","IR"],["اهلالرمل","MA"],["اهلالقصر","DZ"],["اهلانكاد","MA"],["اهلتفنوت","MA"],["اهلسيديلحسن","MA"],["اهلمربع","MA"],["اهلوادزا","MA"],["اهمج","LB"],["اهناسيا","EG"],["اهواز","IR"],["ببا","EG"],["ببنينالعبده","LB"],["ببين","LB"],["ششار","DZ"],["ششتمد","IR"],["ششده","IR"],["للاتكركوست","MA"],["للاعزيزة","MA"],["للاميمونة","MA"],["ووزكان","MA"],["چنار","IR"],["چناران","IR"],["چنارانشهر","IR"],["چناره","IR"],["چۆمان","IQ"],["घघरडह","IN"],["जजपर","IN"],["जजर","IN"],["ननव","IN"],["वकरमगज","IN"],["वकरमगड","IN"],["ससरम","IN"],["ससवड","IN"],["জজর","BD"],["ননদইল","BD"],["ননদগরম","BD"],["ਬਬਬਕਲ","IN"],["ଜଜପର","IN"],["தததயஙகரபடட","IN"],["நநதரவரமகடவஞசர","IN"],["வகரவணட","IN"],["వకరబద","IN"],["വകക","IN"],["แมสอด","TH"],["ແມດ","LA"],["ໂຂງ","LA"],["က","MM"],["ကကက","MM"],["ကကကန","MM"],["ကကခမ","MM"],["ကကဆည","MM"],["ကကတ","MM"],["ကကတခ","MM"],["ကကတန","MM"],["ကကတလက","MM"],["ကကထ","MM"],["ကကဒ","MM"],["ကကပနတင","MM"],["ကကဖ","MM"],["ကကမ","MM"],["ကကမင","MM"],["ကကမရ","MM"],["ကကရတ","MM"],["ကကလတ","MM"],["တတ","MM"],["တတန","MM"],["တတဥ","MM"],["နနပန","MM"],["နနမ","MM"],["နနမန","MM"],["နနမယခ","MM"],["နနယန","MM"],["속초시","KR"],["송림","KP"],["송림시","KP"],["송원","KP"],["송원군","KP"],["송화","KP"],["송화군","KP"],["一串串木野史","JP"],["一关市","JP"],["一宫市","JP"],["一宮市","JP"],["一月一日市镇","CU"],["一関市","JP"],["亀山市","JP"],["亀岡市","JP"],["喀什地区","CN"],["喀什马克","US"],["喀土穆","SD"],["喀尔巴阡山脉","PL"],["喀山","RU"],["喀布尔","AF"],["喀拉拉邦","IN"],["喀斯喀特","US"],["喀斯喀特洛克斯","US"],["喀里多尼亚","US"],["喀麦隆","CM"],["开伯尔普什图省","PK"],["开司米","US"],["开城","KP"],["开基","IN"],["开塞利","TR"],["开姆尼茨","DE"],["开始","CH"],["开封","CN"],["开普吉拉多","US"],["开普敦","ZA"],["开普梅","US"],["开普科勒尔","US"],["开曼群岛","KY"],["开罗","EGUS"],["开花","US"],["开赛东方","CD"],["开赛中央区","CD"],["怀俄明","US"],["怀俄明州","US"],["怀俄明艾奥瓦州","US"],["怀利","US"],["怀化","CN"],["怀卡托","NZ"],["怀卡托区","NZ"],["怀塔克雷","NZ"],["怀塔基区","NZ"],["怀奥塔","US"],["怀尔卡特赫姆","AU"],["怀尔多马","US"],["怀尔德","US"],["怀尔德伍德","US"],["怀尼米港","US"],["怀帕区","NZ"],["怀廷","US"],["怀恩多特","US"],["怀托摩区","NZ"],["怀特","US"],["怀特伍德","US"],["怀特克劳德","US"],["怀特奥克","US"],["怀特斯伯勒","US"],["怀特普莱恩斯","US"],["怀特沃特","US"],["怀特维尔","US"],["怀特莱克","US"],["怀特菲什","US"],["怀特萨蒙","US"],["怀特豪斯","US"],["怀特霍尔","US"],["怀特霍尔俄亥俄州","US"],["怀罗瓦区","NZ"],["怀茨堡","US"],["怀莫尔","US"],["怀诺","CH"],["怀里卡","US"],["怀阿拉","AU"],["怀马卡里里区","NZ"],["怀马特区","NZ"],["攀枝花","CN"],["攀牙府","TH"],["最好的","NL"],["简斯维尔","US"],["紀の川市","JP"],["耀德郡","KP"],["銀城","US"],["門內多夫","CH"],["門塔爾","CH"],["門多塔","US"],["門多塔伊利諾伊州","US"],["門多塔海茨","US"],["門德里西奧","CH"],["門托","US"],["門洛","US"],["門登霍爾","US"],["門真市","JP"],["門羅","US"],["門羅城","US"],["門茨瑙","CH"],["門齊肯","CH"]]
|