worlddb 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/Manifest.txt +18 -0
  2. data/db/america/ca/cities.txt +40 -7
  3. data/db/america/ca/regions.txt +28 -10
  4. data/db/america/mx/cities.txt +32 -15
  5. data/db/america/mx/regions.txt +54 -0
  6. data/db/america/us/cities.txt +46 -16
  7. data/db/america/us/regions.txt +64 -10
  8. data/db/europe/at/cities.txt +30 -17
  9. data/db/europe/at/regions.txt +19 -10
  10. data/db/europe/be/cities.txt +19 -1
  11. data/db/europe/be/regions.txt +21 -0
  12. data/db/europe/bg/cities.txt +4 -0
  13. data/db/europe/by/cities.txt +3 -0
  14. data/db/europe/ch/cities.txt +3 -0
  15. data/db/europe/countries.txt +62 -39
  16. data/db/europe/cz/cities.txt +26 -0
  17. data/db/europe/cz/regions.txt +32 -0
  18. data/db/europe/de/cities.txt +44 -18
  19. data/db/europe/de/regions.txt +16 -16
  20. data/db/europe/dk/cities.txt +5 -0
  21. data/db/europe/ee/cities.txt +2 -0
  22. data/db/europe/en/cities.txt +36 -13
  23. data/db/europe/en/regions.txt +21 -0
  24. data/db/europe/es/cities.txt +17 -5
  25. data/db/europe/es/regions.txt +26 -0
  26. data/db/europe/fi/cities.txt +2 -0
  27. data/db/europe/fr/cities.txt +15 -4
  28. data/db/europe/fr/regions.txt +32 -0
  29. data/db/europe/gr/cities.txt +5 -0
  30. data/db/europe/hu/cities.txt +2 -0
  31. data/db/europe/ie/cities.txt +3 -0
  32. data/db/europe/it/cities.txt +16 -3
  33. data/db/europe/lt/cities.txt +4 -0
  34. data/db/europe/lv/cities.txt +3 -0
  35. data/db/europe/nl/cities.txt +11 -2
  36. data/db/europe/no/cities.txt +3 -0
  37. data/db/europe/pl/cities.txt +12 -0
  38. data/db/europe/pt/cities.txt +5 -2
  39. data/db/europe/ro/cities.txt +3 -0
  40. data/db/europe/rs/cities.txt +3 -0
  41. data/db/europe/ru/cities.txt +14 -2
  42. data/db/europe/sc/cities.txt +3 -1
  43. data/db/europe/se/cities.txt +3 -0
  44. data/db/europe/tr/cities.txt +3 -1
  45. data/db/europe/ua/cities.txt +9 -3
  46. data/lib/worlddb/console.rb +11 -9
  47. data/lib/worlddb/reader.rb +40 -3
  48. data/lib/worlddb/readers/values_reader.rb +12 -4
  49. data/lib/worlddb/schema.rb +18 -3
  50. data/lib/worlddb/version.rb +1 -1
  51. data/lib/worlddb.rb +23 -3
  52. metadata +40 -4
