mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-21 13:06:25 +02:00
Add area detection.
Detect whether way is an area.
This commit is contained in:
parent
8a21e729ad
commit
ed3d555bbc
3 changed files with 79 additions and 11 deletions
|
@ -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",
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue