mirror of
https://github.com/enzet/map-machine.git
synced 2025-05-22 13:36:26 +02:00
Issue #13: support local restrictions.
This commit is contained in:
parent
ce6233486c
commit
34d7ae0dbc
7 changed files with 82 additions and 55 deletions
|
@ -278,7 +278,7 @@ class Constructor:
|
|||
self.extractor,
|
||||
line.tags,
|
||||
processed,
|
||||
self.configuration.zoom_level,
|
||||
self.configuration,
|
||||
)
|
||||
if icon_set is not None:
|
||||
labels: list[Label] = self.scheme.construct_text(
|
||||
|
@ -316,7 +316,7 @@ class Constructor:
|
|||
self.extractor,
|
||||
line.tags,
|
||||
processed,
|
||||
self.configuration.zoom_level,
|
||||
self.configuration,
|
||||
)
|
||||
if icon_set is not None:
|
||||
labels: list[Label] = self.scheme.construct_text(
|
||||
|
@ -430,7 +430,7 @@ class Constructor:
|
|||
return
|
||||
|
||||
icon_set, priority = self.scheme.get_icon(
|
||||
self.extractor, tags, processed, self.configuration.zoom_level
|
||||
self.extractor, tags, processed, self.configuration
|
||||
)
|
||||
if icon_set is None:
|
||||
return
|
||||
|
|
|
@ -41,7 +41,7 @@ def draw_element(options: argparse.Namespace) -> None:
|
|||
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
|
||||
)
|
||||
processed: set[str] = set()
|
||||
icon, priority = scheme.get_icon(extractor, tags, processed, 18)
|
||||
icon, priority = scheme.get_icon(extractor, tags, processed)
|
||||
is_for_node: bool = target == "node"
|
||||
labels: list[Label] = scheme.construct_text(tags, "all", processed)
|
||||
point: Point = Point(
|
||||
|
|
|
@ -148,9 +148,9 @@
|
|||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:cy="491.93534"
|
||||
inkscape:cx="710.8436"
|
||||
inkscape:zoom="22.627417"
|
||||
inkscape:cy="421.22467"
|
||||
inkscape:cx="81.518562"
|
||||
inkscape:zoom="5.6568542"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
borderopacity="1.0"
|
||||
|
@ -4441,20 +4441,20 @@
|
|||
d="m 119,562 c -0.0693,0 -0.12764,0.006 -0.1875,0.0312 C 117.24696,562.13217 116,563.40897 116,565 l -1,7 2,0 0,-7 c 0,-1.10457 0.89543,-2 2,-2 l 1.5,0 c 0.277,0 0.5,-0.223 0.5,-0.5 0,-0.277 -0.223,-0.5 -0.5,-0.5 z m 1,2 c -1.108,0 -2,0.892 -2,2 l 0,0.5 0,1.5 0,5.5 c 0,0.277 0.223,0.5 0.5,0.5 l 3,0 c 0.277,0 0.5,-0.223 0.5,-0.5 l 0,-5.5 0,-1.5 0,-0.5 c 0,-1.108 -0.892,-2 -2,-2 z"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2"
|
||||
d="m 23.5,165.5 -1.5,0 -1,2.5 5,1"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 23.5,164.5 -1.5,0 -1,2.5 5,1"
|
||||
id="path3857"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;opacity:0.2"
|
||||
d="m 26,167.5 2,0"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 26,166.5 2,0"
|
||||
id="path3861"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2"
|
||||
d="m 27,167.5 -2.5,4 -2,-3"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 27,166.5 -2.5,4 -2,-3"
|
||||
id="path3863"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccc" />
|
||||
|
@ -5671,12 +5671,12 @@
|
|||
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker:none;enable-background:accumulate" />
|
||||
<path
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker:none;enable-background:accumulate"
|
||||
d="m 20.5,169 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
d="m 20.5,168 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
id="path3853"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker:none;enable-background:accumulate"
|
||||
d="m 28.5,169 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
d="m 28.5,168 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
id="path3855"
|
||||
inkscape:connector-curvature="0" />
|
||||
<rect
|
||||
|
@ -6108,7 +6108,7 @@
|
|||
<rect
|
||||
rx="0.5"
|
||||
ry="0.5"
|
||||
y="161"
|
||||
y="162"
|
||||
x="49"
|
||||
height="5"
|
||||
width="1"
|
||||
|
@ -6116,12 +6116,12 @@
|
|||
style="opacity:1;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:open="true"
|
||||
d="m 51.5,161 a 1.5,1.5 0 0 1 1.5,1.5 1.5,1.5 0 0 1 -1.5,1.5"
|
||||
d="m 51.5,162 a 1.5,1.5 0 0 1 1.5,1.5 1.5,1.5 0 0 1 -1.5,1.5"
|
||||
sodipodi:end="1.5707963"
|
||||
sodipodi:start="4.712389"
|
||||
sodipodi:ry="1.5"
|
||||
sodipodi:rx="1.5"
|
||||
sodipodi:cy="162.5"
|
||||
sodipodi:cy="163.5"
|
||||
sodipodi:cx="51.5"
|
||||
sodipodi:type="arc"
|
||||
id="path5081"
|
||||
|
@ -6129,12 +6129,12 @@
|
|||
sodipodi:arc-type="arc" />
|
||||
<path
|
||||
sodipodi:open="true"
|
||||
d="m 51.5,162 a 0.5,0.5 0 0 1 0.5,0.5 0.5,0.5 0 0 1 -0.5,0.5"
|
||||
d="m 51.5,163 a 0.5,0.5 0 0 1 0.5,0.5 0.5,0.5 0 0 1 -0.5,0.5"
|
||||
sodipodi:end="1.5707963"
|
||||
sodipodi:start="4.712389"
|
||||
sodipodi:ry="0.5"
|
||||
sodipodi:rx="0.5"
|
||||
sodipodi:cy="162.5"
|
||||
sodipodi:cy="163.5"
|
||||
sodipodi:cx="51.5"
|
||||
sodipodi:type="arc"
|
||||
id="path5083"
|
||||
|
@ -6143,7 +6143,7 @@
|
|||
<rect
|
||||
rx="0.5"
|
||||
ry="0.45580584"
|
||||
y="161"
|
||||
y="162"
|
||||
x="49"
|
||||
height="1"
|
||||
width="3"
|
||||
|
@ -6157,34 +6157,34 @@
|
|||
width="3"
|
||||
height="1"
|
||||
x="49"
|
||||
y="163" />
|
||||
y="164" />
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5089"
|
||||
d="m 55.5,165.5 -1.5,0 -1,2.5 5,1"
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2" />
|
||||
d="m 55.5,166.5 -1.5,0 -1,2.5 5,1"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5091"
|
||||
d="m 58,167.5 2,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;opacity:0.2" />
|
||||
d="m 58,168.5 2,0"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5093"
|
||||
d="m 59,167.5 -2.5,4 -2,-3"
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2" />
|
||||
d="m 59,168.5 -2.5,4 -2,-3"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5095"
|
||||
d="m 52.5,169 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
d="m 52.5,170 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker:none;enable-background:accumulate" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5097"
|
||||
d="m 60.5,169 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
d="m 60.5,170 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker:none;enable-background:accumulate" />
|
||||
<path
|
||||
inkscape:label="#rect5099"
|
||||
|
@ -6199,41 +6199,41 @@
|
|||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5128"
|
||||
d="m 39.5,165.5 -1.5,0 -1,2.5 5,1"
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2" />
|
||||
d="m 39.5,166.5 -1.5,0 -1,2.5 5,1"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5130"
|
||||
d="m 42,167.5 2,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;opacity:0.2" />
|
||||
d="m 42,168.5 2,0"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="ccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5132"
|
||||
d="m 43,167.5 -2.5,4 -2,-3"
|
||||
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2" />
|
||||
d="m 43,168.5 -2.5,4 -2,-3"
|
||||
style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5134"
|
||||
d="m 36.5,169 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
d="m 36.5,170 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker:none;enable-background:accumulate" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5136"
|
||||
d="m 44.5,169 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
d="m 44.5,170 c -1.37479,0 -2.5,1.12521 -2.5,2.5 0,1.37479 1.12521,2.5 2.5,2.5 1.37479,0 2.5,-1.12521 2.5,-2.5 0,-1.37479 -1.12521,-2.5 -2.5,-2.5 z m 0,1 c 0.83435,0 1.5,0.66565 1.5,1.5 0,0.83435 -0.66565,1.5 -1.5,1.5 -0.83435,0 -1.5,-0.66565 -1.5,-1.5 0,-0.83435 0.66565,-1.5 1.5,-1.5 z"
|
||||
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker:none;enable-background:accumulate" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5138"
|
||||
d="m 33.5,161.5 3,3"
|
||||
d="m 33.5,162.5 3,3"
|
||||
style="opacity:0.2;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path5140"
|
||||
d="m 33.5,164.5 3,-3"
|
||||
d="m 33.5,165.5 3,-3"
|
||||
style="opacity:0.2;fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:label="#path5142"
|
||||
|
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
@ -53,6 +53,7 @@ class MapConfiguration:
|
|||
level: str = "overground"
|
||||
seed: str = ""
|
||||
show_tooltips: bool = False
|
||||
country: str = "world"
|
||||
|
||||
@classmethod
|
||||
def from_options(
|
||||
|
|
|
@ -21,6 +21,7 @@ from map_machine.icon import (
|
|||
ShapeExtractor,
|
||||
ShapeSpecification,
|
||||
)
|
||||
from map_machine.map_configuration import MapConfiguration
|
||||
from map_machine.text import Label, get_address, get_text
|
||||
|
||||
__author__ = "Sergey Vartanov"
|
||||
|
@ -89,6 +90,20 @@ def get_selector(key: str, value: str, prefix: str = "") -> str:
|
|||
return f'[{key}="{value}"]'
|
||||
|
||||
|
||||
def match_location(restrictions: dict[str, str], country: str) -> bool:
|
||||
"""Check whether country is matched by location restrictions."""
|
||||
if "exclude" in restrictions and country in restrictions["exclude"]:
|
||||
return False
|
||||
if (
|
||||
"include" in restrictions
|
||||
and restrictions["include"] != "world"
|
||||
and country != "world"
|
||||
and country not in restrictions["include"]
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
class Matcher:
|
||||
"""
|
||||
Tag matching.
|
||||
|
@ -121,14 +136,25 @@ class Matcher:
|
|||
self.start_zoom_level is None or zoom_level >= self.start_zoom_level
|
||||
)
|
||||
|
||||
def is_matched(self, tags: dict[str, str]) -> bool:
|
||||
def is_matched(
|
||||
self,
|
||||
tags: dict[str, str],
|
||||
configuration: Optional[MapConfiguration] = None,
|
||||
) -> bool:
|
||||
"""
|
||||
Check whether element tags matches tag matcher.
|
||||
|
||||
:param tags: element tags to match
|
||||
:param tags: element tags to be matched
|
||||
:param configuration: current map configuration to be matched
|
||||
"""
|
||||
if self.location_restrictions:
|
||||
return False # FIXME: implement
|
||||
if (
|
||||
configuration is not None
|
||||
and self.location_restrictions
|
||||
and not match_location(
|
||||
self.location_restrictions, configuration.country
|
||||
)
|
||||
):
|
||||
return False
|
||||
|
||||
for config_tag_key in self.tags:
|
||||
config_tag_key: str
|
||||
|
@ -355,7 +381,7 @@ class Scheme:
|
|||
extractor: ShapeExtractor,
|
||||
tags: dict[str, Any],
|
||||
processed: set[str],
|
||||
zoom_level: float,
|
||||
configuration: MapConfiguration = MapConfiguration(),
|
||||
) -> tuple[Optional[IconSet], int]:
|
||||
"""
|
||||
Construct icon set.
|
||||
|
@ -363,7 +389,7 @@ class Scheme:
|
|||
:param extractor: extractor with icon specifications
|
||||
:param tags: OpenStreetMap element tags dictionary
|
||||
:param processed: set of already processed tag keys
|
||||
:param zoom_level: zoom level in current context
|
||||
:param configuration: current map configuration to be matched
|
||||
:return (icon set, icon priority)
|
||||
"""
|
||||
tags_hash: str = (
|
||||
|
@ -381,9 +407,9 @@ class Scheme:
|
|||
for matcher in self.node_matchers:
|
||||
if not matcher.replace_shapes and main_icon:
|
||||
continue
|
||||
if not matcher.is_matched(tags):
|
||||
if not matcher.is_matched(tags, configuration):
|
||||
continue
|
||||
if not matcher.check_zoom_level(zoom_level):
|
||||
if not matcher.check_zoom_level(configuration.zoom_level):
|
||||
return None, 0
|
||||
matcher_tags: set[str] = set(matcher.tags.keys())
|
||||
priority = len(self.node_matchers) - index
|
||||
|
|
|
@ -281,7 +281,7 @@ node_icons:
|
|||
shapes: [volcanic_cone]
|
||||
|
||||
- tags: {historic: castle}
|
||||
location_restrictions: {include: jp}
|
||||
location_restrictions: {include: [jp]}
|
||||
shapes: [japan_castle]
|
||||
- tags: {shop: mall}
|
||||
shapes: [bag]
|
||||
|
@ -316,10 +316,10 @@ node_icons:
|
|||
- tags: {amenity: clinic}
|
||||
shapes: [greek_cross]
|
||||
- tags: {amenity: post_office}
|
||||
location_restrictions: {include: world, exclude: jp}
|
||||
location_restrictions: {include: world, exclude: [jp]}
|
||||
shapes: [envelope]
|
||||
- tags: {amenity: post_office}
|
||||
location_restrictions: {include: jp}
|
||||
location_restrictions: {include: [jp]}
|
||||
shapes: [japan_post]
|
||||
- tags: {shop: car_repair}
|
||||
shapes: [car_repair]
|
||||
|
@ -363,7 +363,7 @@ node_icons:
|
|||
- tags: {historic: "*"}
|
||||
shapes: [japan_historic]
|
||||
replace_shapes: no
|
||||
location_restrictions: {include: jp}
|
||||
location_restrictions: {include: [jp]}
|
||||
|
||||
- group: "Normal big objects"
|
||||
start_zoom_level: 15
|
||||
|
@ -562,7 +562,7 @@ node_icons:
|
|||
- tags: {building: office}
|
||||
shapes: [briefcase]
|
||||
- tags: {amenity: school}
|
||||
location_restrictions: {include: jp}
|
||||
location_restrictions: {include: [jp]}
|
||||
shapes: [japan_elementary_school]
|
||||
- tags: {office: company}
|
||||
shapes: [briefcase]
|
||||
|
@ -577,7 +577,7 @@ node_icons:
|
|||
start_zoom_level: 15
|
||||
tags:
|
||||
- tags: {man_made: communications_tower}
|
||||
location_restrictions: {include: jp}
|
||||
location_restrictions: {include: [jp]}
|
||||
shapes: [japan_tv_tower]
|
||||
- tags: {man_made: tower}
|
||||
shapes: [tower]
|
||||
|
|
|
@ -35,7 +35,7 @@ def test_icons_by_name(init_collection: IconCollection) -> None:
|
|||
def get_icon(tags: dict[str, str]) -> IconSet:
|
||||
"""Construct icon from tags."""
|
||||
processed: set[str] = set()
|
||||
icon, _ = SCHEME.get_icon(SHAPE_EXTRACTOR, tags, processed, 18)
|
||||
icon, _ = SCHEME.get_icon(SHAPE_EXTRACTOR, tags, processed)
|
||||
return icon
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue