cartocss_helper 4.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
 - data/lib/cartocss_helper.rb +3 -1
 - data/lib/cartocss_helper/configuration.rb +8 -1
 - data/lib/cartocss_helper/data_file_handling.rb +2 -1
 - data/lib/cartocss_helper/git.rb +2 -0
 - data/lib/cartocss_helper/heuristic.rb +2 -0
 - data/lib/cartocss_helper/history_downloader.rb +35 -0
 - data/lib/cartocss_helper/image_generator.rb +2 -1
 - data/lib/cartocss_helper/notes_downloader.rb +11 -11
 - data/lib/cartocss_helper/overpass_downloader.rb +62 -6
 - data/lib/cartocss_helper/overpass_query_generator.rb +69 -26
 - data/lib/cartocss_helper/renderer_handler.rb +5 -1
 - data/lib/cartocss_helper/style_specific/default_osm_style.rb +4 -0
 - data/lib/cartocss_helper/style_specific/style_specific.rb +2 -0
 - data/lib/cartocss_helper/tag_lister.rb +2 -0
 - data/lib/cartocss_helper/util/filehelper.rb +2 -1
 - data/lib/cartocss_helper/util/generic_cached_downloader.rb +2 -0
 - data/lib/cartocss_helper/util/generic_downloader.rb +7 -1
 - data/lib/cartocss_helper/util/logger.rb +2 -0
 - data/lib/cartocss_helper/util/rest-client_wrapper.rb +5 -2
 - data/lib/cartocss_helper/util/systemhelper.rb +2 -0
 - data/lib/cartocss_helper/validator.rb +2 -1
 - data/lib/cartocss_helper/visualise_changes_diff_from_images.rb +2 -0
 - data/lib/cartocss_helper/visualise_changes_image_generation.rb +4 -9
 - data/lib/data/testing_locations.rb +2 -0
 - data/readme.md +12 -5
 - metadata +21 -27
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: de353ff0f5a1fe946a3e7e782c185570587fdf097afce030a352909772195b79
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 0327dbf4cdbabc8671292766f120c83468d24334fa16475410e82a2cef3f8900
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c1d4815aac6fe77f2735f1b106d8318794f6d8e705768207b902b73666cabbfc4ed9f4a953fb92a54d3d0d091ad162f79309f884f51aae6fb880741b0ac28f1d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d7240dd1d35eccac5151b576dea66f86483b0944b12c508fce3f87725cde37029eaaaf2c60dab11e43b097f42c39bcf89b9ed9fe54653d5f3d134630f808b2c1
         
     | 
    
        data/lib/cartocss_helper.rb
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       2 
3 
     | 
    
         
             
            require 'open3'
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
            module CartoCSSHelper
         
     | 
| 
         @@ -11,6 +12,7 @@ require_relative 'cartocss_helper/validator.rb' 
     | 
|
| 
       11 
12 
     | 
    
         
             
            require_relative 'cartocss_helper/git.rb'
         
     | 
| 
       12 
13 
     | 
    
         
             
            require_relative 'cartocss_helper/util/generic_downloader.rb'
         
     | 
| 
       13 
14 
     | 
    
         
             
            require_relative 'cartocss_helper/notes_downloader.rb'
         
     | 
| 
      
 15 
     | 
    
         
            +
            require_relative 'cartocss_helper/history_downloader.rb'
         
     | 
| 
       14 
16 
     | 
    
         
             
            require_relative 'cartocss_helper/style_specific/default_osm_style.rb'
         
     | 
| 
       15 
17 
     | 
    
         
             
            require_relative 'data/testing_locations'
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       2 
3 
     | 
    
         
             
            require 'fileutils'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'find'
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
         @@ -102,6 +103,12 @@ module CartoCSSHelper::Configuration 
     | 
|
| 
       102 
103 
     | 
    
         
             
                return location
         
     | 
| 
       103 
104 
     | 
    
         
             
              end
         
     | 
| 
       104 
105 
     | 
    
         | 
| 
      
 106 
     | 
    
         
            +
              def get_path_to_folder_for_history_api_cache
         
     | 
| 
      
 107 
     | 
    
         
            +
                location = File.join(get_path_to_folder_for_cache, 'history-api', '')
         
     | 
| 
      
 108 
     | 
    
         
            +
                FileUtils.mkdir_p location
         
     | 
| 
      
 109 
     | 
    
         
            +
                return location
         
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
       105 
112 
     | 
    
         
             
              def get_data_filename
         
     | 
| 
       106 
113 
     | 
    
         
             
                return get_path_to_folder_for_branch_specific_cache + 'data.osm'
         
     | 
| 
       107 
114 
     | 
    
         
             
              end
         
     | 
    
        data/lib/cartocss_helper/git.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative 'util/generic_cached_downloader.rb'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module CartoCSSHelper
         
     | 
| 
      
 6 
     | 
    
         
            +
              class HistoryDownloader
         
     | 
| 
      
 7 
     | 
    
         
            +
                def self.cache_filename(type, id)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  url = HistoryDownloader.format_query_into_url(type, id)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  return CartoCSSHelper::Configuration.get_path_to_folder_for_history_api_cache + url.delete("/") + ".cache"
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def self.run_history_query(type, id, invalidate_cache: false)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  timeout = HistoryDownloader.get_allowed_timeout_in_seconds
         
     | 
| 
      
 14 
     | 
    
         
            +
                  downloader = GenericCachedDownloader.new(timeout: timeout, stop_on_timeout: false)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  file = cache_filename(type, id)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  url = HistoryDownloader.format_query_into_url(type, id)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  return downloader.get_specified_resource(url, file, invalidate_cache: invalidate_cache)
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                def self.cache_timestamp(type, id)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  downloader = GenericCachedDownloader.new
         
     | 
| 
      
 22 
     | 
    
         
            +
                  file = cache_filename(type, id)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  return downloader.get_cache_timestamp(file)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def self.get_allowed_timeout_in_seconds
         
     | 
| 
      
 27 
     | 
    
         
            +
                  return 10 * 60
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                def self.format_query_into_url(type, id)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  # documentated at https://wiki.openstreetmap.org/wiki/API_v0.6
         
     | 
| 
      
 32 
     | 
    
         
            +
                  return "http://api.openstreetmap.org/api/0.6/#{type}/#{id}/history"
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,22 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require_relative 'util/generic_cached_downloader.rb'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            module CartoCSSHelper
         
     | 
