has_geo_lookup 0.1.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +389 -0
- data/Rakefile +8 -0
- data/lib/generators/has_geo_lookup/install_generator.rb +66 -0
- data/lib/generators/has_geo_lookup/templates/INSTALL.md +60 -0
- data/lib/generators/has_geo_lookup/templates/create_feature_codes.rb.erb +17 -0
- data/lib/generators/has_geo_lookup/templates/create_geoboundaries.rb.erb +24 -0
- data/lib/generators/has_geo_lookup/templates/create_geoboundaries_metros.rb.erb +10 -0
- data/lib/generators/has_geo_lookup/templates/create_geonames.rb.erb +40 -0
- data/lib/generators/has_geo_lookup/templates/create_geonames_metros.rb.erb +10 -0
- data/lib/generators/has_geo_lookup/templates/create_metros.rb.erb +17 -0
- data/lib/has_geo_lookup/concern.rb +813 -0
- data/lib/has_geo_lookup/index_checker.rb +360 -0
- data/lib/has_geo_lookup/models/feature_code.rb +194 -0
- data/lib/has_geo_lookup/models/geoboundary.rb +220 -0
- data/lib/has_geo_lookup/models/geoname.rb +152 -0
- data/lib/has_geo_lookup/models/metro.rb +247 -0
- data/lib/has_geo_lookup/railtie.rb +11 -0
- data/lib/has_geo_lookup/version.rb +5 -0
- data/lib/has_geo_lookup.rb +28 -0
- data/lib/tasks/has_geo_lookup.rake +111 -0
- data/sig/has_geo_lookup.rbs +4 -0
- metadata +183 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateFeatureCodes < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
return if table_exists?(:feature_codes)
|
4
|
+
|
5
|
+
create_table :feature_codes do |t|
|
6
|
+
t.string :feature_class, limit: 1
|
7
|
+
t.string :feature_code, limit: 10
|
8
|
+
t.string :name
|
9
|
+
t.text :description
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :feature_codes, [:feature_class, :feature_code], unique: true
|
15
|
+
add_index :feature_codes, :feature_class
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateGeoboundaries < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
return if table_exists?(:geoboundaries)
|
4
|
+
|
5
|
+
create_table :geoboundaries do |t|
|
6
|
+
t.string :name
|
7
|
+
t.string :level
|
8
|
+
t.string :shape_group
|
9
|
+
t.string :shape_iso
|
10
|
+
t.string :shape_id
|
11
|
+
t.string :source_url
|
12
|
+
t.column :boundary, 'geometry NOT NULL SRID 4326'
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
|
17
|
+
add_index :geoboundaries, :boundary, type: :spatial
|
18
|
+
add_index :geoboundaries, :level
|
19
|
+
add_index :geoboundaries, :shape_id, unique: true
|
20
|
+
add_index :geoboundaries, :name
|
21
|
+
add_index :geoboundaries, :shape_iso
|
22
|
+
add_index :geoboundaries, :shape_group
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateGeoboundariesMetros < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
return if table_exists?(:geoboundaries_metros)
|
4
|
+
|
5
|
+
create_join_table :geoboundaries, :metros do |t|
|
6
|
+
t.index [:geoboundary_id, :metro_id]
|
7
|
+
t.index [:metro_id, :geoboundary_id], unique: true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class CreateGeonames < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
return if table_exists?(:geonames)
|
4
|
+
|
5
|
+
create_table :geonames do |t|
|
6
|
+
t.string :name, limit: 200
|
7
|
+
t.string :asciiname, limit: 200
|
8
|
+
t.decimal :latitude, precision: 10, scale: 5
|
9
|
+
t.decimal :longitude, precision: 10, scale: 5
|
10
|
+
t.string :feature_class, limit: 1
|
11
|
+
t.string :feature_code, limit: 10
|
12
|
+
t.string :country_code, limit: 2
|
13
|
+
t.string :cc2, limit: 60
|
14
|
+
t.string :admin1_code, limit: 20
|
15
|
+
t.string :admin2_code, limit: 20
|
16
|
+
t.string :admin3_code, limit: 20
|
17
|
+
t.string :admin4_code, limit: 20
|
18
|
+
t.integer :population, limit: 8
|
19
|
+
t.integer :elevation
|
20
|
+
t.integer :dem
|
21
|
+
t.string :timezone, limit: 40
|
22
|
+
t.datetime :modification_date
|
23
|
+
|
24
|
+
t.timestamps
|
25
|
+
end
|
26
|
+
|
27
|
+
# All indexes consolidated from incremental migrations
|
28
|
+
add_index :geonames, :asciiname
|
29
|
+
add_index :geonames, :country_code
|
30
|
+
add_index :geonames, :population
|
31
|
+
add_index :geonames, [:country_code, :admin1_code]
|
32
|
+
add_index :geonames, [:country_code, :admin1_code, :admin2_code]
|
33
|
+
add_index :geonames, [:feature_class, :feature_code]
|
34
|
+
add_index :geonames, [:feature_class, :feature_code, :latitude, :longitude]
|
35
|
+
add_index :geonames, [:latitude, :longitude]
|
36
|
+
add_index :geonames, :feature_code
|
37
|
+
add_index :geonames, :name
|
38
|
+
add_index :geonames, [:admin1_code, :admin2_code]
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateGeonamesMetros < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
return if table_exists?(:geonames_metros)
|
4
|
+
|
5
|
+
create_join_table :geonames, :metros do |t|
|
6
|
+
t.index [:geoname_id, :metro_id]
|
7
|
+
t.index [:metro_id, :geoname_id], unique: true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateMetros < ActiveRecord::Migration<%= migration_version %>
|
2
|
+
def change
|
3
|
+
return if table_exists?(:metros)
|
4
|
+
|
5
|
+
create_table :metros do |t|
|
6
|
+
t.string :name
|
7
|
+
t.text :details
|
8
|
+
t.string :country_code, limit: 2
|
9
|
+
t.integer :population
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :metros, :name, unique: true
|
15
|
+
add_index :metros, :country_code
|
16
|
+
end
|
17
|
+
end
|