geonames_rails 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,7 +46,9 @@ class CreateGeonamesTables < ActiveRecord::Migration
46
46
  # [1] name : name of geographical point (utf8) varchar(200)
47
47
  t.string :name, :null => false
48
48
  # [2] asciiname : name of geographical point in plain ascii characters, varchar(200)
49
+ t.string :asciiname
49
50
  # [3] alternatenames : alternatenames, comma separated varchar(4000)
51
+ t.text :alternatenames
50
52
  # [4] latitude : latitude in decimal degrees (wgs84)
51
53
  t.decimal :latitude, :precision => 14, :scale => 8, :null => false
52
54
  # [5] longitude : longitude in decimal degrees (wgs84)
@@ -13,8 +13,12 @@ module GeonamesRails
13
13
  :iso_number,
14
14
  :name,
15
15
  :capital,
16
+ :population,
16
17
  :continent,
17
- :geonames_id)
18
+ :currency_name,
19
+ :currency_code,
20
+ :geonames_id,
21
+ :population)
18
22
  c.save!
19
23
 
20
24
  "#{created_or_updating} db record for #{iso_code}"
@@ -25,23 +29,26 @@ module GeonamesRails
25
29
  def write_cities(country_code, city_mappings)
26
30
  country = Country.find_by_iso_code_two_letter(country_code)
27
31
 
28
- #puts country
29
- #puts city_mappings
30
-
31
- city_mappings.each do |city_mapping|
32
- city = City.find_or_initialize_by_geonames_id(city_mapping[:geonames_id])
33
- city.country_id = country.id
34
-
35
- city.attributes = city_mapping.slice(:name,
36
- :latitude,
37
- :longitude,
38
- :country_iso_code_two_letters,
39
- :geonames_timezone_id)
40
-
41
- city.save!
32
+ unless country.nil?
33
+ city_mappings.each do |city_mapping|
34
+ city = City.find_or_initialize_by_geonames_id(city_mapping[:geonames_id])
35
+ city.country_id = country.id
36
+
37
+ city.attributes = city_mapping.slice(:name,
38
+ :asciiname,
39
+ :alternatenames,
40
+ :latitude,
41
+ :longitude,
42
+ :country_iso_code_two_letters,
43
+ :population,
44
+ :geonames_timezone_id,
45
+ :geonames_id)
46
+
47
+ city.save!
48
+ end
49
+
50
+ "Processed #{country.name}(#{country_code}) with #{city_mappings.length} cities"
42
51
  end
43
-
44
- "Processed #{country.name}(#{country_code}) with #{city_mappings.length} cities"
45
52
  end
46
53
 
47
54
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 5
9
+ version: 0.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marius Andra