| 
       4 
6 
     | 
    
         
             
              class NotesDownloader
         
     | 
| 
      
 7 
     | 
    
         
            +
                def self.cache_filename(lat, lon, range)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  url = NotesDownloader.format_query_into_url(lat, lon, range)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  return CartoCSSHelper::Configuration.get_path_to_folder_for_notes_api_cache + url.delete("/") + ".cache"
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       5 
12 
     | 
    
         
             
                def self.run_note_query(lat, lon, range, invalidate_cache: false)
         
     | 
| 
       6 
13 
     | 
    
         
             
                  timeout = NotesDownloader.get_allowed_timeout_in_seconds
         
     | 
| 
       7 
14 
     | 
    
         
             
                  downloader = GenericCachedDownloader.new(timeout: timeout, stop_on_timeout: false)
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                  file = cache_filename(lat, lon, range)
         
     | 
| 
       9 
16 
     | 
    
         
             
                  url = NotesDownloader.format_query_into_url(lat, lon, range)
         
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
       11 
     | 
    
         
            -
                  return downloader.get_specified_resource(url, cache_filename, invalidate_cache: invalidate_cache)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  return downloader.get_specified_resource(url, file, invalidate_cache: invalidate_cache)
         
     | 
| 
       12 
18 
     | 
    
         
             
                end
         
     | 
| 
       13 
19 
     | 
    
         | 
| 
       14 
20 
     | 
    
         
             
                def self.cache_timestamp(lat, lon, range)
         
     | 
| 
       15 
21 
     | 
    
         
             
                  downloader = GenericCachedDownloader.new
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
       18 
     | 
    
         
            -
                  cache_filename = CartoCSSHelper::Configuration.get_path_to_folder_for_notes_api_cache + url.delete("/") + ".cache"
         
     | 
| 
       19 
     | 
    
         
            -
                  return downloader.get_cache_timestamp(cache_filename)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  file = cache_filename(lat, lon, range)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  return downloader.get_cache_timestamp(file)
         
     | 
| 
       20 
24 
     | 
    
         
             
                end
         
     | 
| 
       21 
25 
     | 
    
         | 
| 
       22 
26 
     | 
    
         
             
                def self.get_allowed_timeout_in_seconds
         
     | 
| 
         @@ -38,9 +42,5 @@ module CartoCSSHelper 
     | 
|
| 
       38 
42 
     | 
    
         
             
                  max_longitude = longitude + size / 2
         
     | 
| 
       39 
43 
     | 
    
         
             
                  return "#{min_longitude},#{min_latitude},#{max_longitude},#{max_latitude}"
         
     | 
| 
       40 
44 
     | 
    
         
             
                end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                def self.get_overpass_instance_url
         
     | 
| 
       43 
     | 
    
         
            -
                  return CartoCSSHelper::Configuration.get_overpass_instance_url
         
     | 
| 
       44 
     | 
    
         
            -
                end
         
     | 
| 
       45 
45 
     | 
    
         
             
              end
         
     | 
| 
       46 
46 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,16 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require_relative 'util/generic_downloader.rb'
         
     | 
| 
       2 
4 
     | 
    
         
             
            require_relative 'util/generic_cached_downloader.rb'
         
     | 
| 
       3 
     | 
    
         
            -
            require ' 
     | 
| 
      
 5 
     | 
    
         
            +
            require 'digest/sha1'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'addressable/uri'
         
     | 
| 
       4 
7 
     | 
    
         | 
| 
       5 
8 
     | 
    
         
             
            module CartoCSSHelper
         
     | 
| 
       6 
9 
     | 
    
         
             
              class OverpassDownloader
         
     | 
| 
       7 
10 
     | 
    
         
             
                class OverpassRefusedResponse < IOError; end
         
     | 
| 
       8 
11 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                def self. 
     | 
| 
      
 12 
     | 
    
         
            +
                def self.cache_filename(query)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  hash = Digest::SHA1.hexdigest query
         
     | 
| 
      
 14 
     | 
    
         
            +
                  query_cache_filename = CartoCSSHelper::Configuration.get_path_to_folder_for_overpass_cache + hash + '_query.cache'
         
     | 
| 
      
 15 
     | 
    
         
            +
                  return query_cache_filename
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def self.cache_timestamp(query)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  downloader = GenericCachedDownloader.new
         
     | 
| 
      
 20 
     | 
    
         
            +
                  return downloader.get_cache_timestamp(cache_filename(query))
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                def self.run_overpass_query(query, description, invalidate_cache: false)
         
     | 
| 
       10 
24 
     | 
    
         
             
                  url = OverpassDownloader.format_query_into_url(query)
         
     | 
| 
       11 
25 
     | 
    
         
             
                  timeout = OverpassDownloader.get_allowed_timeout_in_seconds
         
     | 
| 
       12 
26 
     | 
    
         
             
                  downloader = GenericCachedDownloader.new(timeout: timeout, stop_on_timeout: false)
         
     | 
| 
       13 
     | 
    
         
            -
                  return downloader.get_specified_resource(url, cache_filename, description: description)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  return downloader.get_specified_resource(url, cache_filename(query), description: description, invalidate_cache: invalidate_cache)
         
     | 
| 
       14 
28 
     | 
    
         
             
                rescue RequestTimeout => e
         
     | 
| 
       15 
29 
     | 
    
         
             
                  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 
30 
     | 
    
         
             
                  puts
         
     | 
| 
         @@ -20,19 +34,61 @@ module CartoCSSHelper 
     | 
|
| 
       20 
34 
     | 
    
         
             
                  puts
         
     | 
| 
       21 
35 
     | 
    
         
             
                  puts e
         
     | 
| 
       22 
36 
     | 
    
         
             
                  raise OverpassRefusedResponse
         
     | 
| 
      
 37 
     | 
    
         
            +
                rescue ExceptionWithResponse => e
         
     | 
| 
      
 38 
     | 
    
         
            +
                  if e.http_code == 400
         
     | 
| 
      
 39 
     | 
    
         
            +
                    puts "invalid query"
         
     | 
| 
      
 40 
     | 
    
         
            +
                    puts
         
     | 
| 
      
 41 
     | 
    
         
            +
                    puts query
         
     | 
| 
      
 42 
     | 
    
         
            +
                    puts
         
     | 
