Add area detection.

Detect whether way is an area.
This commit is contained in:
Sergey Vartanov 2020-10-02 23:40:07 +03:00
parent 8a21e729ad
commit ed3d555bbc
3 changed files with 79 additions and 11 deletions

View file

@ -153,17 +153,21 @@ node_icons:
- tags: {man_made: flagpole} - tags: {man_made: flagpole}
icon: [flagpole] icon: [flagpole]
- tags: {man_made: manhole} - tags: {man_made: manhole}
icon: [manhole] icon: [circle_9]
- tags: {manhole: drain} - tags: {manhole: drain}
icon: [manhole_drain] icon: [manhole_drain]
- tags: {man_made: pole} - tags: {man_made: pole}
icon: [pole] icon: [pole]
- tags: {man_made: pole, highway: street_lamp} - tags: {man_made: pole, highway: street_lamp}
icon: [pole_lamp] icon: [pole_lamp]
- tags: {man_made: street_cabinet}
icon: [street_cabinet]
- tags: {man_made: surveillance} - tags: {man_made: surveillance}
icon: [cctv] icon: [cctv]
- tags: {man_made: survey_point} - tags: {man_made: survey_point}
icon: [survey_point] icon: [survey_point]
- tags: {man_made: tower}
icon: [tower]
- tags: {man_made: ventilation_shaft} - tags: {man_made: ventilation_shaft}
icon: [ventilation] icon: [ventilation]
@ -180,6 +184,8 @@ node_icons:
icon: [power_generator] icon: [power_generator]
- tags: {power: generator, generator:source: solar} - tags: {power: generator, generator:source: solar}
icon: [solar_panel] icon: [solar_panel]
- tags: {power: generator, generator:source: wind}
icon: [wind_turbine]
- tags: {power: tower} - tags: {power: tower}
icon: [power_tower_2_level] icon: [power_tower_2_level]
- tags: {power: tower, design: one-level} - tags: {power: tower, design: one-level}
@ -208,6 +214,12 @@ node_icons:
icon: [power_tower_y_frame] icon: [power_tower_y_frame]
- tags: {power: tower, design: x-frame} - tags: {power: tower, design: x-frame}
icon: [power_tower_x_frame] icon: [power_tower_x_frame]
- tags: {power: tower, design: h-frame}
icon: [power_tower_h_frame]
- tags: {power: tower, design: h-frame-two-level}
icon: [power_tower_h_frame_2_level]
- tags: {power: tower, design: guyed-h-frame}
icon: [power_tower_guyed_h_frame]
# Information # Information
@ -277,8 +289,10 @@ node_icons:
- tags: {advertising: billboard} - tags: {advertising: billboard}
icon: [billboard] icon: [billboard]
# Eating and entertainment # Amenity
- tags: {amenity: embassy}
icon: [embassy]
- tags: {amenity: cafe} - tags: {amenity: cafe}
icon: [cafe] icon: [cafe]
- tags: {amenity: ice_cream} - tags: {amenity: ice_cream}
@ -524,7 +538,7 @@ node_icons:
- tags: {entrance: exit} - tags: {entrance: exit}
icon: [exit] icon: [exit]
- tags: {entrance: service} - tags: {entrance: service}
icon: [door_with_x] icon: [door_with_keyhole]
- tags: {entrance: main} - tags: {entrance: main}
icon: [main_entrance] icon: [main_entrance]
- tags: {entrance: staircase} - tags: {entrance: staircase}
@ -608,6 +622,16 @@ node_icons:
over_icon: [bus_stop_bench] over_icon: [bus_stop_bench]
- tags: {highway: stop} - tags: {highway: stop}
icon: [stop] icon: [stop]
- tags: {traffic_sign: city_limit}
icon: [city_limit_sign]
- tags: {traffic_sign: maxspeed, maxspeed: "30"}
icon: [circle_30]
- tags: {traffic_sign: maxspeed, maxspeed: "40"}
icon: [circle_40]
- tags: {traffic_sign: maxspeed, maxspeed: "50"}
icon: [circle_50]
- tags: {traffic_sign: maxspeed, maxspeed: "40_mph"}
icon: [speed_limit_40_mph]
- tags: {traffic_sign: stop} - tags: {traffic_sign: stop}
icon: [stop] icon: [stop]
- tags: {highway: give_way} - tags: {highway: give_way}
@ -675,6 +699,8 @@ node_icons:
icon: [tomb] icon: [tomb]
- tags: {historic: tomb, tomb: mausoleum} - tags: {historic: tomb, tomb: mausoleum}
icon: [mausoleum] icon: [mausoleum]
- tags: {tomb: "*"}
icon: [tomb]
# Tourism # Tourism
@ -855,19 +881,22 @@ ways:
# Hidden land use # Hidden land use
- tags: {landuse: residential} - tags: {landuse: cemetery}
fill: hidden_color fill: hidden_color
opacity: 0.05 opacity: 0.05
- tags: {landuse: commercial} - tags: {landuse: commercial}
fill: hidden_color fill: hidden_color
opacity: 0.05 opacity: 0.05
- tags: {landuse: industrial}
fill: hidden_color
opacity: 0.05
- tags: {landuse: military} - tags: {landuse: military}
fill: hidden_color fill: hidden_color
opacity: 0.05 opacity: 0.05
- tags: {landuse: railway} - tags: {landuse: railway}
fill: hidden_color fill: hidden_color
opacity: 0.05 opacity: 0.05
- tags: {landuse: industrial} - tags: {landuse: residential}
fill: hidden_color fill: hidden_color
opacity: 0.05 opacity: 0.05
@ -1187,6 +1216,14 @@ ways:
# stroke-dasharray: 10,5 # stroke-dasharray: 10,5
priority: 60 priority: 60
area_tags:
- tags: {aeroway: "*"}
- tags: {building: "*"}
- tags: {landuse: "*"}
- tags: {leisure: "*"}
- tags: {natural: "*"}
- tags: {indoor: "corridor"}
tags_to_write: [ tags_to_write: [
"operator", "opening_hours", "cuisine", "network", "website", "operator", "opening_hours", "cuisine", "network", "website",
"website_2", "STIF:zone", "opening_hours:url", "phone", "website_2", "STIF:zone", "opening_hours:url", "phone",

View file

@ -337,11 +337,14 @@ class Constructor:
else: else:
self.figures.append( self.figures.append(
Figure(line.tags, inners, outers, line_style)) Figure(line.tags, inners, outers, line_style))
icon_set: IconSet = self.scheme.get_icon( if (line.get_tag("area") == "yes" or
self.icon_extractor, line.tags, for_="line") is_cycle(outers[0]) and line.get_tag("area") != "no" and
self.nodes.append(Point( self.scheme.is_area(line.tags)):
icon_set, line.tags, center_point, center_coordinates, icon_set: IconSet = self.scheme.get_icon(
is_for_node=False)) self.icon_extractor, line.tags, for_="line")
self.nodes.append(Point(
icon_set, line.tags, center_point, center_coordinates,
is_for_node=False))
if not line_styles: if not line_styles:
if DEBUG: if DEBUG:

View file

@ -51,11 +51,12 @@ class Scheme:
input_file.read(), Loader=yaml.FullLoader) input_file.read(), Loader=yaml.FullLoader)
self.icons: List[Dict[str, Any]] = content["node_icons"] self.icons: List[Dict[str, Any]] = content["node_icons"]
self.ways: List[Dict[str, Any]] = content["ways"] self.ways: List[Dict[str, Any]] = content["ways"]
self.colors: Dict[str, str] = content["colors"] self.colors: Dict[str, str] = content["colors"]
self.area_tags: List[Dict[str, str]] = content["area_tags"]
self.tags_to_write: List[str] = content["tags_to_write"] self.tags_to_write: List[str] = content["tags_to_write"]
self.prefix_to_write: List[str] = content["prefix_to_write"] self.prefix_to_write: List[str] = content["prefix_to_write"]
self.tags_to_skip: List[str] = content["tags_to_skip"] self.tags_to_skip: List[str] = content["tags_to_skip"]
@ -204,6 +205,28 @@ class Scheme:
return returned return returned
def is_matched(self, matcher: Dict[str, Any], tags: Dict[str, str]) -> bool:
matched: bool = True
for config_tag_key in matcher["tags"]: # type: str
matcher = matcher["tags"][config_tag_key]
if (config_tag_key not in tags or
(matcher != "*" and
tags[config_tag_key] != matcher and
tags[config_tag_key] not in matcher)):
matched = False
break
if "no_tags" in matcher:
for config_tag_key in matcher["no_tags"]: # type: str
if (config_tag_key in tags and
tags[config_tag_key] ==
matcher["no_tags"][config_tag_key]):
matched = False
break
return matched
def get_style(self, tags: Dict[str, Any], scale): def get_style(self, tags: Dict[str, Any], scale):
line_styles = [] line_styles = []
@ -248,3 +271,8 @@ class Scheme:
return line_styles return line_styles
def is_area(self, tags: Dict[str, str]) -> bool:
for matcher in self.area_tags:
if self.is_matched(matcher, tags):
return True
return False