Module: CartoCSSHelper::Heuristic
- Includes:
- Configuration
- Defined in:
- lib/cartocss_helper/heuristic.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#default_renderer, #find_style_file_location, #get_cartocss_project_name, #get_data_filename, #get_max_z, #get_min_z, #get_overpass_instance_url, #get_path_to_cartocss_project_folder, #get_path_to_folder_for_branch_specific_cache, #get_path_to_folder_for_cache, #get_path_to_folder_for_history_api_cache, #get_path_to_folder_for_notes_api_cache, #get_path_to_folder_for_output, #get_path_to_folder_for_overpass_cache, #get_style_file_location, #get_style_specific_data, #mapnik_reference_version_override, #path_to_kosmtik, #project_file_location, #renderer, #set_known_alternative_overpass_url, #set_mapnik_reference_version_override, #set_overpass_instance_url, #set_path_to_cartocss_project_folder, #set_path_to_folder_for_cache, #set_path_to_folder_for_output, #set_path_to_kosmtik, #set_renderer, #set_style_specific_data
Class Method Details
.get_generic_tag_value ⇒ Object
101
102
103
|
# File 'lib/cartocss_helper/heuristic.rb', line 101
def self.get_generic_tag_value
return '*'
end
|
Instance Method Details
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/cartocss_helper/heuristic.rb', line 44
def get_tags_from_mss_file(style_filename)
possible_key_values = get_tags_from_osm2pqsql
tags = Set.new
style_file = open(style_filename)
style = style_file.read
matched = style.scan(/\[feature = '(man_made|[^_]+)_([^']+)'\]/)
matched.each do |element|
key = element[0]
if possible_key_values.include?([key, get_generic_tag_value])
tags.add([key, element[1]])
end
end
matched = style.scan(/(\w+) = '(\w+)'/)
matched.each do |element|
key = element[0]
next unless key != 'feature'
if possible_key_values.include?([key, get_generic_tag_value])
tags.add([key, element[1]])
end
end
return tags
end
|
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/cartocss_helper/heuristic.rb', line 105
def get_tags_from_osm2pqsql_file(style_filename)
tags = Set.new
style_file = open(style_filename)
style = style_file.read
matched = style.scan(/^(node,way|node|way)\s*([^ ]+)\s*text\s*($|linear|polygon|nocache)/)
matched.each do |element|
tags.add([element[1], get_generic_tag_value])
end
return tags
end
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/cartocss_helper/heuristic.rb', line 68
def get_tags_from_yaml_file(yaml_filename)
possible_key_values = get_tags_from_osm2pqsql
tags = Set.new
yaml_file = open(yaml_filename)
yaml = yaml_file.read
matched = yaml.scan(/(.*\.|)("|)([^"() ]+)("|) = '([^'()]+)'/)
matched.each do |element|
key = element[2]
value = element[4]
if possible_key_values.include?([key, get_generic_tag_value])
tags.add([key, value])
end
end
matched = yaml.scan(/("|)([^"() ]+)("|) (NOT |)IN \(([^()]*)\)/)
matched.each do |element|
tag = element[1]
key = tag.gsub(/.*\./, '')
values = element[4]
values_matched = values.scan(/'([^']+)'/)
next unless possible_key_values.include?([key, get_generic_tag_value])
values_matched.each do |value|
tags.add([key, value[0]])
end
end
return tags
end
|