cartocss_helper 5.2.0 → 5.3.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
  SHA256:
3
- metadata.gz: de353ff0f5a1fe946a3e7e782c185570587fdf097afce030a352909772195b79
4
- data.tar.gz: 0327dbf4cdbabc8671292766f120c83468d24334fa16475410e82a2cef3f8900
3
+ metadata.gz: 24a2a7383e9f2b78c6cf6030f0364646a7a1b5334a0b6045ae7e87c8f64cd80d
4
+ data.tar.gz: e128e7c79ab18d866e75e9f6ad6c750a7b3bd966cff179beec672f1f48efb0db
5
5
  SHA512:
6
- metadata.gz: c1d4815aac6fe77f2735f1b106d8318794f6d8e705768207b902b73666cabbfc4ed9f4a953fb92a54d3d0d091ad162f79309f884f51aae6fb880741b0ac28f1d
7
- data.tar.gz: d7240dd1d35eccac5151b576dea66f86483b0944b12c508fce3f87725cde37029eaaaf2c60dab11e43b097f42c39bcf89b9ed9fe54653d5f3d134630f808b2c1
6
+ metadata.gz: 9178c18bea33811ed65f5bef2f08f7553291a46ce2d37e6550d7d878b9d8eed8217c23e63a2a991e8c59fc54a3912b66d76df107dc391f312b71ef0604b6acfe
7
+ data.tar.gz: 4a4b630a3b59b43680c4832e1afb7e059301afb8cd0576ebe57d14fff220857ca1f8289d3547af802d8d4946e87676e4dc76776f2579c3b54e4c0df7da4f95a2
@@ -42,8 +42,8 @@ module CartoCSSHelper
42
42
  puts
43
43
  puts url
44
44
  puts
45
- puts "url with %20 replaced back by spaces, %22 by \""
46
- puts url.replace("%20", " ").replace("%22", '"')
45
+ puts "url with %20 replaced back by spaces, %22 by \", newline by %0A"
46
+ puts url.replace("%20", " ").replace("%22", '"').replace("\n", "%0A")
47
47
  puts
48
48
  puts e
49
49
  elsif e.http_code == 414
@@ -66,15 +66,14 @@ module CartoCSSHelper
66
66
  query = query.gsub('\\', '\\\\')
67
67
 
68
68
  # newlines, tabs added in query for readability may be safely deleted
69
- query = query.delete("\n")
69
+ #query = query.delete("\n") - can be escaped! Results in nicer Overpass failures
70
70
  query = query.delete("\t")
71
71
 
72
72
  #query = URI.escape(query) # no escaping for / [add require 'uri' to use it]
73
73
  #query = URI.escape(query, "/") # escapes only / [add require 'uri' to use it]
74
74
  #query = CGI.escape(query) # escapes spaces to + sign
75
-
76
75
  query = Addressable::URI.encode_component(query, Addressable::URI::CharacterClasses::QUERY)
77
- query = query.gsub("/", "%2F") # escape slashes manually
76
+ query = query.gsub("/", "%2F") # escape slashes manually
78
77
 
79
78
  # inside query also & and + must be escaped (entire query is an url parameter)
80
79
  query = query.gsub("&", "%26")
@@ -33,35 +33,35 @@ module CartoCSSHelper
33
33
  return "#{min_latitude},#{min_longitude},#{max_latitude},#{max_longitude}"
34
34
  end
35
35
 
36
- def self.find_data_pair(tags_a, tags_b, latitude, longitude, type_a, type_b, bb_size: 0.1, distance_in_meters: 20)
36
+ def self.find_data_pair(tags_a, tags_b, latitude, longitude, type_a, type_b, bb_size: 0.1, distance_in_meters: 20, invalidate_cache: false)
37
37
  return nil, nil if bb_size > 0.5
38
38
  bb = overpass_bbox_string(latitude, longitude, bb_size.to_f)
39
39
  query = OverpassQueryGenerator.get_query_to_find_data_pair(bb, tags_a, tags_b, type_a, type_b, distance_in_meters: distance_in_meters)
40
40
  description = "find #{VisualDiff.tag_dict_to_string(tags_a)} nearby #{VisualDiff.tag_dict_to_string(tags_b)} - bb size: #{bb_size}"
