From ed3d555bbc50c49b3bcb970c102032e8bfefec16 Mon Sep 17 00:00:00 2001 From: Sergey Vartanov Date: Fri, 2 Oct 2020 23:40:07 +0300 Subject: [PATCH] Add area detection. Detect whether way is an area. --- data/tags.yml | 47 ++++++++++++++++++++++++++++++++++++----- roentgen/constructor.py | 13 +++++++----- roentgen/scheme.py | 30 +++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 11 deletions(-) diff --git a/data/tags.yml b/data/tags.yml index 98c4971..300ecf8 100644 --- a/data/tags.yml +++ b/data/tags.yml @@ -153,17 +153,21 @@ node_icons: - tags: {man_made: flagpole} icon: [flagpole] - tags: {man_made: manhole} - icon: [manhole] + icon: [circle_9] - tags: {manhole: drain} icon: [manhole_drain] - tags: {man_made: pole} icon: [pole] - tags: {man_made: pole, highway: street_lamp} icon: [pole_lamp] + - tags: {man_made: street_cabinet} + icon: [street_cabinet] - tags: {man_made: surveillance} icon: [cctv] - tags: {man_made: survey_point} icon: [survey_point] + - tags: {man_made: tower} + icon: [tower] - tags: {man_made: ventilation_shaft} icon: [ventilation] @@ -180,6 +184,8 @@ node_icons: icon: [power_generator] - tags: {power: generator, generator:source: solar} icon: [solar_panel] + - tags: {power: generator, generator:source: wind} + icon: [wind_turbine] - tags: {power: tower} icon: [power_tower_2_level] - tags: {power: tower, design: one-level} @@ -208,6 +214,12 @@ node_icons: icon: [power_tower_y_frame] - tags: {power: tower, design: 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 @@ -277,8 +289,10 @@ node_icons: - tags: {advertising: billboard} icon: [billboard] - # Eating and entertainment + # Amenity + - tags: {amenity: embassy} + icon: [embassy] - tags: {amenity: cafe} icon: [cafe] - tags: {amenity: ice_cream} @@ -524,7 +538,7 @@ node_icons: - tags: {entrance: exit} icon: [exit] - tags: {entrance: service} - icon: [door_with_x] + icon: [door_with_keyhole] - tags: {entrance: main} icon: [main_entrance] - tags: {entrance: staircase} @@ -608,6 +622,16 @@ node_icons: over_icon: [bus_stop_bench] - tags: {highway: 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} icon: [stop] - tags: {highway: give_way} @@ -675,6 +699,8 @@ node_icons: icon: [tomb] - tags: {historic: tomb, tomb: mausoleum} icon: [mausoleum] + - tags: {tomb: "*"} + icon: [tomb] # Tourism @@ -855,19 +881,22 @@ ways: # Hidden land use - - tags: {landuse: residential} + - tags: {landuse: cemetery} fill: hidden_color opacity: 0.05 - tags: {landuse: commercial} fill: hidden_color opacity: 0.05 + - tags: {landuse: industrial} + fill: hidden_color + opacity: 0.05 - tags: {landuse: military} fill: hidden_color opacity: 0.05 - tags: {landuse: railway} fill: hidden_color opacity: 0.05 - - tags: {landuse: industrial} + - tags: {landuse: residential} fill: hidden_color opacity: 0.05 @@ -1187,6 +1216,14 @@ ways: # stroke-dasharray: 10,5 priority: 60 +area_tags: + - tags: {aeroway: "*"} + - tags: {building: "*"} + - tags: {landuse: "*"} + - tags: {leisure: "*"} + - tags: {natural: "*"} + - tags: {indoor: "corridor"} + tags_to_write: [ "operator", "opening_hours", "cuisine", "network", "website", "website_2", "STIF:zone", "opening_hours:url", "phone", diff --git a/roentgen/constructor.py b/roentgen/constructor.py index 7c95db3..5863ac8 100644 --- a/roentgen/constructor.py +++ b/roentgen/constructor.py @@ -337,11 +337,14 @@ class Constructor: else: self.figures.append( Figure(line.tags, inners, outers, line_style)) - icon_set: IconSet = self.scheme.get_icon( - self.icon_extractor, line.tags, for_="line") - self.nodes.append(Point( - icon_set, line.tags, center_point, center_coordinates, - is_for_node=False)) + if (line.get_tag("area") == "yes" or + is_cycle(outers[0]) and line.get_tag("area") != "no" and + self.scheme.is_area(line.tags)): + icon_set: IconSet = self.scheme.get_icon( + 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 DEBUG: diff --git a/roentgen/scheme.py b/roentgen/scheme.py index 7bd1c28..375c44e 100644 --- a/roentgen/scheme.py +++ b/roentgen/scheme.py @@ -51,11 +51,12 @@ class Scheme: input_file.read(), Loader=yaml.FullLoader) self.icons: List[Dict[str, Any]] = content["node_icons"] - self.ways: List[Dict[str, Any]] = content["ways"] 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.prefix_to_write: List[str] = content["prefix_to_write"] self.tags_to_skip: List[str] = content["tags_to_skip"] @@ -204,6 +205,28 @@ class Scheme: 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): line_styles = [] @@ -248,3 +271,8 @@ class Scheme: 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