turkish_cities 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +34 -0
- data/.github/workflows/ruby.yml +39 -0
- data/.hound.yml +1 -1
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +26 -0
- data/Gemfile.lock +38 -46
- data/README.md +301 -30
- data/Rakefile +11 -0
- data/{config → lib/config}/locales/en.yml +3 -0
- data/{config → lib/config}/locales/tr.yml +3 -0
- data/lib/turkish_cities/data/cities.yaml +243 -0
- data/lib/turkish_cities/data/districts/adana.yaml +1 -1
- data/lib/turkish_cities/data/districts/adiyaman.yaml +184 -176
- data/lib/turkish_cities/data/districts/afyon.yaml +295 -189
- data/lib/turkish_cities/data/districts/agri.yaml +28 -28
- data/lib/turkish_cities/data/districts/aksaray.yaml +90 -61
- data/lib/turkish_cities/data/districts/amasya.yaml +17 -6
- data/lib/turkish_cities/data/districts/ankara.yaml +22 -22
- data/lib/turkish_cities/data/districts/antalya.yaml +3 -3
- data/lib/turkish_cities/data/districts/ardahan.yaml +10 -7
- data/lib/turkish_cities/data/districts/artvin.yaml +0 -60
- data/lib/turkish_cities/data/districts/bartin.yaml +23 -19
- data/lib/turkish_cities/data/districts/batman.yaml +45 -28
- data/lib/turkish_cities/data/districts/bayburt.yaml +12 -6
- data/lib/turkish_cities/data/districts/bilecik.yaml +18 -14
- data/lib/turkish_cities/data/districts/bingol.yaml +29 -35
- data/lib/turkish_cities/data/districts/bitlis.yaml +56 -43
- data/lib/turkish_cities/data/districts/bolu.yaml +34 -58
- data/lib/turkish_cities/data/districts/burdur.yaml +22 -16
- data/lib/turkish_cities/data/districts/bursa.yaml +3 -2
- data/lib/turkish_cities/data/districts/canakkale.yaml +46 -47
- data/lib/turkish_cities/data/districts/cankiri.yaml +23 -18
- data/lib/turkish_cities/data/districts/corum.yaml +25 -15
- data/lib/turkish_cities/data/districts/denizli.yaml +1 -1
- data/lib/turkish_cities/data/districts/diyarbakir.yaml +6 -6
- data/lib/turkish_cities/data/districts/duzce.yaml +83 -74
- data/lib/turkish_cities/data/districts/edirne.yaml +37 -23
- data/lib/turkish_cities/data/districts/elazig.yaml +74 -54
- data/lib/turkish_cities/data/districts/erzincan.yaml +47 -38
- data/lib/turkish_cities/data/districts/erzurum.yaml +1 -1
- data/lib/turkish_cities/data/districts/giresun.yaml +125 -57
- data/lib/turkish_cities/data/districts/gumushane.yaml +61 -81
- data/lib/turkish_cities/data/districts/hakkari.yaml +22 -15
- data/lib/turkish_cities/data/districts/hatay.yaml +1 -1
- data/lib/turkish_cities/data/districts/igdir.yaml +20 -11
- data/lib/turkish_cities/data/districts/isparta.yaml +67 -40
- data/lib/turkish_cities/data/districts/istanbul.yaml +12 -12
- data/lib/turkish_cities/data/districts/izmir.yaml +12 -12
- data/lib/turkish_cities/data/districts/kahramanmaras.yaml +3 -2
- data/lib/turkish_cities/data/districts/karabuk.yaml +15 -28
- data/lib/turkish_cities/data/districts/karaman.yaml +36 -31
- data/lib/turkish_cities/data/districts/kars.yaml +5 -4
- data/lib/turkish_cities/data/districts/kastamonu.yaml +3 -29
- data/lib/turkish_cities/data/districts/kayseri.yaml +8 -8
- data/lib/turkish_cities/data/districts/kilis.yaml +3 -2
- data/lib/turkish_cities/data/districts/kirikkale.yaml +17 -13
- data/lib/turkish_cities/data/districts/kirklareli.yaml +63 -45
- data/lib/turkish_cities/data/districts/kirsehir.yaml +25 -16
- data/lib/turkish_cities/data/districts/kocaeli.yaml +1 -1
- data/lib/turkish_cities/data/districts/konya.yaml +7 -8
- data/lib/turkish_cities/data/districts/kutahya.yaml +104 -72
- data/lib/turkish_cities/data/districts/malatya.yaml +1 -1
- data/lib/turkish_cities/data/districts/manisa.yaml +2 -2
- data/lib/turkish_cities/data/districts/mersin.yaml +4 -4
- data/lib/turkish_cities/data/districts/mus.yaml +118 -74
- data/lib/turkish_cities/data/districts/nevsehir.yaml +51 -43
- data/lib/turkish_cities/data/districts/nigde.yaml +135 -76
- data/lib/turkish_cities/data/districts/ordu.yaml +3 -3
- data/lib/turkish_cities/data/districts/osmaniye.yaml +53 -32
- data/lib/turkish_cities/data/districts/rize.yaml +68 -46
- data/lib/turkish_cities/data/districts/sakarya.yaml +2 -2
- data/lib/turkish_cities/data/districts/samsun.yaml +3 -3
- data/lib/turkish_cities/data/districts/sanliurfa.yaml +7 -7
- data/lib/turkish_cities/data/districts/siirt.yaml +27 -13
- data/lib/turkish_cities/data/districts/sinop.yaml +1 -5
- data/lib/turkish_cities/data/districts/sirnak.yaml +78 -40
- data/lib/turkish_cities/data/districts/sivas.yaml +49 -52
- data/lib/turkish_cities/data/districts/tekirdag.yaml +7 -2
- data/lib/turkish_cities/data/districts/tokat.yaml +201 -138
- data/lib/turkish_cities/data/districts/trabzon.yaml +1 -0
- data/lib/turkish_cities/data/districts/tunceli.yaml +13 -9
- data/lib/turkish_cities/data/districts/usak.yaml +40 -24
- data/lib/turkish_cities/data/districts/van.yaml +6 -4
- data/lib/turkish_cities/data/districts/yalova.yaml +45 -21
- data/lib/turkish_cities/data/districts/yozgat.yaml +147 -80
- data/lib/turkish_cities/data/districts/zonguldak.yaml +127 -90
- data/lib/turkish_cities/data/neighborhoods_parser.rb +3 -3
- data/lib/turkish_cities/elevation.rb +42 -0
- data/lib/turkish_cities/helpers/decomposer_helper.rb +28 -0
- data/lib/turkish_cities/population.rb +60 -0
- data/lib/turkish_cities/version.rb +1 -1
- data/lib/turkish_cities.rb +12 -1
- data/turkish_cities.gemspec +4 -3
- metadata +31 -13
- data/.travis.yml +0 -21
data/README.md
CHANGED
@@ -3,10 +3,12 @@
|
|
3
3
|
<p align="center">
|
4
4
|
<a href="https://rubygems.org/gems/turkish_cities">
|
5
5
|
<img src="https://badge.fury.io/rb/turkish_cities.svg" alt="GemVersion"/></a>
|
6
|
-
<a href="https://
|
7
|
-
<img src="https://
|
8
|
-
<a href="https://
|
9
|
-
<img src="https://
|
6
|
+
<a href="https://app.circleci.com/pipelines/github/sarslanoglu/turkish_cities">
|
7
|
+
<img src="https://circleci.com/gh/sarslanoglu/turkish_cities.svg?style=shield" alt="BuildStatus"/></a>
|
8
|
+
<a href="https://codecov.io/gh/sarslanoglu/turkish_cities">
|
9
|
+
<img src="https://codecov.io/gh/sarslanoglu/turkish_cities/branch/master/graph/badge.svg?token=1SU7ZFI8ZJ"/></a>
|
10
|
+
<a href="https://rubygems.org/gems/turkish_cities">
|
11
|
+
<img src="https://img.shields.io/gem/dt/turkish_cities.svg" alt="DownloadCount"/></a>
|
10
12
|
<a href="https://codeclimate.com/github/sarslanoglu/turkish_cities/maintainability">
|
11
13
|
<img src="https://api.codeclimate.com/v1/badges/c1dbe0cef353b152956e/maintainability" alt="Maintainability"/></a>
|
12
14
|
<a href="https://houndci.com">
|
@@ -18,31 +20,70 @@
|
|
18
20
|
**Turkish Cities** is a Ruby gem which makes listing and finding Turkish cities easy. Search can be via name, post code, plate number, district name etc. Also calculate your travel distance and travel time between cities via distance methods.
|
19
21
|
https://rubygems.org/gems/turkish_cities
|
20
22
|
|
23
|
+
|
21
24
|
## Table of Contents
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
25
|
+
<details>
|
26
|
+
<summary>Table of Contents</summary>
|
27
|
+
<ul>
|
28
|
+
<li><a href="#installation">Installation</a></li>
|
29
|
+
<li><a href="#localization">Localization</a></li>
|
30
|
+
<li>
|
31
|
+
<a href="#documentation">Documentation</a>
|
32
|
+
<ul>
|
33
|
+
<li><a href="#finding-city-name-by-plate-number">Finding city name by plate number</a></li>
|
34
|
+
<li><a href="#finding-city-name-by-phone-code">Finding city name by phone code</a></li>
|
35
|
+
<li><a href="#finding-plate-number-by-city-name">Finding plate number by city name</a></li>
|
36
|
+
<li><a href="#finding-phone-code-by-city-name">Finding phone code by city name</a></li>
|
37
|
+
<li>
|
38
|
+
<a href="#listing-all-cities">Listing all cities</a>
|
39
|
+
<ul>
|
40
|
+
<li><a href="#listing-all-cities-with-only-name">Listing all cities with only name</a></li>
|
41
|
+
<li><a href="#listing-all-cities-with-other-parameters">Listing all cities with other parameters</a></li>
|
42
|
+
</ul>
|
43
|
+
</li>
|
44
|
+
<li><a href="#listing-all-districts-of-given-city">Listing all districts of given city</a></li>
|
45
|
+
<li><a href="#listing-all-subdistricts-of-given-city-and-district">Listing all subdistricts of given city and district</a></li>
|
46
|
+
<li>
|
47
|
+
<a href="#listing-all-neighborhoods-of-given-city-and-district">Listing all neighborhoods of given city and district</a>
|
48
|
+
<ul>
|
49
|
+
<li><a href="#with-subdistrict-info">With subdistrict info</a></li>
|
50
|
+
<li><a href="#without-subdistrict-info">Without subdistrict info</a></li>
|
51
|
+
</ul>
|
52
|
+
</li>
|
53
|
+
<li><a href="#finding-city-district-and-subdistrict-name-by-postcode">Finding city, district and subdistrict name by postcode</a></li>
|
54
|
+
<li>
|
55
|
+
<a href="#finding-city-name-with-elevation-data">Finding city name with elevation data</a>
|
56
|
+
<ul>
|
57
|
+
<li><a href="#below-given">Below given</a></li>
|
58
|
+
<li><a href="#above-given">Above given</a></li>
|
59
|
+
<li><a href="#between-search">Between search</a></li>
|
60
|
+
</ul>
|
61
|
+
</li>
|
62
|
+
<li>
|
63
|
+
<a href="#finding-city-name-with-population-data">Finding city name with population data</a>
|
64
|
+
<ul>
|
65
|
+
<li><a href="#exact-search">Exact search</a></li>
|
66
|
+
<li><a href="#below-given">Below given</a></li>
|
67
|
+
<li><a href="#above-given">Above given</a></li>
|
68
|
+
<li><a href="#between-search">Between search</a></li>
|
69
|
+
</ul>
|
70
|
+
</li>
|
71
|
+
<li>
|
72
|
+
<a href="#finding-travel-distance-and-time-estimation-between-two-cities">Finding travel distance and time estimation between two cities</a>
|
73
|
+
<ul>
|
74
|
+
<li><a href="#by-land">By land</a></li>
|
75
|
+
<li><a href="#by-air">By air</a></li>
|
76
|
+
</ul>
|
77
|
+
</li>
|
78
|
+
</ul>
|
79
|
+
</li>
|
80
|
+
<li><a href="#data-sources">Data sources</a></li>
|
81
|
+
<li><a href="#compatibility">Compatibility</a></li>
|
82
|
+
<li><a href="#contributing">Contributing</a></li>
|
83
|
+
<li><a href="#changelog">Changelog</a></li>
|
84
|
+
<li><a href="#copyright">Copyright</a></li>
|
85
|
+
</ul>
|
86
|
+
</details>
|
46
87
|
|
47
88
|
## Installation
|
48
89
|
|
@@ -94,6 +135,9 @@ require 'turkish_cities'
|
|
94
135
|
|
95
136
|
There are 81 cities in Turkey. By calling a plate number between 1-81 will give city_name.
|
96
137
|
|
138
|
+
<details>
|
139
|
+
<summary>Expand</summary>
|
140
|
+
|
97
141
|
```rb
|
98
142
|
TurkishCities.find_name_by_plate_number(26) # => "Eskişehir"
|
99
143
|
TurkishCities.find_name_by_plate_number(7) # => "Antalya"
|
@@ -102,11 +146,15 @@ TurkishCities.find_name_by_plate_number(43.0) # => "Kütahya"
|
|
102
146
|
TurkishCities.find_name_by_plate_number('78') # => "Karabük"
|
103
147
|
TurkishCities.find_name_by_plate_number(100) # => 'Given value [100] is outside bounds of 1 to 81.'
|
104
148
|
```
|
149
|
+
</details>
|
105
150
|
|
106
151
|
### Finding city name by phone code
|
107
152
|
|
108
153
|
There are 82 phone codes for each city in Turkey (Istanbul is an exception with different phone codes for Anatolian side and European side). By calling a phone code between 212-488 will give city_name. All phone codes ending with even numbers. So sending an odd number will give an error without searching.
|
109
154
|
|
155
|
+
<details>
|
156
|
+
<summary>Expand</summary>
|
157
|
+
|
110
158
|
```rb
|
111
159
|
TurkishCities.find_name_by_phone_code(312) # => "Ankara"
|
112
160
|
TurkishCities.find_name_by_phone_code(242) # => "Antalya"
|
@@ -118,11 +166,15 @@ TurkishCities.find_name_by_phone_code(360) # => 'Couldn't find city name with
|
|
118
166
|
TurkishCities.find_name_by_phone_code(0) # => 'Given value [0] is outside bounds of 212 to 488.'
|
119
167
|
TurkishCities.find_name_by_phone_code(213) # => 'Given value [213] must be an even number.'
|
120
168
|
```
|
169
|
+
</details>
|
121
170
|
|
122
171
|
### Finding plate number by city name
|
123
172
|
|
124
173
|
City name can be given case and turkish character insensitive.
|
125
174
|
|
175
|
+
<details>
|
176
|
+
<summary>Expand</summary>
|
177
|
+
|
126
178
|
```rb
|
127
179
|
TurkishCities.find_plate_number_by_name('Ankara') # => 6
|
128
180
|
TurkishCities.find_plate_number_by_name('Eskişehir') # => 26
|
@@ -131,11 +183,15 @@ TurkishCities.find_plate_number_by_name('Istanbul') # => 34
|
|
131
183
|
TurkishCities.find_plate_number_by_name('kirsehir') # => 40
|
132
184
|
TurkishCities.find_plate_number_by_name('falansehir') # => "Couldn't find city name with 'falansehir'"
|
133
185
|
```
|
186
|
+
</details>
|
134
187
|
|
135
188
|
### Finding phone code by city name
|
136
189
|
|
137
190
|
City name can be given case and turkish character insensitive.
|
138
191
|
|
192
|
+
<details>
|
193
|
+
<summary>Expand</summary>
|
194
|
+
|
139
195
|
```rb
|
140
196
|
TurkishCities.find_phone_code_by_name('Ankara') # => 312
|
141
197
|
TurkishCities.find_phone_code_by_name('Eskişehir') # => 222
|
@@ -144,19 +200,27 @@ TurkishCities.find_phone_code_by_name('Istanbul') # => [212, 216]
|
|
144
200
|
TurkishCities.find_phone_code_by_name('kirsehir') # => 386
|
145
201
|
TurkishCities.find_phone_code_by_name('filansehir') # => "Couldn't find city name with 'filansehir'"
|
146
202
|
```
|
203
|
+
</details>
|
147
204
|
|
148
205
|
### Listing all cities
|
149
206
|
|
150
207
|
By default cities will be listed by their plate number ascending.
|
151
208
|
|
209
|
+
<details>
|
210
|
+
<summary>Expand</summary>
|
211
|
+
|
152
212
|
```rb
|
153
213
|
TurkishCities.list_cities # => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "Düzce"]
|
154
214
|
```
|
215
|
+
</details>
|
155
216
|
|
156
217
|
### Listing all cities with only name
|
157
218
|
|
158
219
|
While listing cities three additional parameters can be sent ```alphabetically_sorted```, ```metropolitan_municipality``` and ```region```. All parameters can be sent separately and together.
|
159
220
|
|
221
|
+
<details>
|
222
|
+
<summary>Expand</summary>
|
223
|
+
|
160
224
|
```rb
|
161
225
|
TurkishCities.list_cities({ alphabetically_sorted: true })
|
162
226
|
# => ["Adana", "Adıyaman" ... "Yalova", "Yozgat", "Zonguldak"]
|
@@ -171,11 +235,15 @@ TurkishCities.list_cities({ metropolitan_municipality: true, region: 'Karadeniz'
|
|
171
235
|
TurkishCities.list_cities({ alphabetically_sorted: true, metropolitan_municipality: true })
|
172
236
|
# => ["Adana", "Ankara" ... "Tekirdağ", "Trabzon", "Van"]
|
173
237
|
```
|
238
|
+
</details>
|
174
239
|
|
175
240
|
### Listing all cities with other parameters
|
176
241
|
|
177
242
|
While listing cities ```with``` parameter can be used for listing cities with other attributes. These parameters are ```alphabetically_sorted```, ```metropolitan_municipality``` and ```region```. All parameters can be sent separately and together.
|
178
243
|
|
244
|
+
<details>
|
245
|
+
<summary>Expand</summary>
|
246
|
+
|
179
247
|
```rb
|
180
248
|
TurkishCities.list_cities({ alphabetically_sorted: true, with: { phone_code: true } })
|
181
249
|
# => [{:name=>"Adana", :phone_code=>322}, {:name=>"Adıyaman", :phone_code=>416}, {:name=>"Afyon", :phone_code=>272} .
|
@@ -189,11 +257,15 @@ TurkishCities.list_cities({ metropolitan_municipality: true, region: 'Karadeniz'
|
|
189
257
|
# :metropolitan_municipality_since=>1993, :region=>"Karadeniz"}, {:name=>"Trabzon", :plate_number=>61,
|
190
258
|
# :phone_code=>462, :metropolitan_municipality_since=>2012, :region=>"Karadeniz"}]
|
191
259
|
```
|
260
|
+
</details>
|
192
261
|
|
193
262
|
### Listing all districts of given city
|
194
263
|
|
195
264
|
City name can be given case and turkish character insensitive. Listing of districts are alphabetically sorted.
|
196
265
|
|
266
|
+
<details>
|
267
|
+
<summary>Expand</summary>
|
268
|
+
|
197
269
|
```rb
|
198
270
|
TurkishCities.list_districts('Ankara')
|
199
271
|
# => ["Akyurt", "Altındağ" ... "Sincan", "Şereflikoçhisar", "Yenimahalle"]
|
@@ -208,11 +280,15 @@ TurkishCities.list_districts('Istanbul').length
|
|
208
280
|
TurkishCities.list_districts('filansehir')
|
209
281
|
# => "Couldn't find city name with 'filansehir'"
|
210
282
|
```
|
283
|
+
</details>
|
211
284
|
|
212
285
|
### Listing all subdistricts of given city and district
|
213
286
|
|
214
287
|
City name can be given case and turkish character insensitive. District name should be case and turkish character sensitive.(Correct district names can be obtained by ```list_districts``` method.) Listing of subdistricts are alphabetically sorted.
|
215
288
|
|
289
|
+
<details>
|
290
|
+
<summary>Expand</summary>
|
291
|
+
|
216
292
|
```rb
|
217
293
|
TurkishCities.list_subdistricts('Adana', 'Seyhan')
|
218
294
|
# => ["Akkapı", "Denizli" ... "Yeşiloba", "Yeşilyurt", "Ziyapaşa"]
|
@@ -226,12 +302,17 @@ TurkishCities.list_subdistricts('İstanbul', 'Kadılarköyü')
|
|
226
302
|
# => "Couldn't find district name with 'Kadılarköyü' of 'İstanbul'"
|
227
303
|
```
|
228
304
|
|
305
|
+
</details>
|
306
|
+
|
229
307
|
### Listing all neighborhoods of given city and district
|
230
308
|
|
231
309
|
### With subdistrict info
|
232
310
|
|
233
311
|
City name can be given case and turkish character insensitive. District name and subdistrict name should be case and turkish character sensitive.(Correct district names can be obtained by the ```list_districts``` method. Correct subdistrict names can be obtained by ```list_subdistricts``` method.) Listings of neighborhoods are alphabetically sorted.
|
234
312
|
|
313
|
+
<details>
|
314
|
+
<summary>Expand</summary>
|
315
|
+
|
235
316
|
```rb
|
236
317
|
TurkishCities.list_neighborhoods('Adana', 'Seyhan', 'Emek')
|
237
318
|
# => ["Emek Mah", "Ova Mah", "Şakirpaşa Mah", "Uçak Mah"]
|
@@ -244,6 +325,7 @@ TurkishCities.list_neighborhoods('Adana', 'Beşiktaş', 'Emek')
|
|
244
325
|
TurkishCities.list_neighborhoods('Eskişehir', 'Odunpazarı', 'Büyükkkkkdere')
|
245
326
|
# => "Couldn't find subdistrict with 'Büyükkkkkdere' of 'Odunpazarı'/'Eskişehir'"
|
246
327
|
```
|
328
|
+
</details>
|
247
329
|
|
248
330
|
### Without subdistrict info
|
249
331
|
|
@@ -251,6 +333,9 @@ Also ```list_neighborhoods``` can work without subdistrict information. This tim
|
|
251
333
|
|
252
334
|
City name can be given case and turkish character insensitive. District name should be case and turkish character sensitive.(Correct district names can be obtained by the ```list_districts``` method.) Listings of neighborhoods are alphabetically sorted.
|
253
335
|
|
336
|
+
<details>
|
337
|
+
<summary>Expand</summary>
|
338
|
+
|
254
339
|
```rb
|
255
340
|
TurkishCities.list_neighborhoods('Adana', 'Seyhan')
|
256
341
|
# => ["2000 Evler Mah", "Ahmet Remzi Yüreğir Mah", "Akkapı Mah" ... "Zeytinli Mah", "Ziyapaşa Mah"]
|
@@ -261,11 +346,15 @@ TurkishCities.list_neighborhoods('Istanbul', 'Beşiktaş')
|
|
261
346
|
TurkishCities.list_neighborhoods('İstanbul', 'filanmevki')
|
262
347
|
# => "Couldn't find district name with 'filanmevki' of 'İstanbul'"
|
263
348
|
```
|
349
|
+
</details>
|
264
350
|
|
265
351
|
### Finding city, district and subdistrict name by postcode
|
266
352
|
|
267
353
|
In Turkey postcodes are uniq for subdistricts. Basically when a postcode is search through ```find_by_postcode``` it will give city, district and subdistrict information of postcode if valid and found
|
268
354
|
|
355
|
+
<details>
|
356
|
+
<summary>Expand</summary>
|
357
|
+
|
269
358
|
```rb
|
270
359
|
TurkishCities.find_by_postcode(34380) # => ["İstanbul", "Şişli", "Cumhuriyet"]
|
271
360
|
TurkishCities.find_by_postcode(34433) # => ["İstanbul", "Beyoğlu", "Cihangir"]
|
@@ -273,6 +362,172 @@ TurkishCities.find_by_postcode('26040') # => ["Eskişehir", "Odunpazarı", "Bü
|
|
273
362
|
TurkishCities.find_by_postcode(34382) # => "Couldn't find any subdistrict with postcode '34382'"
|
274
363
|
TurkishCities.find_by_postcode('100000') # => Given value [100000] is outside bounds of 1010 to 81952.
|
275
364
|
```
|
365
|
+
</details>
|
366
|
+
|
367
|
+
### Finding city name with elevation data
|
368
|
+
|
369
|
+
The lowest possible altitude for a city in Turkey is 4 meters with Kocaeli. The highest possible altitude is 1923 meters with Erzurum. Being far outside of the range may give errors.
|
370
|
+
|
371
|
+
### Below given
|
372
|
+
|
373
|
+
Search city name with below elevation
|
374
|
+
|
375
|
+
<details>
|
376
|
+
<summary>Expand</summary>
|
377
|
+
|
378
|
+
```rb
|
379
|
+
TurkishCities.find_by_elevation('below', 10)
|
380
|
+
# => ["İzmir", "Kocaeli", "Yalova"]
|
381
|
+
TurkishCities.find_by_elevation('below', 50)
|
382
|
+
# => ["Adana", "Çanakkale" ... "Bartın", "Yalova"]
|
383
|
+
TurkishCities.find_by_elevation('below', 500)
|
384
|
+
# => ["Adana", "Amasya" ... "Karabük", "Osmaniye", "Düzce"]
|
385
|
+
TurkishCities.find_by_elevation('below', 2213)
|
386
|
+
# => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "Düzce"]
|
387
|
+
TurkishCities.find_by_elevation('woleb', 213)
|
388
|
+
# => ArgumentError: "Elevation type 'woleb' is unsupported"
|
389
|
+
TurkishCities.find_by_elevation('below', 1)
|
390
|
+
# => RangeError: Given value [1] is outside bounds of 3 to Infinity
|
391
|
+
```
|
392
|
+
</details>
|
393
|
+
|
394
|
+
### Above given
|
395
|
+
|
396
|
+
Search city name with above elevation
|
397
|
+
|
398
|
+
<details>
|
399
|
+
<summary>Expand</summary>
|
400
|
+
|
401
|
+
```rb
|
402
|
+
TurkishCities.find_by_elevation('above', 0)
|
403
|
+
# => ["Adana", "Adıyaman" ... "Osmaniye", "Düzce"]
|
404
|
+
TurkishCities.find_by_elevation('above', 100)
|
405
|
+
# => ["Adıyaman", "Afyon" ... "Osmaniye", "Düzce"]
|
406
|
+
TurkishCities.find_by_elevation('above', 500)
|
407
|
+
# => ["Adıyaman", "Afyon" ... "Iğdır", "Kilis"]
|
408
|
+
TurkishCities.find_by_elevation('above', 1750)
|
409
|
+
# => ["Erzurum", "Hakkari", "Kars", "Ardahan"]
|
410
|
+
TurkishCities.find_by_elevation('abov', 1000)
|
411
|
+
# => ArgumentError: "Elevation type 'abov' is unsupported"
|
412
|
+
TurkishCities.find_by_elevation('above', 2000)
|
413
|
+
# => RangeError: Given value [2000] is outside bounds of 0 to 1924
|
414
|
+
```
|
415
|
+
</details>
|
416
|
+
|
417
|
+
### Between search
|
418
|
+
|
419
|
+
Search city name with between elevation
|
420
|
+
|
421
|
+
<details>
|
422
|
+
<summary>Expand</summary>
|
423
|
+
|
424
|
+
```rb
|
425
|
+
TurkishCities.find_by_elevation('between', 50, 100)
|
426
|
+
# => ["Antalya", "Aydın", "Hatay", "Manisa"]
|
427
|
+
TurkishCities.find_by_elevation('between', 100, 250)
|
428
|
+
# => ["Balıkesir", "Bursa", "Kırklareli", "Osmaniye", "Düzce"]
|
429
|
+
TurkishCities.find_by_elevation('between', 250, 1000)
|
430
|
+
# => ["Adıyaman", "Amasya" ... "Karabük", "Kilis"]
|
431
|
+
TurkishCities.find_by_elevation('between', 0, 2000)
|
432
|
+
# => ["Adana", "Adıyaman" ... "Osmaniye", "Düzce"]
|
433
|
+
TurkishCities.find_by_elevation('between', 2000, 5000)
|
434
|
+
# => []
|
435
|
+
```
|
436
|
+
</details>
|
437
|
+
|
438
|
+
### Finding city name with population data
|
439
|
+
|
440
|
+
The least populated city in Turkey is Tunceli with 83645. The highest populated is Istanbul with 15840900. Being far outside of the range may give errors.
|
441
|
+
|
442
|
+
### Exact search
|
443
|
+
|
444
|
+
Search city name with exact population
|
445
|
+
|
446
|
+
<details>
|
447
|
+
<summary>Expand</summary>
|
448
|
+
|
449
|
+
```rb
|
450
|
+
TurkishCities.find_by_population('exact', 15840900)
|
451
|
+
# => ["İstanbul"]
|
452
|
+
TurkishCities.find_by_population('exact', 104320)
|
453
|
+
# => "Couldn't find any city with population data"
|
454
|
+
TurkishCities.find_by_population('exatc', 2130432)
|
455
|
+
# => "Population type 'exatc' is unsupported"
|
456
|
+
TurkishCities.find_by_population('exact', 10432)
|
457
|
+
# => Given value [10432] is outside bounds of 83644 to 15840901
|
458
|
+
TurkishCities.find_by_population('exact', 22130432)
|
459
|
+
# => Given value [22130432] is outside bounds of 83644 to 15840901
|
460
|
+
```
|
461
|
+
</details>
|
462
|
+
|
463
|
+
### Below given
|
464
|
+
|
465
|
+
Search city name with below population
|
466
|
+
|
467
|
+
<details>
|
468
|
+
<summary>Expand</summary>
|
469
|
+
|
470
|
+
```rb
|
471
|
+
TurkishCities.find_by_population('below', 86000)
|
472
|
+
# => ["Tunceli", "Bayburt"]
|
473
|
+
TurkishCities.find_by_population('below', 500000)
|
474
|
+
# => ["Amasya", "Artvin" ... "Kilis", "Düzce"]
|
475
|
+
TurkishCities.find_by_population('below', 1000000)
|
476
|
+
# => ["Adıyaman", "Afyon" ... "Kilis", "Osmaniye", "Düzce"]
|
477
|
+
TurkishCities.find_by_population('below', 22130432)
|
478
|
+
# => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "Düzce"]
|
479
|
+
TurkishCities.find_by_population('woleb', 2130432)
|
480
|
+
# => "Population type 'woleb' is unsupported"
|
481
|
+
TurkishCities.find_by_population('below', 10432)
|
482
|
+
# => Given value [10432] is outside bounds of 83644 to Infinity
|
483
|
+
```
|
484
|
+
</details>
|
485
|
+
|
486
|
+
### Above given
|
487
|
+
|
488
|
+
Search city name with above population
|
489
|
+
|
490
|
+
<details>
|
491
|
+
<summary>Expand</summary>
|
492
|
+
|
493
|
+
```rb
|
494
|
+
TurkishCities.find_by_population('above', 860000)
|
495
|
+
# => ["Adana", "Ankara" ... "Şanlıurfa", "Van"]
|
496
|
+
TurkishCities.find_by_population('above', 2500000)
|
497
|
+
# => ["Ankara", "Antalya", "Bursa", "İstanbul", "İzmir"]
|
498
|
+
TurkishCities.find_by_population('above', 5000000)
|
499
|
+
# => ["Ankara", "İstanbul"]
|
500
|
+
TurkishCities.find_by_population('above', 10432)
|
501
|
+
# => ["Adana", "Adıyaman" ... "Kilis", "Osmaniye", "Düzce"]
|
502
|
+
TurkishCities.find_by_population('abov', 2130432)
|
503
|
+
# => "Population type 'abov' is unsupported"
|
504
|
+
TurkishCities.find_by_population('above', 22130432)
|
505
|
+
# => Given value [22130432] is outside bounds of 0 to 15840901
|
506
|
+
```
|
507
|
+
</details>
|
508
|
+
|
509
|
+
### Between search
|
510
|
+
|
511
|
+
Search city name with between population
|
512
|
+
|
513
|
+
<details>
|
514
|
+
<summary>Expand</summary>
|
515
|
+
|
516
|
+
```rb
|
517
|
+
TurkishCities.find_by_population('between', 15840901, 3000000)
|
518
|
+
# => ["Ankara", "Bursa", "İstanbul", İzmir"]
|
519
|
+
TurkishCities.find_by_population('between', 828369, 985732)
|
520
|
+
# => ["Eskişehir", "Mardin"]
|
521
|
+
TurkishCities.find_by_population('between', 2130432, 3500000)
|
522
|
+
# => ["Adana", "Antalya", "Bursa", "Konya", "Şanlıurfa"]
|
523
|
+
TurkishCities.find_by_population('between', 10432, 100000)
|
524
|
+
# => ["Tunceli", "Bayburt", "Ardahan"]
|
525
|
+
TurkishCities.find_by_population('between', 11304320, 34000000)
|
526
|
+
# => ["İstanbul"]
|
527
|
+
TurkishCities.find_by_population('between', 100000, 100001)
|
528
|
+
# => "Couldn't find any city with population data"
|
529
|
+
```
|
530
|
+
</details>
|
276
531
|
|
277
532
|
### Finding travel distance and time estimation between two cities
|
278
533
|
|
@@ -280,6 +535,9 @@ TurkishCities.find_by_postcode('100000') # => Given value [100000] is outside bo
|
|
280
535
|
|
281
536
|
City names can be given case and turkish character insensitive. Travel method should be lower case. Array with 2 elements will be returned. First element is distance between cities in kilometers and the second element is the description created by the first element.
|
282
537
|
|
538
|
+
<details>
|
539
|
+
<summary>Expand</summary>
|
540
|
+
|
283
541
|
```rb
|
284
542
|
TurkishCities.distance_between('Eskişehir', 'Kastamonu', 'land')
|
285
543
|
# => [480, "Land travel distance between Eskişehir and Kastamonu is 480 km."]
|
@@ -294,11 +552,15 @@ TurkishCities.distance_between('Adana', 'Adıyaman', 'time')
|
|
294
552
|
TurkishCities.distance_between('filansa', 'falansa', 'land')
|
295
553
|
# => "Couldn't find cities combination with 'filansa/falansa'"
|
296
554
|
```
|
555
|
+
</details>
|
297
556
|
|
298
557
|
### By air
|
299
558
|
|
300
559
|
City names can be given case and turkish character insensitive. Travel method should be lower case. Array with 3 elements will be returned. First element is distance between cities in kilometers, the second element is estimated travel time and the last element is the description created by the first two elements.
|
301
560
|
|
561
|
+
<details>
|
562
|
+
<summary>Expand</summary>
|
563
|
+
|
302
564
|
```rb
|
303
565
|
TurkishCities.distance_between('Eskişehir', 'Kastamonu', 'air')
|
304
566
|
# => [327.74, 62, "Air travel distance between Eskişehir and Kastamonu is 327.74 km. Estimated air travel would take 62 minutes."]
|
@@ -313,6 +575,7 @@ TurkishCities.distance_between('Adana', 'Adıyaman', 'time')
|
|
313
575
|
TurkishCities.distance_between('filansa', 'falansa', 'air')
|
314
576
|
# => "Couldn't find cities combination with 'filansa/falansa'"
|
315
577
|
```
|
578
|
+
</details>
|
316
579
|
|
317
580
|
## Data sources
|
318
581
|
|
@@ -322,11 +585,12 @@ All information related with cities can be found at:
|
|
322
585
|
https://tr.wikipedia.org/wiki/{#city_name_here}
|
323
586
|
```
|
324
587
|
|
325
|
-
Districts, subdisctricts, neighborhoods and postcodes can be found at:
|
588
|
+
Districts, subdisctricts, neighborhoods and postcodes information can be found at:
|
326
589
|
|
327
590
|
```
|
328
591
|
https://postakodu.ptt.gov.tr/
|
329
592
|
```
|
593
|
+
All districts/subdistricts are up to date at: 23 January 2022 with using PTT file released at 22 November 2021
|
330
594
|
|
331
595
|
Land distance information can be found at:
|
332
596
|
|
@@ -334,6 +598,13 @@ Land distance information can be found at:
|
|
334
598
|
https://www.kgm.gov.tr/SiteCollectionDocuments/KGMdocuments/Root/Uzakliklar/ilmesafe.xls
|
335
599
|
```
|
336
600
|
|
601
|
+
Population of cities are up to date as 15 February 2022 as using February 2022 report of Türkiye İstatistik Kurumu (TÜİK) / Turkish Statistical Institute (TURKSTAT)
|
602
|
+
|
603
|
+
Statistics for gem can be found at:
|
604
|
+
```
|
605
|
+
https://bestgems.org/gems/turkish_cities
|
606
|
+
```
|
607
|
+
|
337
608
|
## Compatibility
|
338
609
|
|
339
610
|
| Ruby Version | Supported |
|
@@ -377,5 +648,5 @@ The logo is licensed under a
|
|
377
648
|
|
378
649
|
## Copyright
|
379
650
|
|
380
|
-
Copyright (c) 2020 Semih Arslanoglu. See [LICENSE.txt](LICENSE.txt) for
|
651
|
+
Copyright (c) 2020 - 2022 Semih Arslanoglu. See [LICENSE.txt](LICENSE.txt) for
|
381
652
|
further details.
|
data/Rakefile
ADDED
@@ -5,11 +5,14 @@ en:
|
|
5
5
|
errors:
|
6
6
|
cities_not_found_error: "Couldn't find cities combination with '%{first}/%{second}'"
|
7
7
|
city_not_found_error: "Couldn't find city name with '%{input}'"
|
8
|
+
city_population_not_found_error: "Couldn't find any city with population data"
|
8
9
|
district_not_found_error: "Couldn't find district name with '%{district_input}' of '%{city_input}'"
|
9
10
|
not_even_input: "Given value [%{input}] must be an even number"
|
10
11
|
outside_bounds: "Given value [%{input}] is outside bounds of %{min} to %{max}"
|
11
12
|
postcode_not_found_error: "Couldn't find any subdistrict with postcode '%{postcode_input}'"
|
12
13
|
subdistrict_not_found_error: "Couldn't find subdistrict with '%{subdistrict_input}' of '%{district_input}'/'%{city_input}'"
|
14
|
+
unsupported_elevation_type: "Elevation type '%{input}' is unsupported"
|
15
|
+
unsupported_population_type: "Population type '%{input}' is unsupported"
|
13
16
|
unsupported_travel_method: "Travel method '%{input}' is unsupported"
|
14
17
|
language:
|
15
18
|
errors:
|
@@ -5,11 +5,14 @@ tr:
|
|
5
5
|
errors:
|
6
6
|
cities_not_found_error: "'%{first}/%{second}' ile şehir kombinasyonu bulunamadı"
|
7
7
|
city_not_found_error: "'%{input}' ile bir şehir bulunamadı"
|
8
|
+
city_population_not_found_error: "Verilen nüfus verisi ile şehir bulunamadı"
|
8
9
|
district_not_found_error: "'%{city_input}' şehrine ait '%{district_input}' ilçesi ile bir kayıt bulunamadı"
|
9
10
|
not_even_input: "Girilen değer [%{input}] çift sayı olmalı"
|
10
11
|
outside_bounds: "Girilen değer [%{input}] %{min} ile %{max} değerleri dışında"
|
11
12
|
postcode_not_found_error: "'%{postcode_input}' posta kodu ile kayıt bulunamadı"
|
12
13
|
subdistrict_not_found_error: "'%{subdistrict_input}' ile '%{district_input}'/'%{city_input}' ait bir kayıt bulunamdı"
|
14
|
+
unsupported_elevation_type: "'%{input}' ile rakım arama desteklenmiyor"
|
15
|
+
unsupported_population_type: "'%{input}' ile nüfus arama desteklenmiyor"
|
13
16
|
unsupported_travel_method: "'%{input}' yolculuk methodu desteklenmiyor"
|
14
17
|
language:
|
15
18
|
errors:
|