| 
      
 43 
     | 
    
         
            +
                    puts url
         
     | 
| 
      
 44 
     | 
    
         
            +
                    puts
         
     | 
| 
      
 45 
     | 
    
         
            +
                    puts "url with %20 replaced back by spaces, %22 by \""
         
     | 
| 
      
 46 
     | 
    
         
            +
                    puts url.replace("%20", " ").replace("%22", '"')
         
     | 
| 
      
 47 
     | 
    
         
            +
                    puts
         
     | 
| 
      
 48 
     | 
    
         
            +
                    puts e
         
     | 
| 
      
 49 
     | 
    
         
            +
                  elsif e.http_code == 414
         
     | 
| 
      
 50 
     | 
    
         
            +
                    puts 'see https://github.com/matkoniecz/CartoCSSHelper/issues/35'
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
                  raise e
         
     | 
| 
       23 
53 
     | 
    
         
             
                end
         
     | 
| 
       24 
54 
     | 
    
         | 
| 
       25 
55 
     | 
    
         
             
                def self.get_allowed_timeout_in_seconds
         
     | 
| 
       26 
56 
     | 
    
         
             
                  return 10 * 60
         
     | 
| 
       27 
57 
     | 
    
         
             
                end
         
     | 
| 
       28 
58 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
                def self. 
     | 
| 
       30 
     | 
    
         
            -
                   
     | 
| 
      
 59 
     | 
    
         
            +
                def self.escape_query(query)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  # code causing bug - (// inside quotes, as predicted) - why it was even added?
         
     | 
| 
      
 61 
     | 
    
         
            +
                  #query = query.gsub(/\/\/.*\n/, '') # add proper parsing - it will mutilate // inside quotes etc
         
     | 
| 
      
 62 
     | 
    
         
            +
                  # TODO: replace complaint above by a test
         
     | 
| 
      
 63 
     | 
    
         
            +
                  # maybe URI.escape(query, "/") is sufficient?
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  # escape backslash - turns \ into \\
         
     | 
| 
       31 
66 
     | 
    
         
             
                  query = query.gsub('\\', '\\\\')
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  # newlines, tabs added in query for readability may be safely deleted
         
     | 
| 
       32 
69 
     | 
    
         
             
                  query = query.delete("\n")
         
     | 
| 
       33 
70 
     | 
    
         
             
                  query = query.delete("\t")
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  #query = URI.escape(query) # no escaping for / [add require 'uri' to use it]
         
     | 
| 
      
 73 
     | 
    
         
            +
                  #query = URI.escape(query, "/") # escapes only / [add require 'uri' to use it]
         
     | 
| 
      
 74 
     | 
    
         
            +
                  #query = CGI.escape(query) # escapes spaces to + sign
         
     | 
| 
      
 75 
     | 
    
         
            +
                  
         
     | 
| 
      
 76 
     | 
    
         
            +
                  query = Addressable::URI.encode_component(query, Addressable::URI::CharacterClasses::QUERY)
         
     | 
| 
      
 77 
     | 
    
         
            +
                        query = query.gsub("/", "%2F") # escape slashes manually
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  # inside query also & and + must be escaped (entire query is an url parameter)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  query = query.gsub("&", "%26")
         
     | 
| 
      
 81 
     | 
    
         
            +
                  query = query.gsub('+', '%2B')
         
     | 
| 
      
 82 
     | 
    
         
            +
                  return query
         
     | 
| 
      
 83 
     | 
    
         
            +
                end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                def self.format_query_into_url(query)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  query = escape_query(query)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  if query.length > 8174 #8175 is too much and allows crashes
         
     | 
| 
      
 88 
     | 
    
         
            +
                    raise 'see https://github.com/matkoniecz/CartoCSSHelper/issues/35'
         
     | 
| 
      
 89 
     | 
    
         
            +
                  end
         
     | 
| 
       34 
90 
     | 
    
         
             
                  base_overpass_url = OverpassDownloader.get_overpass_instance_url
         
     | 
| 
       35 
     | 
    
         
            -
                  return base_overpass_url + '/interpreter?data=' +  
     | 
| 
      
 91 
     | 
    
         
            +
                  return base_overpass_url + '/interpreter?data=' + query
         
     | 
| 
       36 
92 
     | 
    
         
             
                end
         
     | 
| 
       37 
93 
     | 
    
         | 
| 
       38 
94 
     | 
    
         
             
                def self.get_overpass_instance_url
         
     | 
| 
         @@ -1,8 +1,10 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       2 
3 
     | 
    
         
             
            require 'digest/sha1'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'sys/filesystem'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require_relative 'overpass_downloader.rb'
         
     | 
| 
       5 
6 
     | 
    
         
             
            require_relative 'util/systemhelper.rb'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require_relative 'util/logger.rb'
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
            module CartoCSSHelper
         
     | 
| 
       8 
10 
     | 
    
         
             
              class OverpassQueryGenerator
         
     | 
| 
         @@ -48,7 +50,7 @@ module CartoCSSHelper 
     | 
|
| 
       48 
50 
     | 
    
         
             
                  description = "download data for #{latitude} #{longitude} (#{size})"
         
     | 
| 
       49 
51 
     | 
    
         
             
                  get_overpass_query_results(query, description)
         
     | 
| 
       50 
52 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                  filename =  
     | 
| 
      
 53 
     | 
    
         
            +
                  filename = OverpassDownloader.cache_filename(query)
         
     | 
| 
       52 
54 
     | 
    
         
             
                  return filename
         
     | 
| 
       53 
55 
     | 
    
         
             
                end
         
     | 
| 
       54 
56 
     | 
    
         | 
| 
         @@ -98,7 +100,7 @@ module CartoCSSHelper 
     | 
|
| 
       98 
100 
     | 
    
         
             
                end
         
     | 
| 
       99 
101 
     | 
    
         | 
| 
       100 
102 
     | 
    
         
             
                def self.locate_element_with_given_tags_and_type(tags, type, latitude, longitude, max_range_in_km_for_radius = 1600)
         
     | 
| 
       101 
     | 
    
         
            -
                  # special support for  
     | 
| 
      
 103 
     | 
    
         
            +
                  # special support for some tag values - see CartoCSSHelper::OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter for details
         
     | 
| 
       102 
104 
     | 
    
         
             
                  range = 10 * 1000
         
     | 
