cartocss_helper 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8686f0a5acb7db504aec14f93f683c89dfd06248
4
- data.tar.gz: 1f482eba9f389cdceb37e5253c2520a47725128b
3
+ metadata.gz: 8d44210fbbf9317e53a5c01b2b91f9e121523995
4
+ data.tar.gz: 5a4e1209c655ad3168da06877fb77a1baf0d6f39
5
5
  SHA512:
6
- metadata.gz: f23d8415d318009faf84f70e3f6ae1fb63b80033227c340ba3d647c45a0cc86314c4ec76dc4e07e3d5a2a751415b0cb60affa2a6db92351f1cd031492af54a19
7
- data.tar.gz: e86b7bca3b6b4f9f1a84aee7d861d121bb276b1667e7a005d86fc052e1bfe858266da79c2f256de19c3824802fbbcdcf4f33ce2ddd6889f758ff199a0c11d7db
6
+ metadata.gz: 282ff9198c3c1d46c75d0a2b2bc4afb3426e9e2e5f22c01a9a5d51d5ca261da19c8653979af15ef5b72e5fd09de8a56a3c2347716a6c5e261fea6644df9d5071
7
+ data.tar.gz: 8fc86923dff9816152f56e1d4ba667a59e03f6bcdbe398904ae6f04406d3ce699b3a82c792be4698da35899d3203c970c2dd848495a80cea50e482161352ad1d
@@ -2,21 +2,23 @@ require_relative 'util/generic_cached_downloader.rb'
2
2
 
3
3
  module CartoCSSHelper
4
4
  class NotesDownloader
5
+ def self.cache_filename(lat, lon, range)
6
+ url = NotesDownloader.format_query_into_url(lat, lon, range)
7
+ return CartoCSSHelper::Configuration.get_path_to_folder_for_notes_api_cache + url.delete("/") + ".cache"
8
+ end
9
+
5
10
  def self.run_note_query(lat, lon, range, invalidate_cache: false)
6
11
  timeout = NotesDownloader.get_allowed_timeout_in_seconds
7
12
  downloader = GenericCachedDownloader.new(timeout: timeout, stop_on_timeout: false)
8
-
13
+ file = cache_filename(lat, lon, range)
9
14
  url = NotesDownloader.format_query_into_url(lat, lon, range)
10
- cache_filename = CartoCSSHelper::Configuration.get_path_to_folder_for_notes_api_cache + url.delete("/") + ".cache"
11
- return downloader.get_specified_resource(url, cache_filename, invalidate_cache: invalidate_cache)
15
+ return downloader.get_specified_resource(url, file, invalidate_cache: invalidate_cache)
12
16
  end
13
17
 
14
18
  def self.cache_timestamp(lat, lon, range)
15
19
  downloader = GenericCachedDownloader.new
16
-
17
- url = NotesDownloader.format_query_into_url(lat, lon, range)
18
- cache_filename = CartoCSSHelper::Configuration.get_path_to_folder_for_notes_api_cache + url.delete("/") + ".cache"
19
- return downloader.get_cache_timestamp(cache_filename)
20
+ file = cache_filename(lat, lon, range)
21
+ return downloader.get_cache_timestamp(file)
20
22
  end
21
23
 
22
24
  def self.get_allowed_timeout_in_seconds
@@ -1,16 +1,28 @@
1
1
  require_relative 'util/generic_downloader.rb'
2
2
  require_relative 'util/generic_cached_downloader.rb'
3
3
  require 'uri' # for URI.escape
4
+ require 'digest/sha1'
4
5
 
5
6
  module CartoCSSHelper
6
7
  class OverpassDownloader
7
8
  class OverpassRefusedResponse < IOError; end
8
9
 
9
- def self.run_overpass_query(query, description, cache_filename)
10
+ def self.cache_filename(query)
11
+ hash = Digest::SHA1.hexdigest query
12
+ query_cache_filename = CartoCSSHelper::Configuration.get_path_to_folder_for_overpass_cache + hash + '_query.cache'
13
+ return query_cache_filename
14
+ end
15
+
16
+ def self.cache_timestamp(query)
17
+ downloader = GenericCachedDownloader.new
18
+ return downloader.get_cache_timestamp(cache_filename(query))
19
+ end
20
+
21
+ def self.run_overpass_query(query, description, invalidate_cache: false)
10
22
  url = OverpassDownloader.format_query_into_url(query)
11
23
  timeout = OverpassDownloader.get_allowed_timeout_in_seconds
12
24
  downloader = GenericCachedDownloader.new(timeout: timeout, stop_on_timeout: false)