41
- list = OverpassQueryGenerator.get_overpass_query_results(query, description)
41
+ list = OverpassQueryGenerator.get_overpass_query_results(query, description, invalidate_cache: invalidate_cache)
42
42
  if list.length != 0
43
43
  return OverpassQueryGenerator.list_returned_by_overpass_to_a_single_location(list)
44
44
  end
45
45
  return OverpassQueryGenerator.find_data_pair(tags_a, tags_b, latitude, longitude, type_a, type_b, bb_size: bb_size * 2, distance_in_meters: distance_in_meters)
46
46
  end
47
47
 
48
- def self.get_file_with_downloaded_osm_data_for_location(latitude, longitude, size)
48
+ def self.get_file_with_downloaded_osm_data_for_location(latitude, longitude, size, invalidate_cache: false)
49
49
  query = get_query_to_download_data_around_location(latitude, longitude, size)
50
50
  description = "download data for #{latitude} #{longitude} (#{size})"
51
- get_overpass_query_results(query, description)
51
+ get_overpass_query_results(query, description, invalidate_cache: invalidate_cache)
52
52
 
53
53
  filename = OverpassDownloader.cache_filename(query)
54
54
  return filename
55
55
  end
56
56
 
57
- def self.download_osm_data_for_location(latitude, longitude, size, accept_cache = true)
57
+ def self.download_osm_data_for_location(latitude, longitude, size, accept_cache = true) # TODO: conflict with invalidate_cache
58
58
  filename = CartoCSSHelper::Configuration.get_path_to_folder_for_cache + "#{latitude} #{longitude} #{size}.osm"
59
59
  if File.exist?(filename)
60
60
  return filename if accept_cache
61
61
  SystemHelper.delete_file(filename, 'query refusing to accept cache was used')
62
62
  end
63
63
  query = get_query_to_download_data_around_location(latitude, longitude, size)
64
- text = get_overpass_query_results(query, "download data for #{latitude} #{longitude} (#{size})")
64
+ text = get_overpass_query_results(query, "download data for #{latitude} #{longitude} (#{size})", invalidate_cache: false)
65
65
  File.new(filename, 'w') do |file|
66
66
  file.write text
67
67
  end
@@ -85,17 +85,17 @@ module CartoCSSHelper
85
85
  return query
86
86
  end
87
87
 
88
- def self.get_elements_near_given_location(tags, type, latitude, longitude, range_in_meters)
88
+ def self.get_elements_near_given_location(tags, type, latitude, longitude, range_in_meters, invalidate_cache: false)
89
89
  description = "find #{tags} #{type} within #{range_in_meters / 1000}km from #{latitude}, #{longitude}"
90
90
  query = OverpassQueryGenerator.get_query_to_get_location(tags, type, latitude, longitude, range_in_meters)
91
- list = OverpassQueryGenerator.get_overpass_query_results(query, description)
91
+ list = OverpassQueryGenerator.get_overpass_query_results(query, description, invalidate_cache: invalidate_cache)
92
92
  return list_returned_by_overpass_to_array(list)
93
93
  end
94
94
 
95
- def self.get_elements_across_world(tags, type)
95
+ def self.get_elements_across_world(tags, type, invalidate_cache: false)
96
96
  description = "find #{tags} #{type} across the world"
97
97
  query = OverpassQueryGenerator.get_query_to_get_location(tags, type, 0, 0, :infinity)
98
- list = OverpassQueryGenerator.get_overpass_query_results(query, description)
98
+ list = OverpassQueryGenerator.get_overpass_query_results(query, description, invalidate_cache: invalidate_cache)
99
99
  return list_returned_by_overpass_to_array(list)
100
100
  end
101
101
 
@@ -245,6 +245,8 @@ module CartoCSSHelper
245
245
 
246
246
  def self.get_overpass_query_results(query, description, debug = false, invalidate_cache: false) # TODO: - make debug parameter named
247
247
  if File.exist?(get_query_cache_refused_response_filename(query))
248
+ puts("response cached as failed")
249
+ puts(get_query_cache_refused_response_filename(query))
248
250
  raise OverpassDownloader::OverpassRefusedResponse
249
251
  end
250
252
 
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: 5.2.0
4
+ version: 5.3.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: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client