@@ -0,0 +1,26 @@
1
+
2
+
3
+ # top 10 cities
4
+
5
+ praha, Praha [Prague], region:pr, 1_290_846, m:1_265_000
6
+ brno, Brno, region:jm, 384_277
7
+ ostrava, Ostrava, region:mo, 302_456
8
+ plzen, Plzeň [Pilsen], region:pl, 169_688
9
+ liberec, Liberec, region:li, 102_247
10
+ olomouc, Olomouc, region:ol, 100_043
11
+ ustinadlabem, Ústí nad Labem, region:us, 95_003
12
+ hradeckralove, Hradec Králové, region:kr, 94_242
13
+ budejovice, České Budějovice [Budweis], region:jc, 93_883
14
+ pardubice, Pardubice, region:pa, 91_073
15
+
16
+
17
+ # more cities/towns
18
+
19
+ karlovyvary, Karlovy Vary [Carlsbad], region:ka, 53_737
20
+ kutnahora, Kutná Hora, region:st, 20_839
21
+
22
+ tabor, Tábor, region:jc, 35_769
23
+ krumlov, Český Krumlov region:jc, 13_752
24
+ trebon, Třeboň, region:jc, 8_840
25
+
26
+ mikulov, Mikulov, region:jm, 7_624
@@ -0,0 +1,32 @@
1
+
2
+ ###
3
+ ## 14 regions
4
+ ##
5
+ ## see http://en.wikipedia.org/wiki/Regions_of_the_Czech_Republic
6
+
7
+
8
+ ### NB: using official two letter iso 3166-2 cz region codes
9
+ ## see http://en.wikipedia.org/wiki/ISO_3166-2:CZ
10
+
11
+
12
+ pr, Praha [Prague], 496
13
+ st, Střední Čechy [Central Bohemia], 11_015, central bohemia
14
+
15
+ jc, Jižní Čechy [South Bohemia], 10_057, southwest
16
+ pl, Plzeň, 7_561, southwest
17
+
18
+ ka, Karlovy Vary, 3_315, northwest
19
+ us, Ústí nad Labem, 5_335, northwest
20
+
21
+ li, Liberec, 3_163, northeast
22
+ kr, Hradec Králové, 4_758, northeast
23
+ pa, Pardubice, 4_519, northeast
24
+
25
+ jm, Jižní Morava [South Moravia], 7_067, southeast
26
+ vy, Vysočina, 6_926, southeast
27
+
28
+ ol, Olomouc, 5_159, central moravia
29
+ zl, Zlín, 3_964, central moravia
30
+
31
+ mo, Moravskoslezsko [Moravia-Silesia], 5_535
32
+
@@ -1,18 +1,44 @@
1
- muenchen, München, region:by
2
- nuernberg, Nürnberg, region:by
3
- augsburg, Augsburg, region:by
4
- fuerth, Fürth, region:by
5
- stuttgart, Stuttgart, region:bw
6
- hoffenheim, Hoffenheim, region:bw
7
- freiburg, Freiburg, region:bw
8
- hannover, Hannover, region:ni
9
- wolfsburg, Wolfsburg, region:ni
10
- gelsenkirchen, Gelsenkirchen, region:nw
11
- dortmund, Dortmund, region:nw
12
- leverkusen, Leverkusen, region:nw
13
- duesseldorf, Düsseldorf, region:nw
14
- mgladbach, Mönchengladbach|Mgladbach, region:nw
15
- frankfurt, Frankfurt, region:he
16
- mainz, Mainz, region:rp
17
- hamburg, Hamburg, region:hh
18
- bremen, Bremen, region:hb
1
+ # Top metros (metropolitan areas/urban areas - includes metro/urban area beyond proper city limits)
2
+
3
+ ####
4
+ ## source metro/urban
5
+ ## - http://en.wikipedia.org/wiki/Largest_urban_areas_of_the_European_Union
6
+
7
+
8
+ ruhr, Ruhrgebiet [Ruhr area], region:nw, m:7_304_000, metro , # includes essen, bochum, dortmund, gelsenkirchen
9
+ koelnbonn, Köln/Bonn [Cologne-Bonn], region:nw, m:2_063_000, metro , # includes koeln, leverkusen, bergischgladbach, bonn
10
+
11
+
12
+ # Top 10 cities
13
+
14
+ berlin, Berlin, region:be, 3_501_872, m:3_453_000
15
+ hamburg, Hamburg, region:hh, 1_798_836, m:1_794_000
16
+ muenchen, München [Munich], region:by, 1_378_176, m:1_355_000
17
+ koeln, Köln, region:nw, 1_017_155, metro:koelnbonn,
18
+ frankfurt, Frankfurt, region:he, 691_518 m:2_300_000 , # frankfurt metro includes wiesbaden, darmstadt
19
+ stuttgart, Stuttgart, region:bw, 613_392, m:1_272_000
20
+ duesseldorf, Düsseldorf, region:nw, 592_393
21
+ dortmund, Dortmund, region:nw, 580_956, metro:ruhr
22
+ essen, Essen, region:nw, 573_468, metro:ruhr
23
+ bremen, Bremen, region:hb, 548_319
24
+
25
+
26
+ duisburg, Duisburg, region:nw, 513_400, metro:ruhr
27
+ leipzig, Leipzig, region:sn, 486_100
28
+ dresden, Dresden, region:sn, 473_300
29
+ bochum, Bochum, region:nw, 388_100, metro:ruhr
30
+ bonn, Bonn, region:nw, 307_500, metro:koelnbonn
31
+
32
+ # more cities
33
+
34
+ nuernberg, Nürnberg [Nuremberg], region:by, 510_602, m:1_020_000
35
+ augsburg, Augsburg, region:by, 266_647
36
+ fuerth, Fürth, region:by, 116_317
37
+ hoffenheim, Hoffenheim, region:bw, 3_272
38
+ freiburg, Freiburg, region:bw, 229_144
39
+ hannover, Hannover, region:ni, 525_875
40
+ wolfsburg, Wolfsburg, region:ni, 122_583
41
+ gelsenkirchen, Gelsenkirchen, region:nw, 256_652, metro:ruhr
42
+ leverkusen, Leverkusen, region:nw, 161_195, metro:koelnbonn
43
+ mgladbach, Mönchengladbach|M'gladbach, region:nw, 257_208
44
+ mainz, Mainz, region:rp, 200_957
@@ -1,16 +1,16 @@
1
- bw, Baden-Württemberg
2
- by, Bayern
3
- be, Berlin
4
- bb, Brandenburg
5
- hb, Bremen
6
- hh, Hamburg
7
- he, Hessen
8
- mv, Mecklenburg-Vorpommern
9
- ni, Niedersachsen
10
- nw, Nordrhein-Westfalen
11
- rp, Rheinland-Pfalz
12
- sl, Saarland
13
- sn, Sachsen
14
- st, Sachsen-Anhalt
15
- sh, Schleswig-Holstein
16
- th, Thüringen
1
+ bw, Baden-Württemberg, 35_752
2
+ by, Bayern [Bavaria], 70_552
3
+ be, Berlin, 892
4
+ bb, Brandenburg, 29_479
5
+ hb, Bremen, 419
6
+ hh, Hamburg, 755
7
+ he, Hessen [Hesse], 21_115
8
+ mv, Mecklenburg-Vorpommern, 23_180
9
+ ni, Niedersachsen [Lower Saxony], 47_609
10
+ nw, Nordrhein-Westfalen [North Rhine-Westphalia], 34_085
11
+ rp, Rheinland-Pfalz [Rhineland-Palatinate], 19_853
12
+ sl, Saarland , 2_569
13
+ sn, Sachsen [Saxony], 18_416
14
+ st, Sachsen-Anhalt [Saxony-Anhalt], 20_446
15
+ sh, Schleswig-Holstein, 15_799
16
+ th, Thüringen [Thuringia], 16_172
@@ -1 +1,6 @@
1
+
2
+
3
+ kobenhavn, København [Copenhagen], m:1_181_000
4
+
5
+
1
6
  farum, Farum
