Fix stylesheet, imagemap
This commit is contained in:
parent
179eee3feb
commit
02fa59a4af
2 changed files with 15 additions and 8 deletions
|
@ -561,10 +561,11 @@ def optimize_text_layout(ns, erfas, chaostreffs, size, svg):
|
||||||
def create_imagemap(ns, size, parent,
|
def create_imagemap(ns, size, parent,
|
||||||
erfas, erfa_urls, erfa_names, texts,
|
erfas, erfa_urls, erfa_names, texts,
|
||||||
chaostreffs, chaostreff_urls, chaostreff_names):
|
chaostreffs, chaostreff_urls, chaostreff_names):
|
||||||
|
s = ns.png_scale
|
||||||
img = etree.Element('img',
|
img = etree.Element('img',
|
||||||
src=ns.output_directory.rel(ns.output_directory.png_path),
|
src=ns.output_directory.rel(ns.output_directory.png_path),
|
||||||
usemap='#erfamap',
|
usemap='#erfamap',
|
||||||
width=str(size[0]), height=str(size[1]))
|
width=str(size[0]*s), height=str(size[1]*s))
|
||||||
imgmap = etree.Element('map', name='erfamap')
|
imgmap = etree.Element('map', name='erfamap')
|
||||||
|
|
||||||
for city, location in erfas.items():
|
for city, location in erfas.items():
|
||||||
|
@ -573,11 +574,11 @@ def create_imagemap(ns, size, parent,
|
||||||
box = texts[city]
|
box = texts[city]
|
||||||
area = etree.Element('area',
|
area = etree.Element('area',
|
||||||
shape='circle',
|
shape='circle',
|
||||||
coords=f'{location[0]},{location[1]},{ns.dotsize_erfa}',
|
coords=f'{location[0]*s},{location[1]*s},{ns.dotsize_erfa*s}',
|
||||||
href=erfa_urls[city])
|
href=erfa_urls[city])
|
||||||
area2 = etree.Element('area',
|
area2 = etree.Element('area',
|
||||||
shape='rect',
|
shape='rect',
|
||||||
coords=f'{box.left},{box.top},{box.right},{box.bottom}',
|
coords=f'{box.left*s},{box.top*s},{box.right*s},{box.bottom*s}',
|
||||||
href=erfa_urls[city])
|
href=erfa_urls[city])
|
||||||
if city in erfa_names:
|
if city in erfa_names:
|
||||||
area.set('title', erfa_names[city])
|
area.set('title', erfa_names[city])
|
||||||
|
@ -590,7 +591,7 @@ def create_imagemap(ns, size, parent,
|
||||||
continue
|
continue
|
||||||
area = etree.Element('area',
|
area = etree.Element('area',
|
||||||
shape='circle',
|
shape='circle',
|
||||||
coords=f'{location[0]},{location[1]},{ns.dotsize_treff}',
|
coords=f'{location[0]*s},{location[1]*s},{ns.dotsize_treff*s}',
|
||||||
href=chaostreff_urls[city])
|
href=chaostreff_urls[city])
|
||||||
if city in chaostreff_names:
|
if city in chaostreff_names:
|
||||||
area.set('title', chaostreff_names[city])
|
area.set('title', chaostreff_names[city])
|
||||||
|
@ -803,7 +804,8 @@ def create_svg(ns, bbox):
|
||||||
root.write(mapfile)
|
root.write(mapfile)
|
||||||
|
|
||||||
print('Writing PNG')
|
print('Writing PNG')
|
||||||
cairosvg.svg2png(url=ns.output_directory.svg_path, write_to=ns.output_directory.png_path)
|
cairosvg.svg2png(url=ns.output_directory.svg_path, write_to=ns.output_directory.png_path,
|
||||||
|
scale=ns.png_scale)
|
||||||
|
|
||||||
print('Writing HTML SVG page')
|
print('Writing HTML SVG page')
|
||||||
html = etree.Element('html')
|
html = etree.Element('html')
|
||||||
|
@ -826,6 +828,10 @@ def create_svg(ns, bbox):
|
||||||
|
|
||||||
print('Writing HTML Image Map')
|
print('Writing HTML Image Map')
|
||||||
html = etree.Element('html')
|
html = etree.Element('html')
|
||||||
|
head = etree.Element('head')
|
||||||
|
link = etree.Element('link', rel='stylesheet', href=ns.stylesheet)
|
||||||
|
head.append(link)
|
||||||
|
html.append(head)
|
||||||
body = etree.Element('body')
|
body = etree.Element('body')
|
||||||
html.append(body)
|
html.append(body)
|
||||||
|
|
||||||
|
@ -858,6 +864,7 @@ def main():
|
||||||
ap.add_argument('--projection', type=str, default='epsg:4258', help='Map projection to convert the WGS84 coordinates to')
|
ap.add_argument('--projection', type=str, default='epsg:4258', help='Map projection to convert the WGS84 coordinates to')
|
||||||
ap.add_argument('--scale-x', type=float, default=130, help='X axis scale to apply after projecting')
|
ap.add_argument('--scale-x', type=float, default=130, help='X axis scale to apply after projecting')
|
||||||
ap.add_argument('--scale-y', type=float, default=200, help='Y axis scale to apply after projecting')
|
ap.add_argument('--scale-y', type=float, default=200, help='Y axis scale to apply after projecting')
|
||||||
|
ap.add_argument('--png-scale', type=float, default=1.0, help='Scale of the PNG image')
|
||||||
ap.add_argument('--debug', action='store_true', default=False, help='Add debug information to the produced SVG')
|
ap.add_argument('--debug', action='store_true', default=False, help='Add debug information to the produced SVG')
|
||||||
|
|
||||||
ns = ap.parse_args(sys.argv[1:])
|
ns = ap.parse_args(sys.argv[1:])
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
* {
|
html, body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
object, img {
|
body {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rect.background {
|
rect.background {
|
||||||
fill: #759eb5;
|
fill: #759eb5;
|
||||||
stroke: none;
|
stroke: none;
|
||||||
|
|
Loading…
Reference in a new issue