terragona 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88715c69977bde03e32967c508e4f4a519fecd03
4
+ data.tar.gz: e3fc05839b11f705c3e38ddac17bff854fadb179
5
+ SHA512:
6
+ metadata.gz: bc40ce6a147fdfa8e55eb838b6f1f911a68b821b2e59dfda30618c2b2738c9fbbd8048afacc0eacac8c01ad7851e427d678c30cc3108bf7c686e8792d02c5399
7
+ data.tar.gz: 069423d4fee2ca209821cae9d2e1d43626e2e90b0dbe66a9edb0c8ee7fb1d1550dc297c338296a2d788fbaa737ce926ef409f7d20ea05ba6359c2429db37a891
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 Bruno Salerno
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  terragona
2
2
  =========
3
3
 
4
- Create polygons for [GeoNames](www.geonames.org) places.
4
+ Create polygons for [GeoNames](http://www.geonames.org) places.
5
5
  This means: Create concave polygons using geonames places and store them in a postgres/postgis database.
6
6
  See [ST_Concave_Hull](http://postgis.net/docs/ST_ConcaveHull.html).
7
7
 
@@ -113,6 +113,7 @@ max_points Only for Dump. Max number of points to consider from
113
113
  dump file.
114
114
  default_country Default country.
115
115
  geonames_username Only for API. Geonames API username.
116
+ use_cache Boolean. Default: false.
116
117
  cache_expiration_time Default: 7200.
117
118
  projection Default: EPSG 4326 (WGS84).
118
119
  target_percent Require to draw the concave polygons.
@@ -78,20 +78,28 @@ module Terragona
78
78
  super
79
79
  @username = args[:geonames_username]
80
80
  cache_expiration_time = args[:cache_expiration_time] || 7200
81
- @cache=Diskcached.new('/tmp/cache',cache_expiration_time,true)
81
+ @cache = Diskcached.new('/tmp/cache',cache_expiration_time,true)
82
+ @use_cache = args[:use_cache]
82
83
  end
83
84
 
84
85
  def fetch_geonames(name,country,admin_code_type,admin_code)
85
86
  admin_code_str = admin_code ? "&#{admin_code_type}=#{admin_code}" : ''
86
87
  name_str = name ? "q=#{name}&" : ''
87
88
 
88
- @cache.cache("geonames_name=#{name}&country=#{country}#{admin_code_str}&full666") do
89
- url = URI.escape(%Q{#{URL}?#{name_str}country=#{country}#{admin_code_str}&style=FULL&order_by=relevance&maxRows=1000&username=#{@username}})
90
- request = HTTPI::Request.new(url)
91
- data = HTTPI.get(request)
92
- JSON.parse(data.body,:symbolize_names=>true)[:geonames]
89
+ if @use_cache
90
+ @cache.cache("geonames_name=#{name}&country=#{country}#{admin_code_str}&full666") do
91
+ request(name_str,country,admin_code_str)
92
+ end
93
+ else
94
+ request(name_str,country,admin_code_str)
93
95
  end
94
-
96
+ end
97
+
98
+ def request(name_str,country,admin_code_str)
99
+ url = URI.escape(%Q{#{URL}?#{name_str}country=#{country}#{admin_code_str}&style=FULL&order_by=relevance&maxRows=1000&username=#{@username}})
100
+ request = HTTPI::Request.new(url)
101
+ data = HTTPI.get(request)
102
+ JSON.parse(data.body,:symbolize_names=>true)[:geonames]
95
103
  end
96
104
  end
97
105
 
@@ -1,3 +1,3 @@
1
1
  module Terragona
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,158 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terragona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bruno Salerno
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-04 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: pg
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sequel
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.48.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 3.48.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: httpi
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.1.0
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.1.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: diskcached
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: similar_text
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: 0.0.4
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: 0.0.4
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: geokit
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: bundler
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
103
  version: '1.3'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - "~>"
124
109
  - !ruby/object:Gem::Version
125
110
  version: '1.3'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rake
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: pry-debugger
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  description: Create polygons for geonames places
@@ -162,9 +143,10 @@ executables: []
162
143
  extensions: []
163
144
  extra_rdoc_files: []
164
145
  files:
165
- - .gitignore
146
+ - ".gitignore"
166
147
  - Gemfile
167
148
  - Gemfile.lock
149
+ - LICENSE
168
150
  - README.md
169
151
  - lib/terragona.rb
170
152
  - lib/terragona/base.rb
@@ -175,27 +157,26 @@ files:
175
157
  homepage: https://github.com/BrunoSalerno/terragona
176
158
  licenses:
177
159
  - MIT
160
+ metadata: {}
178
161
  post_install_message:
179
162
  rdoc_options: []
180
163
  require_paths:
181
164
  - lib
182
165
  required_ruby_version: !ruby/object:Gem::Requirement
183
- none: false
184
166
  requirements:
185
- - - ! '>='
167
+ - - ">="
186
168
  - !ruby/object:Gem::Version
187
169
  version: '0'
188
170
  required_rubygems_version: !ruby/object:Gem::Requirement
189
- none: false
190
171
  requirements:
191
- - - ! '>='
172
+ - - ">="
192
173
  - !ruby/object:Gem::Version
193
174
  version: '0'
194
175
  requirements: []
195
176
  rubyforge_project:
196
- rubygems_version: 1.8.23
177
+ rubygems_version: 2.2.2
197
178
  signing_key:
198
- specification_version: 3
179
+ specification_version: 4
199
180
  summary: Use API or dumps as input, draw polygons, and store them in a Postgres/Postgis
200
181
  db
201
182
  test_files: []