@@ -0,0 +1,2 @@
1
+
2
+ tallinn, Tallinn, 418_107
@@ -1,13 +1,36 @@
1
- manchester, Manchester
2
- london, London
3
- liverpool, Liverpool
4
- birmingham, Birmingham, # e.g.Aston Villa
5
- westbrom, West Bromwich
6
- newcastle, Newcastle upon Tyne
7
- stoke, Stoke-on-Trent
8
- sunderland, Sunderland
9
- wigan, Wigan
10
- southampton, Southampton
11
- reading, Reading
12
- norwich, Norwich
13
- swansea, Swansea
1
+ # metros
2
+
3
+ leedsbradford, Leeds-Bradford, region:yh, m:1_541_000, metro
4
+
5
+
6
+ # top cities
7
+
8
+ london, London, region:gl, 7_619_800, m:8_586_000
9
+ birmingham, Birmingham, region:wm, 1_010_400, m:2_294_000
10
+ liverpool, Liverpool, region:nw, 469_017, m:819_000
11
+ leeds, Leeds, region:yh, 443_247, metro:leedsbradford
12
+ sheffield, Sheffield, region:yh, 439_866
13
+ bristol, Bristol, region:sw, 420_556
14
+ manchester, Manchester, region:nw, 394_269, m:2_244_000
15
+ leicester, Leicester, region:em, 330_574
16
+ coventry, Coventry, region:wm, 303_475
17
+ kingston, Kingston upon Hull, region:yh, 301_416
18
+ bradford, Bradford, region:yh, 293_717, metro:leedsbradford
19
+
20
+
21
+ # more cities
22
+
23
+ westbrom, West Bromwich, region:wm, 136940
24
+ newcastle, Newcastle upon Tyne, region:ne, 280200, m:892_000
25
+ stoke, Stoke-on-Trent, region:wm, 249000
26
+ sunderland, Sunderland, region:ne, 177739
27
+ wigan, Wigan, region:nw, 81203
28
+ southampton, Southampton, region:se, 239700
29
+ reading, Reading, region:se, 155700
30
+ norwich, Norwich, region:ee, 140200
31
+
32
+ ####
33
+ ## from wales; keep it here (w/ england?) add it to gb - great britain?
34
+
35
+ swansea, Swansea, region:wa, 239000
36
+
@@ -0,0 +1,21 @@
1
+
2
+ ####
3
+ ## todo: check what abbrevations to use for regions?
4
+ ##
5
+ ## see http://en.wikipedia.org/wiki/Regions_of_England
6
+ ##
7
+ ## make regions into tags? and use smaller admin units?
8
+
9
+
10
+ ne, North East England
11
+ nw, North West England
12
+ yh, Yorkshire and the Humber
13
+ em, East Midlands
14
+ wm, West Midlands
15
+ ee, East of England
16
+ gl, Greater London
17
+ se, South East England
18
+ sw, South West England
19
+
20
+ wa, Wales
21
+
@@ -1,5 +1,17 @@
1
- bilbao, Bilbao
2
- valencia, Valencia
3
- barcelona, Barcelona
4
- madrid, Madrid
5
- malaga, Málaga
1
+
2
+ ## top 10 cities
3
+
4
+ madrid, Madrid, region:md, 3_265_038, m:5_427_000
5
+ barcelona, Barcelona, region:ct, 1_615_448, m:4_223_000
6
+ valencia, Valencia, region:vc, 798_033, m:810_000
7
+ sevilla, Sevilla [Seville], region:an, 703_021, m:750_000
8
+ zaragoza, Zaragoza, region:ar, 674_725
9
+ malaga, Málaga, region:an, 568_030
10
+ murcia, Murcia, region:mc, 442_203
11
+ palma, Palma de Mallorca, region:ib, 405_318
12
+ laspalmas, Las Palmas (de Gran Canaria), region:cn, 383_343
13
+ bilbao, Bilbao, region:pv, 352_700, m:750_000
14
+
15
+
16
+ # more cities here
17
+
@@ -0,0 +1,26 @@
1
+
2
+ ########
3
+ # 17 autonomous communities (+2 autonomous cities)
4
+
5
+ an, Andalucía|Andalusia, 87598
6
+ ar, Aragón, 47720
7
+ as, Asturias, 10604
8
+ ib, Illes Balears|Balearic Islands, 4992
9
+ pv, Pais Vasco|Basque Country 7235
10
+ cn, Canarias|Canary Islands, 7447
11
+ cb, Cantábria, 5321
12
+ cl, Castilla y León, 94225
13
+ cm, Castilla-La Mancha, 79462
14
+ ct, Cataluña|Catalonia, 32113
15
+ ex, Extremadura, 41635
16
+ ga, Galicia, 29574
17
+ ri, La Rioja, 5045
18
+ md, Madrid, 8028
19
+ mc, Murcia, 11313
20
+ na, Navarra 10390
21
+ vc, Valencia, 23255
22
+
23
+ ## autonomous cities
24
+
25
+ ce, Ceuta, 19
26
+ ml, Melilla 13
@@ -0,0 +1,2 @@
1
+
2
+ helsingfors, Helsingfors [Helsinki], m:1_131_000
@@ -1,4 +1,15 @@
1
- lille, Lille
2
- paris, Paris
3
- marseille, Marseille
4
- montpellier, Montpellier
1
+ # top 10 cities
2
+
3
+ paris, Paris, region:if, 2_234_105, m:10_755_000
4
+ marseille, Marseille region:ac, 850_602, m: 1_582_000
5
+ lyon, Lyon, region:ra, 479_803, m: 1_542_000
6
+ toulouse, Toulouse, region:mp, 440_204, m: 880_000
7
+ nice, Nice, region:ac, 340_735, m: 962_000
8
+ nantes, Nantes, region:pl, 282_047
9
+ strasbourg, Strasbourg, region:al, 271_708
10
+ montpellier, Montpellier, region:lr, 255_080
11
+ bordeaux, Bordeaux, region:aq, 236_725, m:845_000
12
+ lille, Lille, region:nc, 226_827, m:1_050_000
13
+ rennes, Rennes, region:br, 206_604
14
+
15
+ # more cities
@@ -0,0 +1,32 @@
1
+
2
+ # NB: use 9 NUTS1 regions for tags
3
+
4
+
5
+ if, Ile-de-France, 12012, ile_de_france
6
+
7
+ ca, Champagne-Ardenne, 25606, bassin_parisien
8
+ pd, Picardie, 19399, bassin_parisien
9
+ hn, Haute-Normandie, 12317, bassin_parisien
10
+ ct, Centre, 39151, bassin_parisien
11
+ bn, Basse-Normandie, 17589, bassin_parisien
12
+ bg, Bourgogne, 31582, bassin_parisien
13
+
14
+ nc, Nord-Pas-de-Calais, 12414, nord_pas_de_calais
15
+
16
+ lr, Lorraine, 23547, est
17
+ al, Alsace, 8280, est
18
+ fc, Franche-Comté, 16202, est
19
+
20
+ pl, Pays de la Loire, 32082, ouest
21
+ br, Bretagne, 27208, ouest
22
+ pc, Poitou-Charentes, 25810, ouest
23
+ aq, Aquitaine, 41308, ouest
24
+ mp, Midi-Pyrénées, 45348, ouest
25
+ lm, Limousin, 16942, ouest
26
+
27
+ ra, Rhône-Alpes, 43698, centre_est
28
+ av, Auvergne, 26013, centre_est
29
+
30
+ lr, Languedoc-Roussillon, 27376, mediterranee
31
+ ac, Provence-Alpes-Côte d'Azur, 31400, mediterranee
32
+ cr, Corse, 8680, mediterranee
@@ -1 +1,6 @@
1
+
2
+ athina, Athína [Athens], m:3_269_000
3
+ thessaloniki, Thessaloniki, m:840_000
4
+
5
+
1
6
  piraeus, Piräus|Piraeus
