geonames_local 0.0.5 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +27 -5
- data/Rakefile +25 -2
- data/VERSION +1 -1
- data/geonames_local.gemspec +64 -40
- data/lib/geonames_local/adapters/mongodb.rb +39 -0
- data/lib/{data → geonames_local/adapters}/postgres.rb +2 -2
- data/lib/{data → geonames_local/adapters}/tokyo.rb +1 -0
- data/lib/{work → geonames_local}/cli.rb +32 -27
- data/lib/{config → geonames_local/config}/codes.yml +0 -0
- data/lib/{config → geonames_local/config}/geonames.yml +3 -2
- data/lib/{data → geonames_local/data}/cache.rb +0 -0
- data/lib/{data → geonames_local/data}/geoquery.rb +0 -0
- data/lib/{data → geonames_local/data}/shp.rb +0 -0
- data/lib/{work → geonames_local}/dump.rb +1 -1
- data/lib/{work → geonames_local}/export.rb +0 -0
- data/lib/{features → geonames_local/features}/city.rb +0 -0
- data/lib/{features → geonames_local/features}/country.rb +0 -0
- data/lib/{features → geonames_local/features}/province.rb +0 -0
- data/lib/{features → geonames_local/features}/road.rb +0 -0
- data/lib/{features → geonames_local/features}/spot.rb +3 -2
- data/lib/{features → geonames_local/features}/zone.rb +0 -0
- data/lib/geonames_local.rb +14 -12
- data/spec/{work → geonames_local}/cli_spec.rb +0 -0
- data/spec/geonames_local/data/cache_spec.rb +4 -0
- data/spec/{data → geonames_local/data}/postgres_spec.rb +1 -1
- data/spec/{data → geonames_local/data}/shp_spec.rb +1 -1
- data/spec/{data → geonames_local/data}/tokyo_spec.rb +1 -1
- data/spec/{features → geonames_local/features}/road_spec.rb +1 -1
- data/spec/{features → geonames_local/features}/spot_spec.rb +1 -1
- data/spec/{features → geonames_local/features}/zone_spec.rb +1 -1
- metadata +88 -49
- data/spec/data/cache_spec.rb +0 -4
data/README.rdoc
CHANGED
@@ -4,14 +4,29 @@ Download and store in tokyo or postgresql Geonames.org data.
|
|
4
4
|
Making every Geoname API operation possible on your servers.
|
5
5
|
No hit limit, fast as possible.
|
6
6
|
|
7
|
-
== Features/Problems
|
8
|
-
|
9
|
-
- Local relational mapping of geonames data
|
10
|
-
- Map geonames fields to your db scheme UNDONE
|
11
|
-
- Countries are a static yml file :/
|
12
7
|
|
13
8
|
== Usage
|
14
9
|
|
10
|
+
To use the adapter, install the corresponding gem:
|
11
|
+
|
12
|
+
PostgreSQL => pg
|
13
|
+
MongoDB => mongodb (optional: mongo_ext)
|
14
|
+
Tokyo => tokyocabinet
|
15
|
+
|
16
|
+
|
17
|
+
=== PostgreSQL
|
18
|
+
|
19
|
+
Be sure to use a database based on the PostGIS template.
|
20
|
+
|
21
|
+
|
22
|
+
=== MongoDB
|
23
|
+
|
24
|
+
MongoDB 2D support is new, only mongo >= 1.3.3 mongodb gem >= 0.19.2
|
25
|
+
http://github.com/mongodb/mongo-ruby-driver
|
26
|
+
|
27
|
+
|
28
|
+
=== Config YML
|
29
|
+
|
15
30
|
geonames conf
|
16
31
|
|
17
32
|
Will generate a "geonames.yml" file on your folder.
|
@@ -75,6 +90,13 @@ Default PG migration:
|
|
75
90
|
add_index :provinces, :country_id
|
76
91
|
|
77
92
|
|
93
|
+
== Features/Problems
|
94
|
+
|
95
|
+
- Local relational mapping of geonames data
|
96
|
+
- Map geonames fields to your db scheme UNDONE
|
97
|
+
- Countries are a static yml file :/
|
98
|
+
|
99
|
+
|
78
100
|
== Note on Patches/Pull Requests
|
79
101
|
|
80
102
|
* Fork the project.
|
data/Rakefile
CHANGED
@@ -11,8 +11,31 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/nofxx/geonames_local"
|
12
12
|
gem.authors = ["Marcos Piccinini"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_dependency "
|
15
|
-
|
14
|
+
gem.add_dependency "nofxx-georuby", ">= 1.7.1"
|
15
|
+
gem.post_install_message = <<-POST_INSTALL_MESSAGE
|
16
|
+
|
17
|
+
Geonames Local
|
18
|
+
--------------
|
19
|
+
|
20
|
+
To use the adapter, install the corresponding gem:
|
21
|
+
|
22
|
+
PostgreSQL => pg
|
23
|
+
MongoDB => mongodb (optional: mongo_ext)
|
24
|
+
Tokyo => tokyocabinet
|
25
|
+
|
26
|
+
PostgreSQL
|
27
|
+
----------
|
28
|
+
|
29
|
+
Be sure to use a database based on the PostGIS template.
|
30
|
+
|
31
|
+
MongoDB
|
32
|
+
-------
|
33
|
+
|
34
|
+
MongoDB 2D support is new, only mongo >= 1.3.3 mongodb gem >= 0.19.2
|
35
|
+
http://github.com/mongodb/mongo-ruby-driver
|
36
|
+
|
37
|
+
Have fun because:
|
38
|
+
POST_INSTALL_MESSAGE
|
16
39
|
end
|
17
40
|
Jeweler::GemcutterTasks.new
|
18
41
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.1
|
data/geonames_local.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{geonames_local}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcos Piccinini"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-03-19}
|
13
13
|
s.default_executable = %q{geonames}
|
14
14
|
s.description = %q{Dump and feed a tokyo cabinet for local geonames search}
|
15
15
|
s.email = %q{x@nofxx.com}
|
@@ -27,53 +27,77 @@ Gem::Specification.new do |s|
|
|
27
27
|
"VERSION",
|
28
28
|
"bin/geonames",
|
29
29
|
"geonames_local.gemspec",
|
30
|
-
"lib/config/codes.yml",
|
31
|
-
"lib/config/geonames.yml",
|
32
|
-
"lib/data/cache.rb",
|
33
|
-
"lib/data/geoquery.rb",
|
34
|
-
"lib/data/postgres.rb",
|
35
|
-
"lib/data/shp.rb",
|
36
|
-
"lib/data/tokyo.rb",
|
37
|
-
"lib/features/city.rb",
|
38
|
-
"lib/features/country.rb",
|
39
|
-
"lib/features/province.rb",
|
40
|
-
"lib/features/road.rb",
|
41
|
-
"lib/features/spot.rb",
|
42
|
-
"lib/features/zone.rb",
|
43
30
|
"lib/geonames_local.rb",
|
44
|
-
"lib/
|
45
|
-
"lib/
|
46
|
-
"lib/
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
31
|
+
"lib/geonames_local/adapters/mongodb.rb",
|
32
|
+
"lib/geonames_local/adapters/postgres.rb",
|
33
|
+
"lib/geonames_local/adapters/tokyo.rb",
|
34
|
+
"lib/geonames_local/cli.rb",
|
35
|
+
"lib/geonames_local/config/codes.yml",
|
36
|
+
"lib/geonames_local/config/geonames.yml",
|
37
|
+
"lib/geonames_local/data/cache.rb",
|
38
|
+
"lib/geonames_local/data/geoquery.rb",
|
39
|
+
"lib/geonames_local/data/shp.rb",
|
40
|
+
"lib/geonames_local/dump.rb",
|
41
|
+
"lib/geonames_local/export.rb",
|
42
|
+
"lib/geonames_local/features/city.rb",
|
43
|
+
"lib/geonames_local/features/country.rb",
|
44
|
+
"lib/geonames_local/features/province.rb",
|
45
|
+
"lib/geonames_local/features/road.rb",
|
46
|
+
"lib/geonames_local/features/spot.rb",
|
47
|
+
"lib/geonames_local/features/zone.rb",
|
48
|
+
"spec/geonames_local/cli_spec.rb",
|
49
|
+
"spec/geonames_local/data/cache_spec.rb",
|
50
|
+
"spec/geonames_local/data/postgres_spec.rb",
|
51
|
+
"spec/geonames_local/data/shp_spec.rb",
|
52
|
+
"spec/geonames_local/data/tokyo_spec.rb",
|
53
|
+
"spec/geonames_local/features/road_spec.rb",
|
54
|
+
"spec/geonames_local/features/spot_spec.rb",
|
55
|
+
"spec/geonames_local/features/zone_spec.rb",
|
54
56
|
"spec/geonames_local_spec.rb",
|
55
57
|
"spec/spec.opts",
|
56
58
|
"spec/spec_helper.rb",
|
57
|
-
"spec/work/cli_spec.rb",
|
58
59
|
"task/benchmark.rb",
|
59
60
|
"task/benchmark_cabinet.rb"
|
60
61
|
]
|
61
62
|
s.homepage = %q{http://github.com/nofxx/geonames_local}
|
63
|
+
s.post_install_message = %q{
|
64
|
+
Geonames Local
|
65
|
+
--------------
|
66
|
+
|
67
|
+
To use the adapter, install the corresponding gem:
|
68
|
+
|
69
|
+
PostgreSQL => pg
|
70
|
+
MongoDB => mongodb (optional: mongo_ext)
|
71
|
+
Tokyo => tokyocabinet
|
72
|
+
|
73
|
+
PostgreSQL
|
74
|
+
----------
|
75
|
+
|
76
|
+
Be sure to use a database based on the PostGIS template.
|
77
|
+
|
78
|
+
MongoDB
|
79
|
+
-------
|
80
|
+
|
81
|
+
MongoDB 2D support is new, only mongo >= 1.3.3 mongodb gem >= 0.19.2
|
82
|
+
http://github.com/mongodb/mongo-ruby-driver
|
83
|
+
|
84
|
+
Have fun because:
|
85
|
+
}
|
62
86
|
s.rdoc_options = ["--charset=UTF-8"]
|
63
87
|
s.require_paths = ["lib"]
|
64
|
-
s.rubygems_version = %q{1.3.
|
88
|
+
s.rubygems_version = %q{1.3.6}
|
65
89
|
s.summary = %q{Dump and feed a tokyo local geonames db}
|
66
90
|
s.test_files = [
|
67
|
-
"spec/
|
68
|
-
"spec/data/
|
69
|
-
"spec/data/
|
70
|
-
"spec/data/tokyo_spec.rb",
|
71
|
-
"spec/
|
72
|
-
"spec/
|
73
|
-
"spec/features/
|
74
|
-
"spec/
|
75
|
-
"spec/
|
76
|
-
"spec/
|
91
|
+
"spec/spec_helper.rb",
|
92
|
+
"spec/geonames_local/data/shp_spec.rb",
|
93
|
+
"spec/geonames_local/data/postgres_spec.rb",
|
94
|
+
"spec/geonames_local/data/tokyo_spec.rb",
|
95
|
+
"spec/geonames_local/data/cache_spec.rb",
|
96
|
+
"spec/geonames_local/cli_spec.rb",
|
97
|
+
"spec/geonames_local/features/spot_spec.rb",
|
98
|
+
"spec/geonames_local/features/zone_spec.rb",
|
99
|
+
"spec/geonames_local/features/road_spec.rb",
|
100
|
+
"spec/geonames_local_spec.rb"
|
77
101
|
]
|
78
102
|
|
79
103
|
if s.respond_to? :specification_version then
|
@@ -82,14 +106,14 @@ Gem::Specification.new do |s|
|
|
82
106
|
|
83
107
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
84
108
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
85
|
-
s.add_runtime_dependency(%q<
|
109
|
+
s.add_runtime_dependency(%q<nofxx-georuby>, [">= 1.7.1"])
|
86
110
|
else
|
87
111
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
88
|
-
s.add_dependency(%q<
|
112
|
+
s.add_dependency(%q<nofxx-georuby>, [">= 1.7.1"])
|
89
113
|
end
|
90
114
|
else
|
91
115
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
92
|
-
s.add_dependency(%q<
|
116
|
+
s.add_dependency(%q<nofxx-georuby>, [">= 1.7.1"])
|
93
117
|
end
|
94
118
|
end
|
95
119
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "mongo"
|
2
|
+
|
3
|
+
module Geonames
|
4
|
+
class Mongodb
|
5
|
+
|
6
|
+
RESOURCES = ["countries", "provinces", "cities"]
|
7
|
+
|
8
|
+
def initialize(params)
|
9
|
+
port = params[:port] || 27017
|
10
|
+
@conn = Mongo::Connection.new(params[:host], port)
|
11
|
+
@db = @conn.db(params[:dbname])
|
12
|
+
purge
|
13
|
+
setup
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
for re in RESOURCES
|
18
|
+
coll = @db.collection(re)
|
19
|
+
coll.create_index(["id", Mongo::ASCENDING])
|
20
|
+
coll.create_index(["geom", Mongo::GEO2D], :min => 0, :max => 180)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def find(resource, id, name=nil)
|
25
|
+
@db.collection(resource.to_s).find("id" => id).to_a.first
|
26
|
+
end
|
27
|
+
|
28
|
+
def insert(resource, spot)
|
29
|
+
@db.collection(resource.to_s).insert(spot.to_hash)
|
30
|
+
end
|
31
|
+
|
32
|
+
def purge
|
33
|
+
for re in RESOURCES
|
34
|
+
@db.drop_collection(re)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -30,9 +30,9 @@ module Geonames
|
|
30
30
|
|
31
31
|
#
|
32
32
|
# Insert a record
|
33
|
-
def insert(some)
|
33
|
+
def insert(table, some)
|
34
34
|
country_id, province_id, city_id = get_some_ids(some)
|
35
|
-
case
|
35
|
+
case table
|
36
36
|
when :cities
|
37
37
|
write("cities", {:name => some.name, :country_id => country_id,
|
38
38
|
:geom => some.geom.as_hex_ewkb, :gid => some.gid,
|
@@ -4,7 +4,6 @@
|
|
4
4
|
require 'optparse'
|
5
5
|
module Geonames
|
6
6
|
class CLI
|
7
|
-
|
8
7
|
def self.parse_options(argv)
|
9
8
|
options = {}
|
10
9
|
|
@@ -14,6 +13,7 @@ Geonames Command Line Usage:
|
|
14
13
|
|
15
14
|
geonames <country code(s)> <opts>
|
16
15
|
|
16
|
+
geonames
|
17
17
|
BANNER
|
18
18
|
opts.on("-l", "--level LEVEL", String, "The level of logging to report" ) { |level| options[:level] = level }
|
19
19
|
opts.on("-d", "--dump", "Dump DB before all" ) { options[:dump] = true }
|
@@ -22,11 +22,6 @@ BANNER
|
|
22
22
|
opts.on("-c", "--config CONFIG", String, "Geonames Config file path" ) { |file| options[:config] = file }
|
23
23
|
opts.on("-i", "--import CONFIG", String, "Geonames Import SHP/DBF/GPX" ) { |file| options[:shp] = file }
|
24
24
|
opts.separator ""
|
25
|
-
opts.separator "Tyrant Options:"
|
26
|
-
opts.on("-t", "--tyrant", "Use tyrant" ) { options[:tyrant] = true }
|
27
|
-
opts.on("-s", "--server SERVER", String, "Tyrant Server URL" ) { |url| options[:server] = url }
|
28
|
-
opts.on("-p", "--port PORT", Integer, "Tyrant Server Port") { |val| options[:port] = val.to_i }
|
29
|
-
opts.separator ""
|
30
25
|
opts.separator "SHP Options:"
|
31
26
|
opts.on("--map TYPE", Array, "Use zone/road to import" ) { |s| options[:map] = s.map(&:to_sym) }
|
32
27
|
opts.on("--type TYPE", String, "Use zone/road to import" ) { |s| options[:type] = s }
|
@@ -53,8 +48,10 @@ BANNER
|
|
53
48
|
end
|
54
49
|
private_class_method :parse_options
|
55
50
|
|
51
|
+
class << self
|
52
|
+
|
56
53
|
# Ugly but works?
|
57
|
-
def
|
54
|
+
def work(argv)
|
58
55
|
trap(:INT) { stop! }
|
59
56
|
trap(:TERM) { stop! }
|
60
57
|
Opt.merge! parse_options(argv)
|
@@ -79,13 +76,16 @@ BANNER
|
|
79
76
|
exit
|
80
77
|
end
|
81
78
|
|
79
|
+
#
|
80
|
+
# If arguments scaffold, config, write down yml.
|
81
|
+
#
|
82
82
|
if argv[0] =~ /scaff|conf/
|
83
83
|
fname = (argv[1] || "geonames") + ".yml"
|
84
84
|
if File.exist?(fname)
|
85
85
|
puts "File exists."
|
86
86
|
else
|
87
87
|
puts "Writing to #{fname}"
|
88
|
-
`cp #{File.join(File.dirname(__FILE__), '
|
88
|
+
`cp #{File.join(File.dirname(__FILE__), 'config', 'geonames.yml')} #{fname}`
|
89
89
|
end
|
90
90
|
exit
|
91
91
|
end
|
@@ -94,24 +94,28 @@ BANNER
|
|
94
94
|
if argv[0] =~ /csv|json/
|
95
95
|
Geonames::Export.new(Country.all).to_csv
|
96
96
|
else
|
97
|
+
db = load_adapter(Opt[:store])
|
98
|
+
info "Using adapter #{Opt[:store]}.."
|
97
99
|
Geonames::Dump.work(Opt[:codes], :zip) #rescue puts "Command not found: #{comm} #{@usage}"
|
98
100
|
Geonames::Dump.work(Opt[:codes], :dump) #rescue puts "Command not found: #{comm} #{@usage}"
|
99
101
|
info "\n---\nTotal #{Cache[:dump].length} parsed. #{Cache[:zip].length} zips."
|
100
102
|
info "Join dump << zip"
|
101
103
|
unify!
|
102
|
-
write_to_store!
|
104
|
+
write_to_store!(db)
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
106
|
-
def
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
108
|
+
def load_adapter(name)
|
109
|
+
begin
|
110
|
+
require "geonames_local/adapters/#{name}"
|
111
|
+
Geonames.class_eval(name.capitalize).new(Opt[:db])
|
112
|
+
rescue LoadError
|
113
|
+
puts "Can't find adapter #{name}"
|
114
|
+
stop!
|
115
|
+
end
|
116
|
+
end
|
114
117
|
|
118
|
+
def write_to_store!(db)
|
115
119
|
groups = Cache[:dump].group_by(&:kind)
|
116
120
|
Cache[:provinces] = groups[:provinces]
|
117
121
|
# ensure this order....
|
@@ -119,16 +123,16 @@ BANNER
|
|
119
123
|
do_write(db, groups[:cities])
|
120
124
|
end
|
121
125
|
|
122
|
-
def
|
123
|
-
return if
|
124
|
-
key =
|
126
|
+
def do_write(db, values)
|
127
|
+
return if values.empty?
|
128
|
+
key = values[0].table
|
125
129
|
start = Time.now
|
126
130
|
writt = 0
|
127
|
-
info "\nWriting #{
|
128
|
-
|
129
|
-
meth =
|
130
|
-
unless db.find(
|
131
|
-
db.insert(
|
131
|
+
info "\nWriting #{values.length} #{key}..."
|
132
|
+
values.each do |val|
|
133
|
+
meth = val.respond_to?(:gid) ? [val.gid] : [val.name, true]
|
134
|
+
unless db.find(val.table, *meth)
|
135
|
+
db.insert(val.table, val)
|
132
136
|
writt += 1
|
133
137
|
end
|
134
138
|
end
|
@@ -136,7 +140,7 @@ BANNER
|
|
136
140
|
info "#{writt} #{key} written in #{total} sec (#{(writt/total).to_i}/s)"
|
137
141
|
end
|
138
142
|
|
139
|
-
def
|
143
|
+
def unify!
|
140
144
|
start = Time.now
|
141
145
|
Cache[:dump].map! do |spot|
|
142
146
|
if other = Cache[:zip].find { |d| d.code == spot.code }
|
@@ -149,10 +153,11 @@ BANNER
|
|
149
153
|
info "Done. #{(Time.now-start).to_i}s"
|
150
154
|
end
|
151
155
|
|
152
|
-
def
|
156
|
+
def stop!
|
153
157
|
puts "Closing Geonames..."
|
154
158
|
exit
|
155
159
|
end
|
160
|
+
end
|
156
161
|
|
157
162
|
end
|
158
163
|
|
File without changes
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#
|
2
2
|
# Geonames Local Config Example
|
3
3
|
#
|
4
|
-
:
|
4
|
+
# Stores: postgres, mongodb, tokyo, redis
|
5
|
+
:store: postgres
|
5
6
|
:codes: [br, it]
|
6
7
|
:level: city
|
7
8
|
:mapping:
|
@@ -9,6 +10,6 @@
|
|
9
10
|
:geom: true
|
10
11
|
:db:
|
11
12
|
:host: localhost
|
12
|
-
:dbname:
|
13
|
+
:dbname: dbname
|
13
14
|
:user: postgres
|
14
15
|
:password:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -73,8 +73,9 @@ module Geonames
|
|
73
73
|
|
74
74
|
# For tokyo
|
75
75
|
def to_hash
|
76
|
-
{ "
|
77
|
-
"
|
76
|
+
{ "id" => @geoname_id, "gid" => @geoname_id.to_s, "kind" => @kind.to_s,
|
77
|
+
"name" => @name, "ascii" => @ascii, "country" => @country,
|
78
|
+
"geom" => {"y" => @lat.to_s, "x" => @lon.to_s}, "tz" => @tz }
|
78
79
|
end
|
79
80
|
|
80
81
|
|
File without changes
|
data/lib/geonames_local.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'features/road'
|
5
|
-
require 'features/zone'
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
6
4
|
require 'rubygems'
|
7
5
|
require 'logger'
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
require '
|
6
|
+
require 'yaml'
|
7
|
+
require 'geonames_local/features/spot'
|
8
|
+
require 'geonames_local/features/country'
|
9
|
+
require 'geonames_local/features/city'
|
10
|
+
require 'geonames_local/features/road'
|
11
|
+
require 'geonames_local/features/zone'
|
12
|
+
require 'geonames_local/data/shp'
|
13
|
+
require 'geonames_local/cli'
|
14
|
+
require 'geonames_local/dump'
|
15
|
+
require 'geonames_local/export'
|
14
16
|
|
15
17
|
module Geonames
|
16
18
|
Opt = {}
|
17
19
|
Cache = {:dump => [], :zip => [], :roads => [], :zones => []}
|
18
|
-
Codes = YAML.load(File.read(File.join(File.dirname(__FILE__),'config', 'codes.yml')))
|
20
|
+
Codes = YAML.load(File.read(File.join(File.dirname(__FILE__), 'geonames_local', 'config', 'codes.yml')))
|
19
21
|
VERSION = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
|
20
22
|
|
21
23
|
def info(txt)
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geonames_local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Marcos Piccinini
|
@@ -9,29 +14,37 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-03-19 00:00:00 -03:00
|
13
18
|
default_executable: geonames
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
23
31
|
version: 1.2.9
|
24
|
-
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
name: nofxx-georuby
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
38
|
requirements:
|
31
39
|
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 7
|
44
|
+
- 1
|
45
|
+
version: 1.7.1
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
35
48
|
description: Dump and feed a tokyo cabinet for local geonames search
|
36
49
|
email: x@nofxx.com
|
37
50
|
executables:
|
@@ -50,41 +63,65 @@ files:
|
|
50
63
|
- VERSION
|
51
64
|
- bin/geonames
|
52
65
|
- geonames_local.gemspec
|
53
|
-
- lib/config/codes.yml
|
54
|
-
- lib/config/geonames.yml
|
55
|
-
- lib/data/cache.rb
|
56
|
-
- lib/data/geoquery.rb
|
57
|
-
- lib/data/postgres.rb
|
58
|
-
- lib/data/shp.rb
|
59
|
-
- lib/data/tokyo.rb
|
60
|
-
- lib/features/city.rb
|
61
|
-
- lib/features/country.rb
|
62
|
-
- lib/features/province.rb
|
63
|
-
- lib/features/road.rb
|
64
|
-
- lib/features/spot.rb
|
65
|
-
- lib/features/zone.rb
|
66
66
|
- lib/geonames_local.rb
|
67
|
-
- lib/
|
68
|
-
- lib/
|
69
|
-
- lib/
|
70
|
-
-
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
67
|
+
- lib/geonames_local/adapters/mongodb.rb
|
68
|
+
- lib/geonames_local/adapters/postgres.rb
|
69
|
+
- lib/geonames_local/adapters/tokyo.rb
|
70
|
+
- lib/geonames_local/cli.rb
|
71
|
+
- lib/geonames_local/config/codes.yml
|
72
|
+
- lib/geonames_local/config/geonames.yml
|
73
|
+
- lib/geonames_local/data/cache.rb
|
74
|
+
- lib/geonames_local/data/geoquery.rb
|
75
|
+
- lib/geonames_local/data/shp.rb
|
76
|
+
- lib/geonames_local/dump.rb
|
77
|
+
- lib/geonames_local/export.rb
|
78
|
+
- lib/geonames_local/features/city.rb
|
79
|
+
- lib/geonames_local/features/country.rb
|
80
|
+
- lib/geonames_local/features/province.rb
|
81
|
+
- lib/geonames_local/features/road.rb
|
82
|
+
- lib/geonames_local/features/spot.rb
|
83
|
+
- lib/geonames_local/features/zone.rb
|
84
|
+
- spec/geonames_local/cli_spec.rb
|
85
|
+
- spec/geonames_local/data/cache_spec.rb
|
86
|
+
- spec/geonames_local/data/postgres_spec.rb
|
87
|
+
- spec/geonames_local/data/shp_spec.rb
|
88
|
+
- spec/geonames_local/data/tokyo_spec.rb
|
89
|
+
- spec/geonames_local/features/road_spec.rb
|
90
|
+
- spec/geonames_local/features/spot_spec.rb
|
91
|
+
- spec/geonames_local/features/zone_spec.rb
|
77
92
|
- spec/geonames_local_spec.rb
|
78
93
|
- spec/spec.opts
|
79
94
|
- spec/spec_helper.rb
|
80
|
-
- spec/work/cli_spec.rb
|
81
95
|
- task/benchmark.rb
|
82
96
|
- task/benchmark_cabinet.rb
|
83
97
|
has_rdoc: true
|
84
98
|
homepage: http://github.com/nofxx/geonames_local
|
85
99
|
licenses: []
|
86
100
|
|
87
|
-
post_install_message:
|
101
|
+
post_install_message: |
|
102
|
+
|
103
|
+
Geonames Local
|
104
|
+
--------------
|
105
|
+
|
106
|
+
To use the adapter, install the corresponding gem:
|
107
|
+
|
108
|
+
PostgreSQL => pg
|
109
|
+
MongoDB => mongodb (optional: mongo_ext)
|
110
|
+
Tokyo => tokyocabinet
|
111
|
+
|
112
|
+
PostgreSQL
|
113
|
+
----------
|
114
|
+
|
115
|
+
Be sure to use a database based on the PostGIS template.
|
116
|
+
|
117
|
+
MongoDB
|
118
|
+
-------
|
119
|
+
|
120
|
+
MongoDB 2D support is new, only mongo >= 1.3.3 mongodb gem >= 0.19.2
|
121
|
+
http://github.com/mongodb/mongo-ruby-driver
|
122
|
+
|
123
|
+
Have fun because:
|
124
|
+
|
88
125
|
rdoc_options:
|
89
126
|
- --charset=UTF-8
|
90
127
|
require_paths:
|
@@ -93,29 +130,31 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
130
|
requirements:
|
94
131
|
- - ">="
|
95
132
|
- !ruby/object:Gem::Version
|
133
|
+
segments:
|
134
|
+
- 0
|
96
135
|
version: "0"
|
97
|
-
version:
|
98
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
137
|
requirements:
|
100
138
|
- - ">="
|
101
139
|
- !ruby/object:Gem::Version
|
140
|
+
segments:
|
141
|
+
- 0
|
102
142
|
version: "0"
|
103
|
-
version:
|
104
143
|
requirements: []
|
105
144
|
|
106
145
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.3.
|
146
|
+
rubygems_version: 1.3.6
|
108
147
|
signing_key:
|
109
148
|
specification_version: 3
|
110
149
|
summary: Dump and feed a tokyo local geonames db
|
111
150
|
test_files:
|
112
|
-
- spec/data/cache_spec.rb
|
113
|
-
- spec/data/postgres_spec.rb
|
114
|
-
- spec/data/shp_spec.rb
|
115
|
-
- spec/data/tokyo_spec.rb
|
116
|
-
- spec/features/road_spec.rb
|
117
|
-
- spec/features/spot_spec.rb
|
118
|
-
- spec/features/zone_spec.rb
|
119
|
-
- spec/geonames_local_spec.rb
|
120
151
|
- spec/spec_helper.rb
|
121
|
-
- spec/
|
152
|
+
- spec/geonames_local/data/shp_spec.rb
|
153
|
+
- spec/geonames_local/data/postgres_spec.rb
|
154
|
+
- spec/geonames_local/data/tokyo_spec.rb
|
155
|
+
- spec/geonames_local/data/cache_spec.rb
|
156
|
+
- spec/geonames_local/cli_spec.rb
|
157
|
+
- spec/geonames_local/features/spot_spec.rb
|
158
|
+
- spec/geonames_local/features/zone_spec.rb
|
159
|
+
- spec/geonames_local/features/road_spec.rb
|
160
|
+
- spec/geonames_local_spec.rb
|
data/spec/data/cache_spec.rb
DELETED