Inspect locations
This commit is contained in:
parent
6b1c6a2e58
commit
cd6ea52f07
4 changed files with 111 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -56,3 +56,5 @@ build-iPhoneSimulator/
|
|||
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
||||
# .rubocop-https?--*
|
||||
|
||||
# Editors
|
||||
*~
|
||||
4
Gemfile
Normal file
4
Gemfile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'sequel'
|
||||
gem 'mysql2'
|
||||
24
Gemfile.lock
Normal file
24
Gemfile.lock
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
bigdecimal (4.0.1)
|
||||
mysql2 (0.5.7)
|
||||
bigdecimal
|
||||
sequel (5.101.0)
|
||||
bigdecimal
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
mysql2
|
||||
sequel
|
||||
|
||||
CHECKSUMS
|
||||
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
|
||||
mysql2 (0.5.7) sha256=ba09ede515a0ae8a7192040a1b778c0fb0f025fa5877e9be895cd325fa5e9d7b
|
||||
sequel (5.101.0) sha256=d2ae3fd997a7c4572e8357918e777869faf90dc19310fcd6332747122aed2b29
|
||||
|
||||
BUNDLED WITH
|
||||
4.0.3
|
||||
81
src/map_locations.rb
Executable file
81
src/map_locations.rb
Executable file
|
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'sequel'
|
||||
|
||||
DB = Sequel.mysql2(host: 'localhost', user: 'migrants', database: 'migrants', password: '1234')
|
||||
|
||||
def toName(name)
|
||||
name.gsub(' ', '_')
|
||||
end
|
||||
|
||||
# Define the regions
|
||||
|
||||
REGIONS = {
|
||||
'Africa' => {
|
||||
wikidata: 'wd:Q15'
|
||||
},
|
||||
'Asia' => {
|
||||
wikidata: 'wd:Q48'
|
||||
},
|
||||
'Australia' => {
|
||||
wikidata: 'wd:Q3960'
|
||||
},
|
||||
'East Asia' => {
|
||||
wikidata: 'wd:Q27231',
|
||||
part_of: 'Asia'
|
||||
},
|
||||
'Europe' => {
|
||||
wikidata: 'wd:Q46'
|
||||
},
|
||||
'Middle East' => {
|
||||
wikidata: 'wd:Q7204'
|
||||
},
|
||||
'North Africa' => {
|
||||
wikidata: 'wd:Q27381',
|
||||
part_of: 'Africa'
|
||||
},
|
||||
'North America' => {
|
||||
wikidata: 'wd:Q49'
|
||||
},
|
||||
'Oceania' => {
|
||||
wikidata: 'wd:Q538'
|
||||
},
|
||||
'South America' => {
|
||||
wikidata: 'wd:Q18'
|
||||
}
|
||||
}
|
||||
|
||||
# Print the regions
|
||||
|
||||
REGIONS.each do |reg_name, reg_attr|
|
||||
reg_attr[:id] = "region:#{toName(reg_name)}"
|
||||
puts "#{reg_attr[:id]} a mig:Region ; skos:prefLabel \"#{reg_name}\"@en ."
|
||||
end
|
||||
|
||||
LOCATIONS = []
|
||||
COUNTRIES = {}
|
||||
|
||||
# [[:IDLocation, {primary_key: true, auto_increment: false, generated: false, allow_null: false, comment: nil, default: nil, db_type: "varchar(20)", type: :string, extra: "", ruby_default: nil, max_length: 20}],
|
||||
# [:Continent, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "varchar(50)", type: :string, extra: "", ruby_default: nil, max_length: 50}],
|
||||
# [:Country, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "varchar(50)", type: :string, extra: "", ruby_default: nil, max_length: 50}],
|
||||
# [:State, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "varchar(50)", type: :string, extra: "", ruby_default: nil, max_length: 50}],
|
||||
# [:City, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "varchar(50)", type: :string, extra: "", ruby_default: nil, max_length: 50}],
|
||||
# [:latitude, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "float", type: :float, extra: "", ruby_default: nil}],
|
||||
# [:longitude, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "float", type: :float, extra: "", ruby_default: nil}],
|
||||
# [:wikipedia, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "text", type: :string, extra: "", ruby_default: nil}],
|
||||
# [:wikidata, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "text", type: :string, extra: "", ruby_default: nil}],
|
||||
# [:GeoNamesID, {primary_key: false, generated: false, allow_null: true, comment: nil, default: nil, db_type: "varchar(100)", type: :string, extra: "", ruby_default: nil, max_length: 100}]]
|
||||
|
||||
|
||||
DB[:location].limit(10).each do |location|
|
||||
LOCATIONS << {
|
||||
id: "location:#{location[:IDLocation]}"
|
||||
}
|
||||
end
|
||||
|
||||
# Print locations
|
||||
|
||||
LOCATIONS.each do |location|
|
||||
p location
|
||||
puts "#{location[:id]} a mig:Location ."
|
||||
end
|
||||
Loading…
Reference in a new issue