@@ -0,0 +1,2 @@
1
+
2
+ budapest, Budapest, 1_733_685, m:1_727_000
@@ -0,0 +1,3 @@
1
+
2
+ dublin, Dublin, m:1_128_000
3
+
@@ -1,4 +1,17 @@
1
- turin, Turin
2
- milano, Mailand|Milano
3
- napoli, Neapel|Napoli
4
1
 
2
+
3
+ milano, Milano [Milan], 1_338_436, m:5_232_000
4
+ roma, Roma [Rome], 2_777_979, m:3_799_000
5
+ napoli, Napoli [Naples], 1_046_987, m:3_726_000
6
+ torino, Torino [Turin], 921_485, m:1_499_000
7
+ palermo, Palermo, 689_349, m:876_000
8
+ genova, Genova [Genoa], 655_704
9
+ bologna, Bologna, 385_813
10
+ firenze, Firenze [Florence], 381_762, m:821_000
11
+
12
+ catania, Catania, 341_685
13
+ bari, Bari, 335_647
14
+ venezia, Venezia [Venice], 297_743
15
+ messina, Messina, 262_524
16
+ verona, Verona, 254_146
17
+ trieste, Trieste, 222_589
@@ -0,0 +1,4 @@
1
+ ## Latvia cities
2
+
3
+ riga, Riga, 699_203, m:1_018_295
4
+
@@ -0,0 +1,3 @@
1
+ ## Lithuania Cities
2
+
3
+ vilnius, Vilnius, 554_060, m:838_852
@@ -1,2 +1,11 @@
1
- amsterdam, Amsterdam
2
- alkmaar, Alkmaar ## region: North Holland
1
+
2
+ # metros
3
+
4
+ rotterdamthehague, Rotterdam-The Hague, m:2_113_000
5
+
6
+
7
+ # cities
8
+
9
+ amsterdam, Amsterdam, m:1_050_000
10
+
11
+ alkmaar, Alkmaar, ## region: North Holland
@@ -0,0 +1,3 @@
1
+
2
+ oslo, Oslo, m:922_000
3
+
@@ -0,0 +1,12 @@
1
+
2
+ # metros
3
+
4
+ katowicemetro, Katowice (Upper-Silesian Metropolis), m:2_505_000, metro
5
+ gdansktri, Gdańsk (Tricity), m:775_000, metro # includes Gdańsk, Gdynia and Sopot
6
+
7
+ # cities
8
+
9
+ warszawa, Warszawa [Warsaw], 1_720_398, m:1_713_000
10
+ lodz, Łódź, m: 907_000
11
+ krakow, Kraków, m: 760_000
12
+
@@ -1,3 +1,6 @@
1
- porto, Porto
1
+
2
+ lisboa, Lissabon|Lisboa, m:3_051_000
3
+ porto, Porto, m:1_491_000
4
+
5
+
2
6
  braga, Braga
