geonames_local 3.3.1 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +13 -10
- data/Guardfile +2 -2
- data/Rakefile +16 -17
- data/geonames.yml +2 -2
- data/geonames_local.gemspec +17 -17
- data/lib/geonames_local/cli.rb +55 -71
- data/lib/geonames_local/data/dump.rb +18 -29
- data/lib/geonames_local/data/export.rb +4 -5
- data/lib/geonames_local/data/shp.rb +7 -8
- data/lib/geonames_local/features/road.rb +7 -10
- data/lib/geonames_local/features/spot.rb +4 -8
- data/lib/geonames_local/features/zone.rb +4 -5
- data/lib/geonames_local/geonames.rb +3 -7
- data/lib/geonames_local/models/mongodb.rb +28 -29
- data/lib/geonames_local/models/postgis.rb +37 -39
- data/lib/geonames_local/version.rb +1 -1
- data/lib/geonames_local.rb +5 -0
- data/spec/geonames_local/cli_spec.rb +2 -2
- data/spec/geonames_local/data/shp_spec.rb +8 -9
- data/spec/geonames_local/features/road_spec.rb +23 -26
- data/spec/geonames_local/features/spot_spec.rb +130 -133
- data/spec/geonames_local/features/zone_spec.rb +21 -22
- data/spec/geonames_local/models/mongodb_spec.rb +1 -1
- data/spec/geonames_local/models/tokyo_spec.rb +21 -21
- data/spec/geonames_local_spec.rb +2 -3
- data/spec/spec_ar_helper.rb +0 -3
- data/spec/spec_helper.rb +2 -4
- data/task/benchmark.rb +6 -8
- data/task/benchmark_cabinet.rb +5 -7
- metadata +9 -8
@@ -1,275 +1,272 @@
|
|
1
|
-
|
2
|
-
require "spec_helper"
|
3
|
-
require "geo_ruby"
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe Spot do
|
6
4
|
|
7
|
-
describe
|
5
|
+
describe 'Parsing Dump' do
|
8
6
|
|
9
7
|
let(:spot) { Spot.new("6319037\tMaxaranguape\tMaxaranguape\t\t-5.46874226086957\t-35.3565714695652\tA\tADM2\tBR\t22\t2407500\t6593\t\t12\t\t\t\tAmerica/Recife\t2006-12-17", :dump) }
|
10
8
|
|
11
|
-
it
|
12
|
-
spot.geoname_id.
|
13
|
-
spot.gid.
|
9
|
+
it 'should parse geoid integer' do
|
10
|
+
expect(spot.geoname_id).to eql(6_319_037)
|
11
|
+
expect(spot.gid).to eql(6_319_037)
|
14
12
|
end
|
15
13
|
|
16
|
-
it
|
17
|
-
spot.code.
|
14
|
+
it 'should parse code' do
|
15
|
+
expect(spot.code).to eql('6593')
|
18
16
|
end
|
19
17
|
|
20
|
-
it
|
21
|
-
spot.region.
|
18
|
+
it 'should parse region code' do
|
19
|
+
expect(spot.region).to eql('2407500')
|
22
20
|
end
|
23
21
|
|
24
|
-
it
|
25
|
-
spot.name.
|
26
|
-
spot.ascii.
|
22
|
+
it 'should parse name' do
|
23
|
+
expect(spot.name).to eql('Maxaranguape')
|
24
|
+
expect(spot.ascii).to eql('Maxaranguape')
|
27
25
|
end
|
28
26
|
|
29
|
-
it
|
30
|
-
spot.lat.
|
31
|
-
spot.y.
|
32
|
-
spot.lon.
|
27
|
+
it 'should parse geostuff' do
|
28
|
+
expect(spot.lat).to be_within(0.001).of(-5.4687)
|
29
|
+
expect(spot.y).to be_within(0.001).of(-5.4687)
|
30
|
+
expect(spot.lon).to be_within(0.001).of(-35.3565)
|
33
31
|
end
|
34
32
|
|
35
|
-
it
|
36
|
-
spot.kind.
|
33
|
+
it 'should parse spot kind' do
|
34
|
+
expect(spot.kind).to eql(:city)
|
37
35
|
end
|
38
36
|
|
39
|
-
it
|
40
|
-
spot.nation.
|
37
|
+
it 'should parse spot nation' do
|
38
|
+
expect(spot.nation).to eql('BR')
|
41
39
|
end
|
42
40
|
|
43
|
-
it
|
44
|
-
spot.tz.
|
41
|
+
it 'shuold parse timezone' do
|
42
|
+
expect(spot.tz).to eql('America/Recife')
|
45
43
|
end
|
46
44
|
|
47
|
-
it
|
48
|
-
spot.updated_at.
|
49
|
-
spot.updated_at.day.
|
45
|
+
it 'should parse updated_at' do
|
46
|
+
expect(spot.updated_at).to be_instance_of(Time)
|
47
|
+
expect(spot.updated_at.day).to eql(17)
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
describe
|
51
|
+
describe 'More Parsing' do
|
54
52
|
|
55
53
|
let(:spot) { Geonames::Spot.new("3384862\tRiacho Zuza\tRiacho Zuza\t\t-9.4333333\t-37.6666667\tH\tSTMI\tBR\t\t02\t\t\t\t0\t\t241\tAmerica/Maceio\t1993-12-17\n", :dump) }
|
56
54
|
|
57
|
-
it
|
58
|
-
spot.geoname_id.
|
55
|
+
it 'should parse geoid integer' do
|
56
|
+
expect(spot.geoname_id).to eql(3_384_862)
|
59
57
|
end
|
60
58
|
|
61
|
-
it
|
62
|
-
spot.name.
|
63
|
-
spot.ascii.
|
59
|
+
it 'should parse name' do
|
60
|
+
expect(spot.name).to eql('Riacho Zuza')
|
61
|
+
expect(spot.ascii).to eql('Riacho Zuza')
|
64
62
|
end
|
65
63
|
|
66
|
-
it
|
67
|
-
spot.lat.
|
68
|
-
spot.lon.
|
64
|
+
it 'should parse geostuff' do
|
65
|
+
expect(spot.lat).to be_within(0.001).of(-9.4333333)
|
66
|
+
expect(spot.lon).to be_within(0.001).of(-37.6666667)
|
69
67
|
end
|
70
68
|
|
71
|
-
it
|
72
|
-
spot.kind.
|
69
|
+
it 'should parse spot kind' do
|
70
|
+
expect(spot.kind).to eql(:other)
|
73
71
|
end
|
74
72
|
|
75
|
-
it
|
76
|
-
spot.nation.
|
73
|
+
it 'should parse spot nation' do
|
74
|
+
expect(spot.nation).to eql('BR')
|
77
75
|
end
|
78
76
|
|
79
|
-
it
|
80
|
-
spot.tz.
|
77
|
+
it 'shuold parse timezone' do
|
78
|
+
expect(spot.tz).to eql('America/Maceio')
|
81
79
|
end
|
82
80
|
|
83
|
-
it
|
84
|
-
spot.updated_at.
|
85
|
-
spot.updated_at.day.
|
81
|
+
it 'should parse updated_at' do
|
82
|
+
expect(spot.updated_at).to be_instance_of(Time)
|
83
|
+
expect(spot.updated_at.day).to eql(17)
|
86
84
|
end
|
87
85
|
end
|
88
86
|
|
89
|
-
describe
|
87
|
+
describe 'Parsing Region' do
|
90
88
|
|
91
89
|
let(:spot) { Geonames::Spot.new("3457153\tEstado de Minas Gerais\tEstado de Minas Gerais\tMinas,Minas Geraes,Minas Gerais\t-18.0\t-44.0\tA\tADM1\tBR\tBR\t15\t\t\t\t16672613\t\t1219\tAmerica/Sao_Paulo\t2007-05-15\n", :dump) }
|
92
90
|
|
93
|
-
it
|
94
|
-
spot.kind.
|
91
|
+
it 'should be kind of region' do
|
92
|
+
expect(spot.kind).to eql(:region)
|
95
93
|
end
|
96
94
|
|
97
|
-
it
|
98
|
-
|
99
|
-
spot.gid.
|
95
|
+
it 'should parse geoid' do
|
96
|
+
expect(spot.geoname_id).to eql(3_457_153)
|
97
|
+
expect(spot.gid).to eql(3_457_153)
|
100
98
|
end
|
101
99
|
|
102
|
-
it
|
103
|
-
spot.code.
|
100
|
+
it 'should parse code' do
|
101
|
+
expect(spot.code).to be_empty
|
104
102
|
end
|
105
103
|
|
106
|
-
it
|
107
|
-
spot.region.
|
104
|
+
it 'should parse region code' do
|
105
|
+
expect(spot.region).to eql('15')
|
108
106
|
end
|
109
107
|
|
110
|
-
it
|
111
|
-
spot.abbr.
|
108
|
+
it 'should create abbr' do
|
109
|
+
expect(spot.abbr).to eql('MG')
|
112
110
|
end
|
113
111
|
|
114
|
-
it
|
115
|
-
spot.name.
|
116
|
-
spot.ascii.
|
112
|
+
it 'should parse name' do
|
113
|
+
expect(spot.name).to eql('Minas Gerais')
|
114
|
+
expect(spot.ascii).to eql('Estado de Minas Gerais')
|
117
115
|
end
|
118
116
|
|
119
|
-
it
|
120
|
-
spot.lat.
|
121
|
-
spot.lon.
|
117
|
+
it 'should parse geostuff' do
|
118
|
+
expect(spot.lat).to be_within(0.001).of(-18.0)
|
119
|
+
expect(spot.lon).to be_within(0.001).of(-44.0)
|
122
120
|
end
|
123
121
|
|
124
122
|
end
|
125
123
|
|
126
|
-
describe
|
124
|
+
describe 'Parsing City' do
|
127
125
|
|
128
126
|
let(:spot) { Spot.new "3386859\tTamboril\tTamboril\t\t-4.9931\t-40.26738\tA\tADM2\tBR\t\t06\t2313203\t\t\t25455\t\t401\tAmerica/Fortaleza\t2011-04-21" }
|
129
127
|
|
130
|
-
it
|
131
|
-
spot.name.
|
128
|
+
it 'should parse name' do
|
129
|
+
expect(spot.name).to eql('Tamboril')
|
132
130
|
end
|
133
131
|
|
134
|
-
it
|
135
|
-
spot.name.
|
132
|
+
it 'should parse ascii name' do
|
133
|
+
expect(spot.name).to eql('Tamboril')
|
136
134
|
end
|
137
135
|
|
138
|
-
it
|
139
|
-
spot.x.
|
136
|
+
it 'should parse x' do
|
137
|
+
expect(spot.x).to be_within(0.001).of(-40.26738)
|
140
138
|
end
|
141
139
|
|
142
|
-
it
|
143
|
-
spot.y.
|
140
|
+
it 'should parse y' do
|
141
|
+
expect(spot.y).to be_within(0.001).of(-4.9931)
|
144
142
|
end
|
145
143
|
|
146
|
-
it
|
147
|
-
spot.tz.
|
144
|
+
it 'should parse tz' do
|
145
|
+
expect(spot.tz).to eql('America/Fortaleza')
|
148
146
|
end
|
149
147
|
|
150
|
-
it
|
151
|
-
spot.kind.
|
148
|
+
it 'should parse kind' do
|
149
|
+
expect(spot.kind).to eql(:city)
|
152
150
|
end
|
153
151
|
|
154
|
-
it
|
155
|
-
spot.nation.
|
152
|
+
it 'should parse nation' do
|
153
|
+
expect(spot.nation).to eql('BR')
|
156
154
|
end
|
157
155
|
|
158
|
-
it
|
159
|
-
spot.region.
|
156
|
+
it 'should parse region' do
|
157
|
+
expect(spot.region).to eql('06')
|
160
158
|
end
|
161
159
|
|
162
|
-
it
|
163
|
-
spot.pop.
|
160
|
+
it 'should parse pop' do
|
161
|
+
expect(spot.pop).to eql('25455')
|
164
162
|
end
|
165
163
|
|
166
164
|
end
|
167
165
|
|
168
|
-
describe
|
166
|
+
describe 'Parsing Big City' do
|
169
167
|
|
170
168
|
let(:spot) { Spot.new "6322846\tLondrina\tLondrina\t\t-23.58643\t-51.08739\tA\tADM2\tBR\t\t18\t4113700\t\t\t506645\t\t544\tAmerica/Sao_Paulo\t2011-04-21" }
|
171
169
|
|
172
|
-
it
|
173
|
-
spot.name.
|
170
|
+
it 'should parse name' do
|
171
|
+
expect(spot.name).to eql('Londrina')
|
174
172
|
end
|
175
173
|
|
176
|
-
it
|
177
|
-
spot.name.
|
174
|
+
it 'should parse ascii name' do
|
175
|
+
expect(spot.name).to eql('Londrina')
|
178
176
|
end
|
179
177
|
|
180
|
-
it
|
181
|
-
spot.x.
|
178
|
+
it 'should parse x' do
|
179
|
+
expect(spot.x).to be_within(0.001).of(-51.08739)
|
182
180
|
end
|
183
181
|
|
184
|
-
it
|
185
|
-
spot.y.
|
182
|
+
it 'should parse y' do
|
183
|
+
expect(spot.y).to be_within(0.001).of(-23.58643)
|
186
184
|
end
|
187
185
|
|
188
|
-
it
|
189
|
-
spot.tz.
|
186
|
+
it 'should parse tz' do
|
187
|
+
expect(spot.tz).to eql('America/Sao_Paulo')
|
190
188
|
end
|
191
189
|
|
192
|
-
it
|
193
|
-
spot.kind.
|
190
|
+
it 'should parse kind' do
|
191
|
+
expect(spot.kind).to eql(:city)
|
194
192
|
end
|
195
193
|
|
196
|
-
it
|
197
|
-
spot.nation.
|
194
|
+
it 'should parse nation' do
|
195
|
+
expect(spot.nation).to eql('BR')
|
198
196
|
end
|
199
197
|
|
200
|
-
it
|
201
|
-
spot.region.
|
198
|
+
it 'should parse region' do
|
199
|
+
expect(spot.region).to eql('18')
|
202
200
|
end
|
203
201
|
|
204
|
-
it
|
205
|
-
spot.pop.
|
202
|
+
it 'should parse pop' do
|
203
|
+
expect(spot.pop).to eql('506645')
|
206
204
|
end
|
207
205
|
|
208
|
-
|
209
206
|
end
|
210
207
|
|
211
|
-
describe
|
208
|
+
describe 'Parsing Zip' do
|
212
209
|
|
213
210
|
let(:spot) { Geonames::Spot.new("BR\t76375-000\tHidrolina\tGoias\t\t5209804\t29\t\t\t-14.7574\t-49.3596\t\n", :zip) }
|
214
211
|
|
215
|
-
it
|
216
|
-
spot.zip.
|
212
|
+
it 'should parse zip oO' do
|
213
|
+
expect(spot.zip).to eql('76375-000')
|
217
214
|
end
|
218
215
|
|
219
|
-
it
|
220
|
-
spot.kind.
|
216
|
+
it 'should be a city' do
|
217
|
+
expect(spot.kind).to eql(:city)
|
221
218
|
end
|
222
219
|
|
223
|
-
it
|
224
|
-
spot.code.
|
220
|
+
it 'should parse code' do
|
221
|
+
expect(spot.code).to eql('29')
|
225
222
|
end
|
226
223
|
|
227
|
-
it
|
228
|
-
spot.gid.
|
224
|
+
it 'should parse geoid integer' do
|
225
|
+
expect(spot.gid).to be_nil # eql(3384862)
|
229
226
|
end
|
230
227
|
|
231
|
-
it
|
232
|
-
spot.name.
|
233
|
-
spot.ascii.
|
228
|
+
it 'should parse name' do
|
229
|
+
expect(spot.name).to eql('Hidrolina')
|
230
|
+
expect(spot.ascii).to be_nil # eql("Hidrolina")
|
234
231
|
end
|
235
232
|
|
236
|
-
it
|
237
|
-
spot.lat.
|
233
|
+
it 'should parse lat' do
|
234
|
+
expect(spot.lat).to be_within(0.001).of(-14.7574)
|
238
235
|
end
|
239
236
|
|
240
|
-
it
|
241
|
-
spot.lon.
|
237
|
+
it 'should parse lon' do
|
238
|
+
expect(spot.lon).to be_within(0.001).of(-49.3596)
|
242
239
|
end
|
243
240
|
|
244
241
|
end
|
245
242
|
|
246
|
-
describe
|
243
|
+
describe 'From Hash' do
|
247
244
|
|
248
|
-
let(:spot) { Spot.from_hash(
|
245
|
+
let(:spot) { Spot.from_hash('id' => 9, 'name' => 'Sao Rock', 'geom' => [15, 15], 'kind' => 'city', 'nation' => 'BR', 'gid' => 13_232, 'tz' => 'America/Foo', 'ascii' => 'Rock') }
|
249
246
|
|
250
|
-
it
|
251
|
-
spot.
|
247
|
+
it 'should be an spot' do
|
248
|
+
expect(spot).to be_instance_of Spot
|
252
249
|
end
|
253
250
|
|
254
|
-
it
|
255
|
-
spot.name.
|
251
|
+
it 'should set the name' do
|
252
|
+
expect(spot.name).to eql('Sao Rock')
|
256
253
|
end
|
257
254
|
|
258
|
-
it
|
259
|
-
spot.geom.
|
260
|
-
spot.geom.x.
|
255
|
+
it 'should set the geom' do
|
256
|
+
expect(spot.geom).to be_instance_of(GeoRuby::SimpleFeatures::Point)
|
257
|
+
expect(spot.geom.x).to eql(15)
|
261
258
|
end
|
262
259
|
|
263
|
-
it
|
264
|
-
spot.tz.
|
260
|
+
it 'should set the tz' do
|
261
|
+
expect(spot.tz).to eql('America/Foo')
|
265
262
|
end
|
266
263
|
|
267
|
-
it
|
268
|
-
spot.ascii.
|
264
|
+
it 'should set the ascii' do
|
265
|
+
expect(spot.ascii).to eql('Rock')
|
269
266
|
end
|
270
267
|
|
271
|
-
it
|
272
|
-
spot.nation.
|
268
|
+
it 'should set the nation abbr' do
|
269
|
+
expect(spot.nation).to eql('BR')
|
273
270
|
end
|
274
271
|
|
275
272
|
end
|
@@ -1,56 +1,55 @@
|
|
1
|
-
require
|
2
|
-
require "geo_ruby"
|
1
|
+
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Zone do
|
5
4
|
|
6
|
-
describe
|
5
|
+
describe 'Parsing Dump' do
|
7
6
|
|
8
7
|
before do
|
9
8
|
@zone = Zone.new([:name, :null, :geom], "Copacabana\t2\t0106000020E6100000010000000103000020E6100000010000001B000000DE024322029645C0E3263B4536F736C06A78FF7D099745C05F4C17BC3AF836C016ECF835959745C0A6303C5AF6F836C031D79B0DEE9745C02A86A360EDF936C0BBC7A929259845C054515A9559FB36C0050527EF109845C02AD15A3969FC36C0A5705221BD9745C031151F7ACBFC36C0A96DC310049845C0055C26CBE0FC36C0C0FA3CDA6E9845C02424EED2F6FC36C08D80123FF49845C03C190018D7FB36C02E4C5C15199945C0A11ABD694CFB36C00D94B215269945C0F04B5E66CAFA36C03440A3EA169945C029ADE30D51FA36C082988494F89845C06DF6F65FD3F936C0E1CC3ABED39845C00B593959CFF836C0C0ED50117D9845C045937E53F2F736C03440A3EA169945C0CDFE644A93F636C0BA204AE9E29845C0C2EF96F233F636C08C60DFA8C29845C0A38B4DC61DF636C06DA128929D9845C03DE8AF4604F636C047CEF70F499845C08B67D19D49F636C0E87201390A9845C073BEF5F5B5F636C05F50930A799745C0B707094838F636C06CEAA05AAD9645C049A9FD439CF536C034760E48739645C0B9F4FBDC84F536C0F2A307AC159645C0CCEA3108E3F636C0DE024322029645C0E3263B4536F736C0")
|
10
9
|
end
|
11
10
|
|
12
|
-
it
|
13
|
-
@zone.name.
|
11
|
+
it 'should parse code' do
|
12
|
+
expect(@zone.name).to eql('Copacabana')
|
14
13
|
end
|
15
14
|
|
16
|
-
it
|
17
|
-
@zone.kind.
|
15
|
+
it 'should parse kind' do
|
16
|
+
expect(@zone.kind).to eql(:zone)
|
18
17
|
end
|
19
18
|
|
20
|
-
it
|
21
|
-
@zone.geom.
|
19
|
+
it 'should parse geom' do
|
20
|
+
expect(@zone.geom).to be_kind_of(GeoRuby::SimpleFeatures::MultiPolygon)
|
22
21
|
end
|
23
22
|
|
24
|
-
it
|
25
|
-
@zone.geom.
|
23
|
+
it 'should have 1 geometry' do
|
24
|
+
expect(@zone.geom.size).to eq(1)
|
26
25
|
end
|
27
26
|
|
28
|
-
it
|
27
|
+
it 'should have 1 geometry polygon' do
|
29
28
|
geom = @zone.geom.geometries[0]
|
30
|
-
geom.
|
29
|
+
expect(geom).to be_kind_of(GeoRuby::SimpleFeatures::Polygon)
|
31
30
|
end
|
32
31
|
|
33
|
-
it
|
34
|
-
@zone.geom.geometries[0][0].
|
32
|
+
it 'should have 1 geometry polygon with n points' do
|
33
|
+
expect(@zone.geom.geometries[0][0].size).to eq(27)
|
35
34
|
end
|
36
35
|
|
37
36
|
end
|
38
37
|
|
39
|
-
describe
|
38
|
+
describe 'Another parse' do
|
40
39
|
before do
|
41
40
|
@zone = Zone.new([:name, :null, :geom], "Botafogo\t4\t0106000020E6100000010000000103000020E610000001000000260000008C60DFA8C29845C0A38B4DC61DF636C0D68132D5E79845C090FADA554EF536C069D119B12A9945C0D857001102F436C0298D2075189945C0BFEDCBEBA8F336C049DBDD0FFA9845C0EEE2E7537BF336C0D68132D5E79845C0C2DCE6FB5FF336C0A761EE3BB99845C0FD7DA07637F336C048D58ABADF9845C061341567FBF136C0D5CD0D24649845C01D4DDC69AEF136C0106FC79E3B9845C058EE95E485F136C0739E6AE14F9845C043737CCFE3F036C0C10619C0459845C0466297DF9AF036C0BD63D9FE0A9845C0AF6F70421DF036C0A8E8BFE9689745C022C3C82715F036C0AF7A1ABB5A9745C08103515A72F036C0805AD6212C9745C0A04BBB9F39F036C03FFE0258109745C0E861C12D4AF036C0FD2EA4E8CC9645C08103515A72F036C03F62B834969645C0A9913A22AFF036C0C96B208E639645C0875AB5CC30F136C02DFC02077A9645C03E01065281F136C0BD3A35D49B9645C04CFB74214EF136C04048B7CBD99645C0F0F4ABBE6EF136C0ABD7DAF91F9745C0521060C417F236C083C8D321229745C0BC1081D776F236C009643E7BF99645C083E4C80ECAF236C0D16BCFB3BF9645C0EFBC652AD8F236C084595B73599645C07CA67AEF3AF336C0B1592EAC6B9645C0A3A74E6AB4F336C03DAE50A9189645C0D653696356F436C02127B0EE3C9645C070D22BCB62F536C034760E48739645C0B9F4FBDC84F536C06CEAA05AAD9645C049A9FD439CF536C05F50930A799745C0B707094838F636C0E87201390A9845C073BEF5F5B5F636C047CEF70F499845C08B67D19D49F636C06DA128929D9845C03DE8AF4604F636C08C60DFA8C29845C0A38B4DC61DF636C0")
|
42
41
|
end
|
43
42
|
|
44
|
-
it
|
45
|
-
@zone.name.
|
43
|
+
it 'should parse code' do
|
44
|
+
expect(@zone.name).to eql('Botafogo')
|
46
45
|
end
|
47
46
|
|
48
|
-
it
|
49
|
-
@zone.geom.
|
47
|
+
it 'should parse geom' do
|
48
|
+
expect(@zone.geom).to be_kind_of(GeoRuby::SimpleFeatures::MultiPolygon)
|
50
49
|
end
|
51
50
|
|
52
|
-
it
|
53
|
-
@zone.geom.geometries[0][0].
|
51
|
+
it 'should have 1 geometry polygon with n points' do
|
52
|
+
expect(@zone.geom.geometries[0][0].size).to eq(38)
|
54
53
|
end
|
55
54
|
|
56
55
|
end
|
@@ -1,29 +1,29 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Tokyo' do
|
4
4
|
|
5
|
-
# it "should write down a spot" do
|
6
|
-
# t = Geonames::Tokyo.new('localhost', 1978)
|
7
|
-
# m = mock(Geonames::Spot, { :gid => 888, :to_hash => { "gid" => 888, "kind" => "city", "lat" => 5.5 }})
|
8
|
-
# t.write(m)
|
9
|
-
# end
|
5
|
+
# it "should write down a spot" do
|
6
|
+
# t = Geonames::Tokyo.new('localhost', 1978)
|
7
|
+
# m = mock(Geonames::Spot, { :gid => 888, :to_hash => { "gid" => 888, "kind" => "city", "lat" => 5.5 }})
|
8
|
+
# t.write(m)
|
9
|
+
# end
|
10
10
|
|
11
|
-
# it "should read it up" do
|
12
|
-
# t = Geonames::Tokyo.new('localhost', 1978)
|
13
|
-
# record = t.find(888)
|
14
|
-
# record.should be_instance_of Geonames::Spot
|
15
|
-
# end
|
11
|
+
# it "should read it up" do
|
12
|
+
# t = Geonames::Tokyo.new('localhost', 1978)
|
13
|
+
# record = t.find(888)
|
14
|
+
# record.should be_instance_of Geonames::Spot
|
15
|
+
# end
|
16
16
|
|
17
|
-
# it "should not duplicate" do
|
18
|
-
# t = Geonames::Tokyo.new('localhost', 1978)
|
19
|
-
# t.all({ :gid => 888}).length.should eql(1)
|
20
|
-
# end
|
17
|
+
# it "should not duplicate" do
|
18
|
+
# t = Geonames::Tokyo.new('localhost', 1978)
|
19
|
+
# t.all({ :gid => 888}).length.should eql(1)
|
20
|
+
# end
|
21
21
|
|
22
|
-
# it "should return all countries" do
|
23
|
-
# all = Geonames::Nation.all
|
24
|
-
# all.should be_instance_of Array
|
25
|
-
# all[0].should be_instance_of Geonames::Nation
|
26
|
-
# all[0].gid.should eql(1)
|
27
|
-
# end
|
22
|
+
# it "should return all countries" do
|
23
|
+
# all = Geonames::Nation.all
|
24
|
+
# all.should be_instance_of Array
|
25
|
+
# all[0].should be_instance_of Geonames::Nation
|
26
|
+
# all[0].gid.should eql(1)
|
27
|
+
# end
|
28
28
|
|
29
29
|
end
|
data/spec/geonames_local_spec.rb
CHANGED
data/spec/spec_ar_helper.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
require 'geonames_local'
|
4
4
|
require 'geonames_local/cli'
|
5
5
|
require 'rspec'
|
6
|
-
require 'rspec/autorun'
|
7
6
|
include Geonames
|
8
7
|
|
9
|
-
RSpec.configure do |config|
|
10
|
-
|
11
|
-
end
|
8
|
+
# RSpec.configure do |config|
|
9
|
+
# end
|
data/task/benchmark.rb
CHANGED
@@ -11,17 +11,15 @@ require 'geonames_local'
|
|
11
11
|
def b1(db)
|
12
12
|
puts "#{db.count} Objects"
|
13
13
|
Benchmark.bmbm do |b|
|
14
|
-
b.report(
|
15
|
-
b.report(
|
16
|
-
b.report(
|
17
|
-
b.report(
|
14
|
+
b.report('All Country') { db.all(kind: 'country') }
|
15
|
+
b.report('Find by GID') { db.find(888) }
|
16
|
+
b.report('Find by name') { db.all(name: 'Maxaranguape') }
|
17
|
+
b.report('Find on country') { db.all(country: 'CL') }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
print
|
21
|
+
print 'Tyrant => '
|
22
22
|
b1(Geonames::Tokyo.new(:tyrant))
|
23
23
|
|
24
|
-
|
25
|
-
print "Cabinet => "
|
24
|
+
print 'Cabinet => '
|
26
25
|
b1(Geonames::Tokyo.new)
|
27
|
-
|
data/task/benchmark_cabinet.rb
CHANGED
@@ -8,17 +8,15 @@ require 'geonames_local'
|
|
8
8
|
include Geonames
|
9
9
|
# @db.flush
|
10
10
|
|
11
|
-
|
12
11
|
def b1(db)
|
13
12
|
puts "#{db.count} Objects"
|
14
13
|
Benchmark.bmbm do |b|
|
15
|
-
b.report(
|
16
|
-
b.report(
|
17
|
-
b.report(
|
18
|
-
b.report(
|
14
|
+
b.report('All Country') { Country.all }
|
15
|
+
b.report('Find by GID') { db.find(888) }
|
16
|
+
b.report('Find by name') { db.all(name: 'Maxaranguape') }
|
17
|
+
b.report('Find on country') { db.all(country: 'CL') }
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
print
|
21
|
+
print 'Cabinet => '
|
23
22
|
b1(Tokyo.new)
|
24
|
-
|