| 
       103 
105 
     | 
    
         
             
                  while range <= max_range_in_km_for_radius * 1000
         
     | 
| 
       104 
106 
     | 
    
         
             
                    list = OverpassQueryGenerator.get_elements_near_given_location(tags, type, latitude, longitude, range)
         
     | 
| 
         @@ -133,8 +135,12 @@ module CartoCSSHelper 
     | 
|
| 
       133 
135 
     | 
    
         
             
                  return get_query_to_get_location_set_format(tags, type, latitude, longitude, range, "[out:csv(::lat,::lon;false)]")
         
     | 
| 
       134 
136 
     | 
    
         
             
                end
         
     | 
| 
       135 
137 
     | 
    
         | 
| 
      
 138 
     | 
    
         
            +
                # TODO: better, more generic function name
         
     | 
| 
      
 139 
     | 
    
         
            +
                # get_query_to_get_objects_matching?
         
     | 
| 
      
 140 
     | 
    
         
            +
                # put latitude, longitude, range together to avoid passing dummy variables
         
     | 
| 
       136 
141 
     | 
    
         
             
                def self.get_query_to_get_location_set_format(tags, type, latitude, longitude, range, format)
         
     | 
| 
       137 
     | 
    
         
            -
                  # special support for  
     | 
| 
      
 142 
     | 
    
         
            +
                  # special support for range == :infinity
         
     | 
| 
      
 143 
     | 
    
         
            +
                  # special support for some tag values - see CartoCSSHelper::OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter for details
         
     | 
| 
       138 
144 
     | 
    
         
             
                  locator = "[timeout:#{OverpassDownloader.get_allowed_timeout_in_seconds}]#{format};"
         
     | 
| 
       139 
145 
     | 
    
         
             
                  locator += "\n"
         
     | 
| 
       140 
146 
     | 
    
         
             
                  type = 'way' if type == 'closed_way'
         
     | 
| 
         @@ -156,35 +162,74 @@ module CartoCSSHelper 
     | 
|
| 
       156 
162 
     | 
    
         
             
                end
         
     | 
| 
       157 
163 
     | 
    
         | 
| 
       158 
164 
     | 
    
         
             
                def self.turn_list_of_tags_in_overpass_filter(tags)
         
     | 
| 
      
 165 
     | 
    
         
            +
                  # special support for following tag values:  :any_value, {operation: :not_equal_to, value: "tag"}
         
     | 
| 
       159 
166 
     | 
    
         
             
                  element = ''
         
     | 
| 
       160 
167 
     | 
    
         
             
                  tags.each do |tag|
         
     | 
| 
       161 
     | 
    
         
            -
                    element +=  
     | 
| 
       162 
     | 
    
         
            -
                                 "\t['#{tag[0]}']"
         
     | 
| 
       163 
     | 
    
         
            -
                               else
         
     | 
| 
       164 
     | 
    
         
            -
                                 "\t['#{tag[0]}'='#{tag[1]}']"
         
     | 
| 
       165 
     | 
    
         
            -
                               end
         
     | 
| 
      
 168 
     | 
    
         
            +
                    element += turn_tag_into_overpass_filter(tag)
         
     | 
| 
       166 
169 
     | 
    
         
             
                    element += "\n"
         
     | 
| 
       167 
170 
     | 
    
         
             
                  end
         
     | 
| 
       168 
171 
     | 
    
         
             
                  return element
         
     | 
| 
       169 
172 
     | 
    
         
             
                end
         
     | 
| 
       170 
173 
     | 
    
         | 
| 
      
 174 
     | 
    
         
            +
                def self.translate_tag_object_into_filter_data(tag)
         
     | 
| 
      
 175 
     | 
    
         
            +
                  operator = :equal
         
     | 
| 
      
 176 
     | 
    
         
            +
                  key = tag[0]
         
     | 
| 
      
 177 
     | 
    
         
            +
                  value = :any_value
         
     | 
| 
      
 178 
     | 
    
         
            +
                  if tag[1].class == Hash
         
     | 
| 
      
 179 
     | 
    
         
            +
                    # complex operation
         
     | 
| 
      
 180 
     | 
    
         
            +
                    if tag[1][:operation] == :not_equal_to
         
     | 
| 
      
 181 
     | 
    
         
            +
                      operator = :not_equal
         
     | 
| 
      
 182 
     | 
    
         
            +
                    else
         
     | 
| 
      
 183 
     | 
    
         
            +
                      raise "unexpected operation in #{tag[1]}"
         
     | 
| 
      
 184 
     | 
    
         
            +
                    end
         
     | 
| 
      
 185 
     | 
    
         
            +
                    value = tag[1][:value]
         
     | 
| 
      
 186 
     | 
    
         
            +
                  else
         
     | 
| 
      
 187 
     | 
    
         
            +
                    value = tag[1]
         
     | 
| 
      
 188 
     | 
    
         
            +
                  end
         
     | 
| 
      
 189 
     | 
    
         
            +
                  return { operator: operator, key: key, value: value }
         
     | 
| 
      
 190 
     | 
    
         
            +
                 end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
                def self.overpass_escape(text)
         
     | 
| 
      
 193 
     | 
    
         
            +
                  return text.gsub("\\", "\\\\\\").gsub("'", "\\\\'")
         
     | 
| 
      
 194 
     | 
    
         
            +
                end
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
                def self.turn_tag_into_overpass_filter(tag)
         
     | 
| 
      
 197 
     | 
    
         
            +
                  filter_data = translate_tag_object_into_filter_data(tag)
         
     | 
| 
      
 198 
     | 
    
         
            +
                  value = filter_data[:value]
         
     | 
| 
      
 199 
     | 
    
         
            +
                  key = filter_data[:key]
         
     | 
| 
      
 200 
     | 
    
         
            +
                  operator = filter_data[:operator]
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                  value = overpass_escape(value) if value != :any_value
         
     | 
| 
      
 203 
     | 
    
         
            +
                  key = overpass_escape(key)
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
                  if value == :any_value && operator == :equal
         
     | 
| 
      
 206 
     | 
    
         
            +
                    return "\t['#{key}']"
         
     | 
| 
      
 207 
     | 
    
         
            +
                  elsif value == :any_value && operator == :not_equal
         
     | 
| 
      
 208 
     | 
    
         
            +
                    return "\t['#{key}'!~'.*']"
         
     | 