3
- lisboa, Lissabon|Lisboa
@@ -1 +1,4 @@
1
+
2
+ bucuresti, Bucuresti [Bucharest], 1_677_985, m:1_931_000
3
+
1
4
  cluj, Cluj
@@ -0,0 +1,3 @@
1
+
2
+ beograd, Beograd [Belgrade], 1_154_589, m:1_098_000
3
+
@@ -1,2 +1,14 @@
1
- moskva, Moskau|Moskva
2
- stpetersburg, St. Petersburg
1
+
2
+ moskva, Moskva [Moscow], 11_689_048, m:15_512_000
3
+ stpetersburg, St. Petersburg, 4_879_566, m:4_879_000
4
+
5
+ novgorod, Nizhni Novgorod, 1_250_615, m:1_248_000
6
+
7
+ samara, Samaram, 1_164_896, m:1_163_000
8
+ kazan, Kazan, 1_143_546, m:1_141_000
9
+
10
+ # Yekaterinburg 1_350_136 ??
11
+ # Chelyabinsk 1_130_273 ??
12
+
13
+
14
+
@@ -1 +1,3 @@
1
- glasgow, Glasgow
1
+
2
+ glasgow, Glasgow, m:1_201_000
3
+
@@ -0,0 +1,3 @@
1
+
2
+ stockholm, Stockholm, m:1_288_000
3
+
@@ -1 +1,3 @@
1
- istanbul, Istanbul
1
+
2
+ istanbul, Istanbul, 13_624_240, m:13_576_000
3
+
@@ -1,3 +1,9 @@
1
- kiev, Kiew|Kiev|Kyiv
2
- donetsk, Donezk|Donetsk
3
- kharkov, Kharkiv|Kharkov
1
+
2
+ kiev, Kiew|Kiev|Kyiv, 2_785_100, m:2_812_000
3
+ kharkov, Kharkiv|Kharkov, 1_470_000, m:1_449_000
4
+ donetsk, Donezk|Donetsk, m:963_000
5
+
6
+
7
+ dnepropetrovsk, Dnepropetrovsk, 1_007_200, m:1_000_000
8
+ odessa, Odessa, 1_003_705, m:1_010_000
9
+
@@ -49,19 +49,21 @@ puts "Ready."
49
49
 
