experimental change to all-manik poi style markers

poi-mapnik
Hartmut Holzgraefe 2020-10-24 18:03:29 +00:00
rodzic 6afe9e62d5
commit bf07852d34
8 zmienionych plików z 205 dodań i 7 usunięć

Wyświetl plik

@ -9,6 +9,8 @@ gi.require_version('Rsvg', '2.0')
from gi.repository import Rsvg
from io import BytesIO
import tempfile
from string import Template
from ocitysmap.layoutlib.commons import convert_pt_to_dots
from ocitysmap.layoutlib.abstract_renderer import Renderer
@ -27,6 +29,7 @@ def render(renderer, ctx):
lat, lon = poi.endpoint1.get_latlong()
renderer._marker(category.color, str(n), lat, lon, ctx, renderer.dpi)
# place "you are here" circle if coordinates are given
if renderer.street_index.lat != False:
x,y = renderer._latlon2xy(renderer.street_index.lat, renderer.street_index.lon, renderer.dpi)

Wyświetl plik

@ -48,7 +48,7 @@ from ocitysmap.indexlib.PoiIndex import PoiIndexRenderer, PoiIndex
from indexlib.commons import IndexDoesNotFitError, IndexEmptyError
import draw_utils
from ocitysmap.maplib.map_canvas import MapCanvas
from ocitysmap.stylelib import GpxStylesheet, UmapStylesheet
from ocitysmap.stylelib import GpxStylesheet, UmapStylesheet, PoiStylesheet
import time
@ -173,9 +173,12 @@ class SinglePageRenderer(Renderer):
else:
self._overlays.append(umap_style)
elif file_type == 'poi':
# TODO: refactor this special case
self._overlay_effects['poi_markers'] = self.get_plugin('poi_markers')
self.rc.poi_file = import_file
try:
poi_style = PoiStylesheet(import_file, self.tmpdir, self.street_index)
except Exception as e:
LOG.warning("Poi stylesheet error: %s" % e)
else:
self._overlays.append(poi_style)
else:
LOG.warning("Unsupported file type '%s' for file '%s" % (file_type, import_file))

Wyświetl plik

@ -24,14 +24,49 @@
from . import Stylesheet
import os
import shutil
import tempfile
from string import Template
import logging
LOG = logging.getLogger('ocitysmap')
class PoiStylesheet(Stylesheet):
def __init__(self, poi_file, tmpdir):
def __init__(self, poi_file, tmpdir, poi_index):
super().__init__()
template_dir = os.path.realpath(
os.path.join(
os.path.dirname(__file__),
'../../templates/poi_markers'))
template_file = os.path.join(template_dir, 'template.xml')
style_filename = tempfile.mktemp(suffix='.xml', dir=tmpdir)
tmpfile = open(style_filename, 'w')
position_data = "lat,lon\n%f,%f\n" % (poi_index.lat, poi_index.lon)
n = 0
marker_data = "number,lat,lon,color\n"
for category in poi_index.categories:
for poi in category.items:
n = n + 1
lat, lon = poi.endpoint1.get_latlong()
marker_data += "%d,%f,%f,%s\n" % (n, lat, lon, category.color)
with open(template_file, 'r') as style_template:
tmpstyle = Template(style_template.read())
tmpfile.write(
tmpstyle.substitute(
svgdir = template_dir,
position_data = position_data,
marker_data = marker_data
))
tmpfile.close()
shutil.copyfile(style_filename, "/tmp/poi_style")
self.name = "POI overlay"
self.path = "internal:poi_markers"
self.path = style_filename

Wyświetl plik

@ -141,4 +141,5 @@ class Stylesheet:
from .Gpx import GpxStylesheet
from .Umap import UmapStylesheet
from .Poi import PoiStylesheet