| 
      
 209 
     | 
    
         
            +
                  elsif value != :any_value && operator == :equal
         
     | 
| 
      
 210 
     | 
    
         
            +
                    return "\t['#{key}'='#{value}']"
         
     | 
| 
      
 211 
     | 
    
         
            +
                  elsif value != :any_value && operator == :not_equal
         
     | 
| 
      
 212 
     | 
    
         
            +
                    return "\t['#{key}'!='#{value}']"
         
     | 
| 
      
 213 
     | 
    
         
            +
                  else
         
     | 
| 
      
 214 
     | 
    
         
            +
                    raise "unexpected situation in <#{tag}>"
         
     | 
| 
      
 215 
     | 
    
         
            +
                  end
         
     | 
| 
      
 216 
     | 
    
         
            +
                 end
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
       171 
218 
     | 
    
         
             
                def self.get_query_element_to_get_location(tags, latitude, longitude, type, range)
         
     | 
| 
       172 
     | 
    
         
            -
                  # special support for  
     | 
| 
      
 219 
     | 
    
         
            +
                  # special support for some tag values - see CartoCSSHelper::OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter for details
         
     | 
| 
       173 
220 
     | 
    
         
             
                  # TODO - escape value with quotation signs in them
         
     | 
| 
       174 
221 
     | 
    
         
             
                  element = "(#{type}"
         
     | 
| 
       175 
     | 
    
         
            -
                  element += OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter(tags)
         
     | 
| 
       176 
     | 
    
         
            -
                  element += "\n"
         
     | 
| 
      
 222 
     | 
    
         
            +
                  element += OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter(tags).strip
         
     | 
| 
       177 
223 
     | 
    
         
             
                  if range != :infinity
         
     | 
| 
       178 
     | 
    
         
            -
                    element += " 
     | 
| 
       179 
     | 
    
         
            -
                    element += "\n"
         
     | 
| 
      
 224 
     | 
    
         
            +
                    element += "(around:#{range},#{latitude},#{longitude})"
         
     | 
| 
       180 
225 
     | 
    
         
             
                  end
         
     | 
| 
       181 
     | 
    
         
            -
                  element += ');'
         
     | 
| 
       182 
     | 
    
         
            -
                  element += "\n"
         
     | 
| 
      
 226 
     | 
    
         
            +
                  element += ';);'
         
     | 
| 
      
 227 
     | 
    
         
            +
                  element += "\n\n"
         
     | 
| 
       183 
228 
     | 
    
         
             
                  return element
         
     | 
| 
       184 
229 
     | 
    
         
             
                end
         
     | 
| 
       185 
230 
     | 
    
         | 
| 
       186 
231 
     | 
    
         
             
                def self.get_query_cache_refused_response_filename(query)
         
     | 
| 
       187 
     | 
    
         
            -
                  return  
     | 
| 
      
 232 
     | 
    
         
            +
                  return OverpassDownloader.cache_filename(query) + '_response_refused'
         
     | 
| 
       188 
233 
     | 
    
         
             
                end
         
     | 
| 
       189 
234 
     | 
    
         | 
| 
       190 
235 
     | 
    
         
             
                def self.mark_query_as_refused(query)
         
     | 
| 
         @@ -193,13 +238,12 @@ module CartoCSSHelper 
     | 
|
| 
       193 
238 
     | 
    
         
             
                  file.close
         
     | 
| 
       194 
239 
     | 
    
         
             
                end
         
     | 
| 
       195 
240 
     | 
    
         | 