50
50
  ##### some countries
51
51
 
52
- at = Country.find_by_key( 'at' )
53
- de = Country.find_by_key( 'de' )
54
- en = Country.find_by_key( 'en' )
52
+ # local variables (e.g. at) not working; use constants instead (e.g. AT)
55
53
 
56
- us = Country.find_by_key( 'us' )
57
- ca = Country.find_by_key( 'ca' )
58
- mx = Country.find_by_key( 'mx' )
54
+ AT = Country.find_by_key( 'at' )
55
+ DE = Country.find_by_key( 'de' )
56
+ EN = Country.find_by_key( 'en' )
57
+
58
+ US = Country.find_by_key( 'us' )
59
+ CA = Country.find_by_key( 'ca' )
60
+ MX = Country.find_by_key( 'mx' )
59
61
 
60
62
  ### some cities
61
63
 
62
- nyc = City.find_by_key( 'newyork' )
63
- lon = City.find_by_key( 'london' )
64
- vie = City.find_by_key( 'wien' )
64
+ NYC = City.find_by_key( 'newyork' )
65
+ LON = City.find_by_key( 'london' )
66
+ VIE = City.find_by_key( 'wien' )
65
67
 
66
68
  ## todo: add some predefined tags (e.g. europe, america, g8, euro, etc.)
67
69
 
@@ -140,6 +140,12 @@ private
140
140
  reader.each_line do |attribs, values|
141
141
 
142
142
  value_numbers = []
143
+
144
+ if clazz == City
145
+ attribs[ :c ] = true # assume city type by default (use metro,district to change in fixture)
146
+ elsif clazz == Country
147
+ attribs[ :c ] = true # assume country type by default (use supra,depend to change)
148
+ end
143
149
 
