Issue #13: support local restrictions.

This commit is contained in:
Sergey Vartanov 2021-09-12 06:09:41 +03:00
parent ce6233486c
commit 34d7ae0dbc
7 changed files with 82 additions and 55 deletions

View file

@ -278,7 +278,7 @@ class Constructor:
self.extractor, self.extractor,
line.tags, line.tags,
processed, processed,
self.configuration.zoom_level, self.configuration,
) )
if icon_set is not None: if icon_set is not None:
labels: list[Label] = self.scheme.construct_text( labels: list[Label] = self.scheme.construct_text(
@ -316,7 +316,7 @@ class Constructor:
self.extractor, self.extractor,
line.tags, line.tags,
processed, processed,
self.configuration.zoom_level, self.configuration,
) )
if icon_set is not None: if icon_set is not None:
labels: list[Label] = self.scheme.construct_text( labels: list[Label] = self.scheme.construct_text(
@ -430,7 +430,7 @@ class Constructor:
return return
icon_set, priority = self.scheme.get_icon( 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: if icon_set is None:
return return

View file

@ -41,7 +41,7 @@ def draw_element(options: argparse.Namespace) -> None:
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
) )
processed: set[str] = set() 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" is_for_node: bool = target == "node"
labels: list[Label] = scheme.construct_text(tags, "all", processed) labels: list[Label] = scheme.construct_text(tags, "all", processed)
point: Point = Point( point: Point = Point(

View file

@ -148,9 +148,9 @@
showgrid="true" showgrid="true"
inkscape:document-units="px" inkscape:document-units="px"
inkscape:current-layer="layer1" inkscape:current-layer="layer1"
inkscape:cy="491.93534" inkscape:cy="421.22467"
inkscape:cx="710.8436" inkscape:cx="81.518562"
inkscape:zoom="22.627417" inkscape:zoom="5.6568542"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
borderopacity="1.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" 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" /> style="fill:#000000;fill-opacity:1;stroke:none" />
<path <path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2" style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="m 23.5,165.5 -1.5,0 -1,2.5 5,1" d="m 23.5,164.5 -1.5,0 -1,2.5 5,1"
id="path3857" id="path3857"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" /> sodipodi:nodetypes="cccc" />
<path <path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;opacity:0.2" style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1"
d="m 26,167.5 2,0" d="m 26,166.5 2,0"
id="path3861" id="path3861"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" /> sodipodi:nodetypes="cc" />
<path <path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;opacity:0.2" style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="m 27,167.5 -2.5,4 -2,-3" d="m 27,166.5 -2.5,4 -2,-3"
id="path3863" id="path3863"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" /> 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" /> 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 <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" 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" id="path3853"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0" />
<path <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" 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" id="path3855"
inkscape:connector-curvature="0" /> inkscape:connector-curvature="0" />
<rect <rect
@ -6108,7 +6108,7 @@
<rect <rect
rx="0.5" rx="0.5"
ry="0.5" ry="0.5"
y="161" y="162"
x="49" x="49"
height="5" height="5"
width="1" 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" /> 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 <path
sodipodi:open="true" 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:end="1.5707963"
sodipodi:start="4.712389" sodipodi:start="4.712389"
sodipodi:ry="1.5" sodipodi:ry="1.5"
sodipodi:rx="1.5" sodipodi:rx="1.5"
sodipodi:cy="162.5" sodipodi:cy="163.5"
sodipodi:cx="51.5" sodipodi:cx="51.5"
sodipodi:type="arc" sodipodi:type="arc"
id="path5081" id="path5081"
@ -6129,12 +6129,12 @@
sodipodi:arc-type="arc" /> sodipodi:arc-type="arc" />
<path <path
sodipodi:open="true" 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:end="1.5707963"
sodipodi:start="4.712389" sodipodi:start="4.712389"
sodipodi:ry="0.5" sodipodi:ry="0.5"
sodipodi:rx="0.5" sodipodi:rx="0.5"
sodipodi:cy="162.5" sodipodi:cy="163.5"
sodipodi:cx="51.5" sodipodi:cx="51.5"
sodipodi:type="arc" sodipodi:type="arc"
id="path5083" id="path5083"
@ -6143,7 +6143,7 @@
<rect <rect
rx="0.5" rx="0.5"
ry="0.45580584" ry="0.45580584"
y="161" y="162"
x="49" x="49"
height="1" height="1"
width="3" width="3"
@ -6157,34 +6157,34 @@
width="3" width="3"
height="1" height="1"
x="49" x="49"
y="163" /> y="164" />
<path <path
sodipodi:nodetypes="cccc" sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5089" id="path5089"
d="m 55.5,165.5 -1.5,0 -1,2.5 5,1" d="m 55.5,166.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" /> style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
<path <path
sodipodi:nodetypes="cc" sodipodi:nodetypes="cc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5091" id="path5091"
d="m 58,167.5 2,0" d="m 58,168.5 2,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;opacity:0.2" /> style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
<path <path
sodipodi:nodetypes="ccc" sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5093" id="path5093"
d="m 59,167.5 -2.5,4 -2,-3" d="m 59,168.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" /> style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
<path <path
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5095" 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" /> 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 <path
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5097" 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" /> 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 <path
inkscape:label="#rect5099" inkscape:label="#rect5099"
@ -6199,41 +6199,41 @@
sodipodi:nodetypes="cccc" sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5128" id="path5128"
d="m 39.5,165.5 -1.5,0 -1,2.5 5,1" d="m 39.5,166.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" /> style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
<path <path
sodipodi:nodetypes="cc" sodipodi:nodetypes="cc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5130" id="path5130"
d="m 42,167.5 2,0" d="m 42,168.5 2,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1;opacity:0.2" /> style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" />
<path <path
sodipodi:nodetypes="ccc" sodipodi:nodetypes="ccc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5132" id="path5132"
d="m 43,167.5 -2.5,4 -2,-3" d="m 43,168.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" /> style="opacity:0.2;fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
<path <path
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5134" 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" /> 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 <path
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5136" 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" /> 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 <path
sodipodi:nodetypes="cc" sodipodi:nodetypes="cc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5138" 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" /> 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 <path
sodipodi:nodetypes="cc" sodipodi:nodetypes="cc"
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
id="path5140" 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" /> 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 <path
inkscape:label="#path5142" inkscape:label="#path5142"

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Before After
Before After

View file

@ -53,6 +53,7 @@ class MapConfiguration:
level: str = "overground" level: str = "overground"
seed: str = "" seed: str = ""
show_tooltips: bool = False show_tooltips: bool = False
country: str = "world"
@classmethod @classmethod
def from_options( def from_options(

View file

@ -21,6 +21,7 @@ from map_machine.icon import (
ShapeExtractor, ShapeExtractor,
ShapeSpecification, ShapeSpecification,
) )
from map_machine.map_configuration import MapConfiguration
from map_machine.text import Label, get_address, get_text from map_machine.text import Label, get_address, get_text
__author__ = "Sergey Vartanov" __author__ = "Sergey Vartanov"
@ -89,6 +90,20 @@ def get_selector(key: str, value: str, prefix: str = "") -> str:
return f'[{key}="{value}"]' 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: class Matcher:
""" """
Tag matching. Tag matching.
@ -121,14 +136,25 @@ class Matcher:
self.start_zoom_level is None or zoom_level >= self.start_zoom_level 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. 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: if (
return False # FIXME: implement 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: for config_tag_key in self.tags:
config_tag_key: str config_tag_key: str
@ -355,7 +381,7 @@ class Scheme:
extractor: ShapeExtractor, extractor: ShapeExtractor,
tags: dict[str, Any], tags: dict[str, Any],
processed: set[str], processed: set[str],
zoom_level: float, configuration: MapConfiguration = MapConfiguration(),
) -> tuple[Optional[IconSet], int]: ) -> tuple[Optional[IconSet], int]:
""" """
Construct icon set. Construct icon set.
@ -363,7 +389,7 @@ class Scheme:
:param extractor: extractor with icon specifications :param extractor: extractor with icon specifications
:param tags: OpenStreetMap element tags dictionary :param tags: OpenStreetMap element tags dictionary
:param processed: set of already processed tag keys :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) :return (icon set, icon priority)
""" """
tags_hash: str = ( tags_hash: str = (
@ -381,9 +407,9 @@ class Scheme:
for matcher in self.node_matchers: for matcher in self.node_matchers:
if not matcher.replace_shapes and main_icon: if not matcher.replace_shapes and main_icon:
continue continue
if not matcher.is_matched(tags): if not matcher.is_matched(tags, configuration):
continue continue
if not matcher.check_zoom_level(zoom_level): if not matcher.check_zoom_level(configuration.zoom_level):
return None, 0 return None, 0
matcher_tags: set[str] = set(matcher.tags.keys()) matcher_tags: set[str] = set(matcher.tags.keys())
priority = len(self.node_matchers) - index priority = len(self.node_matchers) - index

View file

@ -281,7 +281,7 @@ node_icons:
shapes: [volcanic_cone] shapes: [volcanic_cone]
- tags: {historic: castle} - tags: {historic: castle}
location_restrictions: {include: jp} location_restrictions: {include: [jp]}
shapes: [japan_castle] shapes: [japan_castle]
- tags: {shop: mall} - tags: {shop: mall}
shapes: [bag] shapes: [bag]
@ -316,10 +316,10 @@ node_icons:
- tags: {amenity: clinic} - tags: {amenity: clinic}
shapes: [greek_cross] shapes: [greek_cross]
- tags: {amenity: post_office} - tags: {amenity: post_office}
location_restrictions: {include: world, exclude: jp} location_restrictions: {include: world, exclude: [jp]}
shapes: [envelope] shapes: [envelope]
- tags: {amenity: post_office} - tags: {amenity: post_office}
location_restrictions: {include: jp} location_restrictions: {include: [jp]}
shapes: [japan_post] shapes: [japan_post]
- tags: {shop: car_repair} - tags: {shop: car_repair}
shapes: [car_repair] shapes: [car_repair]
@ -363,7 +363,7 @@ node_icons:
- tags: {historic: "*"} - tags: {historic: "*"}
shapes: [japan_historic] shapes: [japan_historic]
replace_shapes: no replace_shapes: no
location_restrictions: {include: jp} location_restrictions: {include: [jp]}
- group: "Normal big objects" - group: "Normal big objects"
start_zoom_level: 15 start_zoom_level: 15
@ -562,7 +562,7 @@ node_icons:
- tags: {building: office} - tags: {building: office}
shapes: [briefcase] shapes: [briefcase]
- tags: {amenity: school} - tags: {amenity: school}
location_restrictions: {include: jp} location_restrictions: {include: [jp]}
shapes: [japan_elementary_school] shapes: [japan_elementary_school]
- tags: {office: company} - tags: {office: company}
shapes: [briefcase] shapes: [briefcase]
@ -577,7 +577,7 @@ node_icons:
start_zoom_level: 15 start_zoom_level: 15
tags: tags:
- tags: {man_made: communications_tower} - tags: {man_made: communications_tower}
location_restrictions: {include: jp} location_restrictions: {include: [jp]}
shapes: [japan_tv_tower] shapes: [japan_tv_tower]
- tags: {man_made: tower} - tags: {man_made: tower}
shapes: [tower] shapes: [tower]

View file

@ -35,7 +35,7 @@ def test_icons_by_name(init_collection: IconCollection) -> None:
def get_icon(tags: dict[str, str]) -> IconSet: def get_icon(tags: dict[str, str]) -> IconSet:
"""Construct icon from tags.""" """Construct icon from tags."""
processed: set[str] = set() processed: set[str] = set()
icon, _ = SCHEME.get_icon(SHAPE_EXTRACTOR, tags, processed, 18) icon, _ = SCHEME.get_icon(SHAPE_EXTRACTOR, tags, processed)
return icon return icon