Wyświetl plik

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
height="32"
width="32"
version="1.1"
id="svg3025"
viewBox="0 -256 32 32">
<metadata
id="metadata3035">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3033" />
<path
style="opacity:0.7;fill:#ffffff"
d="m 876.47461,55576 a 362.353,362.353 0 0 1 362.35329,362.354 362.353,362.353 0 0 1 -362.35329,362.353 362.353,362.353 0 0 1 -362.3533,-362.353 362.353,362.353 0 0 1 362.3533,-362.354 z"
id="path3029-3" />
<path
style="opacity:0.7;fill:#000000;stroke-width:0.02066946"
d="m 15.99999,-255.87412 c -2.921268,0 -5.41539,1.03338 -7.4823425,3.1003 -2.066935,2.06695 -3.100404,4.56123 -3.100404,7.48246 0,1.502 0.227354,2.73528 0.68208,3.69985 l 7.5443635,15.99805 c 0.206693,0.45487 0.527062,0.81302 0.961128,1.07485 0.434046,0.26182 0.899113,0.39274 1.395177,0.39274 0.496063,0 0.961128,-0.13101 1.395193,-0.39274 0.434067,-0.26183 0.761316,-0.61998 0.981789,-1.07485 l 7.523682,-15.99805 c 0.454728,-0.96457 0.6821,-2.19785 0.6821,-3.69985 0,-2.92123 -1.033467,-5.41551 -3.100424,-7.48246 -2.066933,-2.06692 -4.561054,-3.1003 -7.482342,-3.1003 z m 0,3.34353 a 7.4896387,7.4896387 0 0 1 7.489649,7.48972 7.4896387,7.4896387 0 0 1 -7.489649,7.48953 7.4896387,7.4896387 0 0 1 -7.4896505,-7.48953 7.4896387,7.4896387 0 0 1 7.4896505,-7.48972 z"
id="path21912" />
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.8 KiB

Wyświetl plik

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 8.4666659 8.4666659"
version="1.1"
id="svg8">
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<path
id="path814"
transform="scale(0.26458331)"
d="M 16 0.083984375 C 9.4770814 0.083984375 4.189466 5.463218 4.1894531 12.099609 C 4.1894429 18.736001 8.4209063 24.265612 16 31.976562 C 23.638416 24.205276 27.810557 18.736003 27.810547 12.099609 C 27.810534 5.4632195 22.522919 0.083984375 16 0.083984375 z M 16 2.9589844 C 21.066737 2.9589844 25.173828 7.0660753 25.173828 12.132812 C 25.173828 17.199549 21.066737 21.306641 16 21.306641 C 10.933263 21.306641 6.8261719 17.199549 6.8261719 12.132812 C 6.8261719 7.0660757 10.933263 2.9589846 16 2.9589844 z "
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:5.34579372;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<g
id="layer1"
transform="translate(0,-288.53334)" />
<path
id="path817"
d="m 6.6606572,3.2101429 c 0,1.3405741 -1.08675,2.4273241 -2.4273241,2.4273241 -1.340574,-1e-7 -2.427324,-1.0867501 -2.427324,-2.4273241 0,-1.340574 1.08675,-2.427324 2.427324,-2.42732406 1.3405741,0 2.4273241,1.08674996 2.4273241,2.42732406 z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.29799426;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 KiB

Wyświetl plik

@ -0,0 +1,38 @@
<?xml version='1.0' encoding='utf-8'?>
<Map xmlns:xi='http://www.w3.org/2001/XInclude' background-color='transparent'>
<FileSource name="svg">${svgdir}</FileSource>
<Style name="you_are_here">
<Rule>
<MarkersSymbolizer fill="red" opacity=".5" width="50" height="50" stroke="red" stroke-width="15" stroke-opacity=".8" placement="point" marker-type="ellipse"/>
</Rule>
</Style>
<Layer name="you_are_here" status="on" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>you_are_here</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline"><![CDATA[
${position_data}
]]></Parameter>
</Datasource>
</Layer>
<Style name="markers">
<Rule>
<!-- <MarkersSymbolizer fill="red" opacity=".5" width="50" height="50" stroke="red" stroke-width="15" stroke-opacity=".8" placement="point" marker-type="ellipse" allow-overlap="true"/> -->
<MarkersSymbolizer base="svg" file="marker.svg" placement="point" allow-overlap="true" fill="[color]"/>
</Rule>
</Style>
<Layer name="markers" status="on" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>markers</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline"><![CDATA[
${marker_data}
]]></Parameter>
</Datasource>
</Layer>
</Map>

Wyświetl plik

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
version="1.1"
viewBox="0 0 13.229166 13.229167"
height="50"
width="50">
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0,-283.77082)"
id="layer1">
<ellipse
ry="6.6230044"
rx="6.6235657"
cy="290.39404"
cx="6.6271734"
id="path18-3"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.25;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.5006578;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<circle
r="6.1389213"
cy="290.39661"
cx="6.6257591"
id="path18"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.75;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#ff0000;stroke-width:0.96419412;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:markers stroke fill;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</g>
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.1 KiB