| 
       196 
     | 
    
         
            -
                def self.get_query_cache_filename( 
     | 
| 
       197 
     | 
    
         
            -
                   
     | 
| 
       198 
     | 
    
         
            -
                   
     | 
| 
       199 
     | 
    
         
            -
                  return query_cache_filename
         
     | 
| 
      
 241 
     | 
    
         
            +
                def self.get_query_cache_filename(_query)
         
     | 
| 
      
 242 
     | 
    
         
            +
                  Log.warn "call OverpassDownloader.cache_filename directly"
         
     | 
| 
      
 243 
     | 
    
         
            +
                  return OverpassDownloader.cache_filename
         
     | 
| 
       200 
244 
     | 
    
         
             
                end
         
     | 
| 
       201 
245 
     | 
    
         | 
| 
       202 
     | 
    
         
            -
                def self.get_overpass_query_results(query, description, debug = false)
         
     | 
| 
      
 246 
     | 
    
         
            +
                def self.get_overpass_query_results(query, description, debug = false, invalidate_cache: false) # TODO: - make debug parameter named
         
     | 
| 
       203 
247 
     | 
    
         
             
                  if File.exist?(get_query_cache_refused_response_filename(query))
         
     | 
| 
       204 
248 
     | 
    
         
             
                    raise OverpassDownloader::OverpassRefusedResponse
         
     | 
| 
       205 
249 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -207,14 +251,13 @@ module CartoCSSHelper 
     | 
|
| 
       207 
251 
     | 
    
         
             
                  check_for_free_space
         
     | 
| 
       208 
252 
     | 
    
         | 
| 
       209 
253 
     | 
    
         
             
                  if debug
         
     | 
| 
       210 
     | 
    
         
            -
                     
     | 
| 
       211 
     | 
    
         
            -
                     
     | 
| 
      
 254 
     | 
    
         
            +
                    Log.info query
         
     | 
| 
      
 255 
     | 
    
         
            +
                    Log.info
         
     | 
| 
       212 
256 
     | 
    
         
             
                  end
         
     | 
| 
       213 
257 
     | 
    
         | 
| 
       214 
     | 
    
         
            -
                  cache_filename = get_query_cache_filename(query)
         
     | 
| 
       215 
258 
     | 
    
         
             
                  description = 'Running Overpass query (connection initiated on ' + Time.now.to_s + ') ' + description
         
     | 
| 
       216 
259 
     | 
    
         
             
                  begin
         
     | 
| 
       217 
     | 
    
         
            -
                    return OverpassDownloader.run_overpass_query query, description,  
     | 
| 
      
 260 
     | 
    
         
            +
                    return OverpassDownloader.run_overpass_query query, description, invalidate_cache: invalidate_cache
         
     | 
| 
       218 
261 
     | 
    
         
             
                  rescue OverpassDownloader::OverpassRefusedResponse
         
     | 
| 
       219 
262 
     | 
    
         
             
                    mark_query_as_refused(query)
         
     | 
| 
       220 
263 
     | 
    
         
             
                    raise OverpassDownloader::OverpassRefusedResponse
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require_relative 'util/systemhelper.rb'
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            include SystemHelper
         
     | 
| 
         @@ -85,7 +87,9 @@ module CartoCSSHelper 
     | 
|
| 
       85 
87 
     | 
    
         | 
| 
       86 
88 
     | 
    
         
             
                  execute_rendering_command(command_to_execute, export_location, debug)
         
     | 
| 
       87 
89 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
                   
     | 
| 
      
 90 
     | 
    
         
            +
                  generation_time = (Time.now - start).to_i
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                  puts "generated in #{generation_time}s (#{Git.get_commit_hash})"
         
     | 
| 
       89 
93 
     | 
    
         
             
                  return export_location
         
     | 
| 
       90 
94 
     | 
    
         
             
                end
         
     | 
| 
       91 
95 
     | 
    
         | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require_relative('style_specific')
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            module CartoCSSHelper
         
     | 
| 
         @@ -237,6 +239,7 @@ module CartoCSSHelper 
     | 
|
| 
       237 
239 
     | 
    
         
             
                    TagRenderingStatus.new('layer', '-4', :composite, { 'highway' => 'service' }), # modifies ordering
         
     | 
| 
       238 
240 
     | 
    
         
             
                    TagRenderingStatus.new('layer', '-5', :composite, { 'highway' => 'service' }), # modifies ordering
         
     | 
| 
       239 
241 
     | 
    
         
             
                    TagRenderingStatus.new('leisure', 'common', :primary),
         
     | 
| 
      
 242 
     | 
    
         
            +
                    TagRenderingStatus.new('leisure', 'dog_park', :primary),
         
     | 
| 
       240 
243 
     | 
    
         
             
                    TagRenderingStatus.new('leisure', 'garden', :primary),
         
     | 
| 
       241 
244 
     | 
    
         
             
                    TagRenderingStatus.new('leisure', 'golf_course', :primary),
         
     | 
| 
       242 
245 
     | 
    
         
             
                    TagRenderingStatus.new('leisure', 'marina', :primary),
         
     | 
| 
         @@ -261,6 +264,7 @@ module CartoCSSHelper 
     | 
|
| 
       261 
264 
     | 
    
         
             
                    TagRenderingStatus.new('man_made', 'groyne', :primary),
         
     | 
| 
       262 
265 
     | 
    
         
             
                    TagRenderingStatus.new('man_made', 'lighthouse', :primary),
         
     | 
| 
       263 
266 
     | 
    
         
             
                    TagRenderingStatus.new('man_made', 'mast', :primary),
         
     | 
| 
      
 267 
     | 
    
         
            +
                    TagRenderingStatus.new('man_made', 'obelisk', :primary),
         
     | 
| 
       264 
268 
     | 
    
         
             
                    TagRenderingStatus.new('man_made', 'pier', :primary),
         
     | 
| 
       265 
269 
     | 
    
         
             
                    TagRenderingStatus.new('man_made', 'water_tower', :primary),
         
     | 
| 
       266 
270 
     | 
    
         
             
                    TagRenderingStatus.new('man_made', 'windmill', :primary),
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'ruby-progressbar'
         
     | 
| 
       2 
4 
     | 
    
         
             
            require_relative 'rest-client_wrapper.rb'
         
     | 
| 
       3 
5 
     | 
    
         
             
            require_relative 'logger.rb'
         
     | 
| 
         @@ -57,7 +59,11 @@ class GenericDownloader 
     | 
|
| 
       57 
59 
     | 
    
         
             
                output_shared_error_part(url, e)
         
     | 
| 
       58 
60 
     | 
    
         
             
                Log.warn e.response
         
     | 
| 
       59 
61 
     | 
    
         
             
                Log.warn e.http_code
         
     | 
| 
       60 
     | 
    
         
            -
                 
     | 
| 
      
 62 
     | 
    
         
            +
                if retry_allowed(e)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  get_specified_resource(url)
         
     | 
| 
      
 64 
     | 
    
         
            +
                else
         
     | 
| 
      
 65 
     | 
    
         
            +
                  raise e
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
       61 
67 
     | 
    
         
             
              rescue ExceptionWithoutResponse => e
         
     | 
| 
       62 
68 
     | 
    
         
             
                output_shared_error_part(url, e)
         
     | 
| 
       63 
69 
     | 
    
         
             
                raise e
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'rest-client'
         
     | 
| 
       2 
4 
     | 
    
         
             
            require_relative 'generic_downloader.rb'
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
         @@ -10,14 +12,15 @@ class RestClientWrapper 
     | 
|
| 
       10 
12 
     | 
    
         
             
                wait if url == @last_url_fetched
         
     | 
| 
       11 
13 
     | 
    
         
             
                @last_url_fetched = url
         
     | 
| 
       12 
14 
     | 
    
         
             
                return execute_fetch_data_from_url(url, request_timeout)
         
     | 
| 
       13 
     | 
    
         
            -
              # http://www.rubydoc.info/gems/rest-client/1.8.0/RestClient/Exception
         
     | 
| 
       14 
15 
     | 
    
         
             
              rescue RestClient::RequestTimeout => e
         
     | 
| 
       15 
16 
     | 
    
         
             
                raise RequestTimeout, e.to_s
         
     | 
| 
       16 
17 
     | 
    
         
             
              rescue RestClient::ExceptionWithResponse => e
         
     | 
| 
       17 
18 
     | 
    
         
             
                raise_exception_about_returned_response(e)
         
     | 
| 
       18 
     | 
    
         
            -
              rescue RestClient:: 
     | 
| 
      
 19 
     | 
    
         
            +
              rescue RestClient::SSLCertificateNotVerified, RestClient::ServerBrokeConnection, SocketError, URI::InvalidURIError
         
     | 
| 
       19 
20 
     | 
    
         
             
                raise ExceptionWithoutResponse.new(e), e.to_s
         
     | 
| 
       20 
21 
     | 
    
         
             
              rescue ArgumentError => e
         
     | 
| 
      
 22 
     | 
    
         
            +
                puts "url:"
         
     | 
| 
      
 23 
     | 
    
         
            +
                puts url
         
     | 
| 
       21 
24 
     | 
    
         
             
                raise_issue_359_exception(e)
         
     | 
| 
       22 
25 
     | 
    
         
             
              rescue => e
         
     | 
| 
       23 
26 
     | 
    
         
             
                puts 'unhandled exception! It is a clear bug!'
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require_relative 'visualise_changes_diff_from_images'
         
     | 
| 
       2 
4 
     | 
    
         
             
            require_relative 'git'
         
     | 
| 
       3 
5 
     | 
    
         
             
            require_relative 'renderer_handler'
         
     | 
| 
         @@ -130,7 +132,7 @@ module CartoCSSHelper 
     | 
|
| 
       130 
132 
     | 
    
         
             
                end
         
     | 
| 
       131 
133 
     | 
    
         | 
| 
       132 
134 
     | 
    
         
             
                def self.visualise_on_overpass_data(tags, type, wanted_latitude, wanted_longitude, zlevels, new_branch, old_branch = 'master')
         
     | 
| 
       133 
     | 
    
         
            -
                  # special support for  
     | 
| 
      
 135 
     | 
    
         
            +
                  # special support for some tag values - see CartoCSSHelper::OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter for details
         
     | 
| 
       134 
136 
     | 
    
         
             
                  header_prefix = "#{VisualDiff.tag_dict_to_string(tags)} #{type} [#{wanted_latitude}, #{wanted_longitude}] -> "
         
     | 
| 
       135 
137 
     | 
    
         
             
                  target_location = '[?, ?]'
         
     | 
| 
       136 
138 
     | 
    
         
             
                  header_sufix = " #{old_branch}->#{new_branch} #{zlevels}"
         
     | 
| 
         @@ -198,14 +200,7 @@ module CartoCSSHelper 
     | 
|
| 
       198 
200 
     | 
    
         
             
                end
         
     | 
| 
       199 
201 
     | 
    
         | 
| 
       200 
202 
     | 
    
         
             
                def self.tag_dict_to_string(dict)
         
     | 
| 
       201 
     | 
    
         
            -
                   
     | 
| 
       202 
     | 
    
         
            -
                  dict.to_a.each do |tag|
         
     | 
| 
       203 
     | 
    
         
            -
                    result << '; ' if result != ''
         
     | 
| 
       204 
     | 
    
         
            -
                    value = "'#{tag[1]}'"
         
     | 
| 
       205 
     | 
    
         
            -
                    value = '{any value}' if tag[1] == :any_value
         
     | 
| 
       206 
     | 
    
         
            -
                    result << "#{tag[0]}=#{value}"
         
     | 
| 
       207 
     | 
    
         
            -
                  end
         
     | 
| 
       208 
     | 
    
         
            -
                  return result
         
     | 
| 
      
 203 
     | 
    
         
            +
                  return OverpassQueryGenerator.turn_list_of_tags_in_overpass_filter(dict)
         
     | 
| 
       209 
204 
     | 
    
         
             
                end
         
     | 
| 
       210 
205 
     | 
    
         
             
              end
         
     | 
| 
       211 
206 
     | 
    
         
             
            end
         
     | 
    
        data/readme.md
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ##CartoCSS Helper
         
     | 
| 
      
 1 
     | 
    
         
            +
            ## CartoCSS Helper
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            It is a tool making development of CartoCSS styles more efficient. Allows to write simple Ruby scripts that generate comparison images of how rendering changed between two versions of map style. It is also possible to generate validation reports detecting for example too low values of text-dy. Loading data using osm2pgsql, rendering with TileMill, obtaining test data from overpass turbo.
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
         @@ -12,7 +12,7 @@ It is work in progress, major problems that should be solved include: 
     | 
|
| 
       12 
12 
     | 
    
         
             
            * Executing git checkout commands on map style git repository during normal script operation (https://github.com/matkoniecz/CartoCSSHelper/issues/9)
         
     | 
| 
       13 
13 
     | 
    
         
             
            * Current rendering method is obnoxiously slow. (https://github.com/matkoniecz/CartoCSSHelper/issues/1)
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
            ###Installation
         
     | 
| 
      
 15 
     | 
    
         
            +
            ### Installation
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            Assumes that osm2pgsql and TileMill are installed.
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
         @@ -26,7 +26,7 @@ Unfortunately, standard `gem install cartocss_helper` may not be enough as Carto 
     | 
|
| 
       26 
26 
     | 
    
         
             
            2. `gem install --user-install rmagick`
         
     | 
| 
       27 
27 
     | 
    
         
             
            3. `gem install --user-install cartocss_helper`.
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
            ###Examples
         
     | 
| 
      
 29 
     | 
    
         
            +
            ### Examples
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
            It is assumed that CartoCSS project with Default OSM Style (https://github.com/gravitystorm/openstreetmap-carto/) is located at `~/Documents/MapBox/project/osm-carto`.
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
         @@ -74,8 +74,15 @@ It is also possible to look for certain keys, with any value: 
     | 
|
| 
       74 
74 
     | 
    
         
             
                tags = {'landuse' => 'village_green', 'tourism' => 'attraction', 'name' => :any_value}
         
     | 
| 
       75 
75 
     | 
    
         
             
                CartoCSSHelper.test tags, 'master', 'v2.28.1'
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
      
 77 
     | 
    
         
            +
            ### Tests
         
     | 
| 
       77 
78 
     | 
    
         | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
      
 79 
     | 
    
         
            +
            Tests are written using rspec. Use `rspec` command to run them.
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            ### Automated stuff
         
     | 
| 
       79 
82 
     | 
    
         | 
| 
       80 
83 
     | 
    
         
             
            [](https://codeclimate.com/github/matkoniecz/CartoCSSHelper)
         
     | 
| 
       81 
     | 
    
         
            -
            [](https://travis-ci.org/matkoniecz/CartoCSSHelper)
         
     | 
| 
      
 84 
     | 
    
         
            +
            [](https://travis-ci.org/matkoniecz/CartoCSSHelper)
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            ### RubyGems link
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            [https://rubygems.org/gems/cartocss_helper](https://rubygems.org/gems/cartocss_helper)
         
     | 
    
        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 
     | 
    
         
            +
              version: 5.2.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:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-07-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rest-client
         
     | 
| 
         @@ -16,21 +16,21 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: sys-filesystem
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
31 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
       34 
34 
     | 
    
         
             
                - - ">="
         
     | 
| 
       35 
35 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       36 
36 
     | 
    
         
             
                    version: 1.1.0
         
     | 
| 
         @@ -40,7 +40,7 @@ dependencies: 
     | 
|
| 
       40 
40 
     | 
    
         
             
                requirements:
         
     | 
| 
       41 
41 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       42 
42 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       43 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 43 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
       44 
44 
     | 
    
         
             
                - - ">="
         
     | 
| 
       45 
45 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       46 
46 
     | 
    
         
             
                    version: 1.1.0
         
     | 
| 
         @@ -73,25 +73,19 @@ dependencies: 
     | 
|
| 
       73 
73 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       74 
74 
     | 
    
         
             
                    version: '1.8'
         
     | 
| 
       75 
75 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       76 
     | 
    
         
            -
              name:  
     | 
| 
      
 76 
     | 
    
         
            +
              name: addressable
         
     | 
| 
       77 
77 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       78 
78 
     | 
    
         
             
                requirements:
         
     | 
| 
       79 
79 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       80 
80 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       81 
     | 
    
         
            -
                    version: ' 
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       84 
     | 
    
         
            -
                    version: '0.41'
         
     | 
| 
       85 
     | 
    
         
            -
              type: :development
         
     | 
| 
      
 81 
     | 
    
         
            +
                    version: '2.7'
         
     | 
| 
      
 82 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
       86 
83 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       87 
84 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       88 
85 
     | 
    
         
             
                requirements:
         
     | 
| 
       89 
86 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       90 
87 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       91 
     | 
    
         
            -
                    version: ' 
     | 
| 
       92 
     | 
    
         
            -
                - - ">"
         
     | 
| 
       93 
     | 
    
         
            -
                  - !ruby/object:Gem::Version
         
     | 
| 
       94 
     | 
    
         
            -
                    version: '0.41'
         
     | 
| 
      
 88 
     | 
    
         
            +
                    version: '2.7'
         
     | 
| 
       95 
89 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       96 
90 
     | 
    
         
             
              name: rspec
         
     | 
| 
       97 
91 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -113,19 +107,19 @@ dependencies: 
     | 
|
| 
       113 
107 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       114 
108 
     | 
    
         
             
                    version: 3.4.0
         
     | 
| 
       115 
109 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       116 
     | 
    
         
            -
              name:  
     | 
| 
      
 110 
     | 
    
         
            +
              name: matkoniecz-ruby-style
         
     | 
| 
       117 
111 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       118 
112 
     | 
    
         
             
                requirements:
         
     | 
| 
       119 
     | 
    
         
            -
                - - " 
     | 
| 
      
 113 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       120 
114 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       121 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 115 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       122 
116 
     | 
    
         
             
              type: :development
         
     | 
| 
       123 
117 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       124 
118 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       125 
119 
     | 
    
         
             
                requirements:
         
     | 
| 
       126 
     | 
    
         
            -
                - - " 
     | 
| 
      
 120 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       127 
121 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       128 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 122 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       129 
123 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       130 
124 
     | 
    
         
             
              name: simplecov
         
     | 
| 
       131 
125 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -141,19 +135,19 @@ dependencies: 
     | 
|
| 
       141 
135 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       142 
136 
     | 
    
         
             
                    version: '0.11'
         
     | 
| 
       143 
137 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       144 
     | 
    
         
            -
              name:  
     | 
| 
      
 138 
     | 
    
         
            +
              name: travis
         
     | 
| 
       145 
139 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       146 
140 
     | 
    
         
             
                requirements:
         
     | 
| 
       147 
141 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       148 
142 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       149 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 143 
     | 
    
         
            +
                    version: '1.8'
         
     | 
| 
       150 
144 
     | 
    
         
             
              type: :development
         
     | 
| 
       151 
145 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       152 
146 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       153 
147 
     | 
    
         
             
                requirements:
         
     | 
| 
       154 
148 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       155 
149 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       156 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 150 
     | 
    
         
            +
                    version: '1.8'
         
     | 
| 
       157 
151 
     | 
    
         
             
            description: Tool to make development of CartoCSS styles more efficient. Automates
         
     | 
| 
       158 
152 
     | 
    
         
             
              actions necessary to produce test images and validates style. Loading data using
         
     | 
| 
       159 
153 
     | 
    
         
             
              osm2pgsql, rendering with TileMill, obtaining test data from overpass turbo.
         
     | 
| 
         @@ -168,6 +162,7 @@ files: 
     | 
|
| 
       168 
162 
     | 
    
         
             
            - lib/cartocss_helper/data_file_handling.rb
         
     | 
| 
       169 
163 
     | 
    
         
             
            - lib/cartocss_helper/git.rb
         
     | 
| 
       170 
164 
     | 
    
         
             
            - lib/cartocss_helper/heuristic.rb
         
     | 
| 
      
 165 
     | 
    
         
            +
            - lib/cartocss_helper/history_downloader.rb
         
     | 
| 
       171 
166 
     | 
    
         
             
            - lib/cartocss_helper/image_generator.rb
         
     | 
| 
       172 
167 
     | 
    
         
             
            - lib/cartocss_helper/notes_downloader.rb
         
     | 
| 
       173 
168 
     | 
    
         
             
            - lib/cartocss_helper/overpass_downloader.rb
         
     | 
| 
         @@ -200,15 +195,14 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       200 
195 
     | 
    
         
             
              requirements:
         
     | 
| 
       201 
196 
     | 
    
         
             
              - - ">="
         
     | 
| 
       202 
197 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       203 
     | 
    
         
            -
                  version: 2. 
     | 
| 
      
 198 
     | 
    
         
            +
                  version: 2.4.0
         
     | 
| 
       204 
199 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       205 
200 
     | 
    
         
             
              requirements:
         
     | 
| 
       206 
201 
     | 
    
         
             
              - - ">="
         
     | 
| 
       207 
202 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       208 
203 
     | 
    
         
             
                  version: 1.8.23
         
     | 
| 
       209 
204 
     | 
    
         
             
            requirements: []
         
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
            rubygems_version: 2.5.1
         
     | 
| 
      
 205 
     | 
    
         
            +
            rubygems_version: 3.1.2
         
     | 
| 
       212 
206 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       213 
207 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       214 
208 
     | 
    
         
             
            summary: Tool to make development of CartoCSS styles more efficient.
         
     |