144
150
  ## check for optional values
145
151
  values.each_with_index do |value,index|
@@ -147,11 +153,42 @@ private
147
153
  value_region_key = value[7..-1] ## cut off region: prefix
148
154
  value_region = Region.find_by_key!( value_region_key )
149
155
  attribs[ :region_id ] = value_region.id
156
+ elsif value =~ /^metro$/ ## metro(politan area)
157
+ attribs[ :c ] = false # turn off default c|city flag; make it m|metro only
158
+ attribs[ :m ] = true
159
+ elsif value =~ /^supra$/ ## supra(national)
160
+ attribs[ :c ] = false # turn off default c|country flag; make it s|supra only
161
+ attribs[ :s ] = true
162
+ elsif value =~ /^supra:/ ## supra:
163
+ value_country_key = value[6..-1] ## cut off supra: prefix
164
+ value_country = Country.find_by_key!( value_country_key )
165
+ attribs[ :country_id ] = value_country.id
166
+ elsif value =~ /^country:/ ## country:
167
+ value_country_key = value[8..-1] ## cut off country: prefix
168
+ value_country = Country.find_by_key!( value_country_key )
169
+ attribs[ :country_id ] = value_country.id
170
+ attribs[ :c ] = false # turn off default c|country flag; make it d|depend only
171
+ attribs[ :d ] = true
172
+ elsif value =~ /^metro:/ ## metro:
173
+ value_city_key = value[6..-1] ## cut off metro: prefix
174
+ value_city = City.find_by_key!( value_city_key )
175
+ attribs[ :city_id ] = value_city.id
176
+ elsif value =~ /^city:/ ## city:
177
+ value_city_key = value[5..-1] ## cut off city: prefix
178
+ value_city = City.find_by_key!( value_city_key )
179
+ attribs[ :city_id ] = value_city.id
180
+ attribs[ :c ] = false # turn off default c|city flag; make it d|district only
181
+ attribs[ :d ] = true
182
+ elsif value =~ /^m:/ ## m:
183
+ value_popm_str = value[2..-1] ## cut off m: prefix
184
+ value_popm = value_popm_str.gsub(/[ _]/, '').to_i
185
+ attribs[ :popm ] = value_popm
186
+ attribs[ :m ] = true # auto-mark city as m|metro too
150
187
  elsif value =~ /^[A-Z]{3}$/ ## assume three-letter code
151
188
  attribs[ :code ] = value
152
- elsif value =~ /^\d+$/ ## numeric
153
- value_numbers << value.to_i
154
- elsif (values.size==(index+3)) && value =~ /^[a-z0-9\| ]+$/ # tags must be last entry
189
+ elsif value =~ /(^[0-9]{1,2}$)|(^[0-9][0-9 _]+[0-9]$)/ ## numeric (nb: can use any _ or spaces inside digits e.g. 1_000_000 or 1 000 000)
190
+ value_numbers << value.gsub(/[ _]/, '').to_i
191
+ elsif (values.size==(index+3)) && value =~ /^[a-z0-9\|_ ]+$/ # tags must be last entry
155
192
  puts " skipping tags: #{value}"
156
193
  else
157
194
  # issue warning: unknown type for value
@@ -43,11 +43,11 @@ class ValuesReader
43
43
 
44
44
  values = line.split(',')
45
45
 
46
- # remove leading and trailing whitespace for values
46
+ # pass 1) remove leading and trailing whitespace for values
47
+
47
48
  values = values.map { |value| value.strip }
48
49
 
49
- ## remove comment columns
50
- ## todo: also removecomments from inside columns ?? why? why not??
50
+ # pass 2) remove comment columns
51
51
 
52
52
  values = values.select do |value|
53
53
  if value =~ /^#/ ## start with # treat it as a comment column; e.g. remove it
@@ -56,7 +56,15 @@ class ValuesReader
56
56
  else
57
57
  true
58
58
  end
59
- end
59
+ end
60
+
61
+ # pass 3) remove comments inside columns
62
+
63
+ values = values.map do |value|
64
+ value = value.sub( /\s+#.+$/, '' )
65
+ value
66
+ end
67
+
60
68
 
61
69
  puts " values: >>#{values.join('<< >>')}<<"
62
70