13
- return downloader.get_specified_resource(url, cache_filename, description: description)
25
+ return downloader.get_specified_resource(url, cache_filename(query), description: description, invalidate_cache: invalidate_cache)
14
26
  rescue RequestTimeout => e
15
27
  puts 'Overpass API refused to process this request. It will be not attempted again, most likely query is too complex. It is also possible that Overpass servers are unavailable'
16
28
  puts
@@ -3,6 +3,7 @@ require 'digest/sha1'
3
3
  require 'sys/filesystem'
4
4
  require_relative 'overpass_downloader.rb'
5
5
  require_relative 'util/systemhelper.rb'
6
+ require_relative 'util/logger.rb'
6
7
 
7
8
  module CartoCSSHelper
8
9
  class OverpassQueryGenerator
@@ -48,7 +49,7 @@ module CartoCSSHelper
48
49
  description = "download data for #{latitude} #{longitude} (#{size})"
49
50
  get_overpass_query_results(query, description)
50
51
 
51
- filename = get_query_cache_filename(query)
52
+ filename = OverpassDownloader.cache_filename(query)
52
53
  return filename
53
54
  end
54
55
 
@@ -184,7 +185,7 @@ module CartoCSSHelper
184
185
  end
185
186
 
186
187
  def self.get_query_cache_refused_response_filename(query)
187
- return get_query_cache_filename(query) + '_response_refused'
188
+ return OverpassDownloader.cache_filename(query) + '_response_refused'
188
189
  end
189
190
 
190
191
  def self.mark_query_as_refused(query)
@@ -193,13 +194,12 @@ module CartoCSSHelper
193
194
  file.close
194
195
  end
195
196
 
196
- def self.get_query_cache_filename(query)
197
- hash = Digest::SHA1.hexdigest query
198
- query_cache_filename = CartoCSSHelper::Configuration.get_path_to_folder_for_overpass_cache + hash + '_query.cache'
199
- return query_cache_filename
197
+ def self.get_query_cache_filename(_query)
198
+ Log.warn "call OverpassDownloader.cache_filename directly"
199
+ return OverpassDownloader.cache_filename
200
200
  end
201
201
 
202
- def self.get_overpass_query_results(query, description, debug = false)
202
+ def self.get_overpass_query_results(query, description, debug = false, invalidate_cache: false) # TODO: - make debug parameter named
203
203
  if File.exist?(get_query_cache_refused_response_filename(query))
204
204
  raise OverpassDownloader::OverpassRefusedResponse
205
205
  end
@@ -207,14 +207,13 @@ module CartoCSSHelper
207
207
  check_for_free_space
208
208
 
209
209
  if debug
210
- puts query
211
- puts
210
+ Log.info query
211
+ Log.info
212
212
  end
213
213
 
214
- cache_filename = get_query_cache_filename(query)
215
214
  description = 'Running Overpass query (connection initiated on ' + Time.now.to_s + ') ' + description
216
215
  begin
217
- return OverpassDownloader.run_overpass_query query, description, cache_filename
216
+ return OverpassDownloader.run_overpass_query query, description, invalidate_cache: invalidate_cache
218
217
  rescue OverpassDownloader::OverpassRefusedResponse
219
218
  mark_query_as_refused(query)
220
219
  raise OverpassDownloader::OverpassRefusedResponse
@@ -237,6 +237,7 @@ module CartoCSSHelper
237
237
  TagRenderingStatus.new('layer', '-4', :composite, { 'highway' => 'service' }), # modifies ordering
238
238
  TagRenderingStatus.new('layer', '-5', :composite, { 'highway' => 'service' }), # modifies ordering
239
239
  TagRenderingStatus.new('leisure', 'common', :primary),
240
+ TagRenderingStatus.new('leisure', 'dog_park', :primary),
240
241
  TagRenderingStatus.new('leisure', 'garden', :primary),
241
242
  TagRenderingStatus.new('leisure', 'golf_course', :primary),
242
243
  TagRenderingStatus.new('leisure', 'marina', :primary),
@@ -261,6 +262,7 @@ module CartoCSSHelper
261
262
  TagRenderingStatus.new('man_made', 'groyne', :primary),
262
263
  TagRenderingStatus.new('man_made', 'lighthouse', :primary),
263
264
  TagRenderingStatus.new('man_made', 'mast', :primary),
265
+ TagRenderingStatus.new('man_made', 'obelisk', :primary),
264
266
  TagRenderingStatus.new('man_made', 'pier', :primary),
265
267
  TagRenderingStatus.new('man_made', 'water_tower', :primary),
266
268
  TagRenderingStatus.new('man_made', 'windmill', :primary),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartocss_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Konieczny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-15 00:00:00.000000000 Z
11
+ date: 2016-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client