remove intermediate level routeparts

This commit is contained in:
Laura Klünder 2016-12-19 12:24:07 +01:00
parent d6736670d4
commit 1e46ee10ae
3 changed files with 49 additions and 31 deletions

View file

@ -2,29 +2,34 @@
<h2>Your Route</h2>
<div class="routeparts">
{% for routepart in route.routeparts %}
<svg xmlns="http://www.w3.org/2000/svg" class="map" data-level="{{ routepart.level_name }}"
viewBox="0 0 {{ routepart.svg_width | stringformat:"f" }} {{ routepart.svg_height | stringformat:"f" }}"
style="max-height:{% if routepart.svg_height > 300 %}300{% else %}{{ routepart.svg_height | stringformat:"f" }}{% endif %}px">
<defs>
<marker id="arrow-{{ forloop.counter0 }}" markerWidth="4" markerHeight="4" refX="2.5" refY="2" orient="auto">
<path d="M0,0 L3,2 L0,4 L0,0" style="fill: #FF0000; stroke: 0;"></path>
</marker>
</defs>
<div class="row">
<div class="form-group col-md-6">
<svg xmlns="http://www.w3.org/2000/svg" class="map" data-level="{{ routepart.level.name }}"
viewBox="0 0 {{ routepart.svg_width | stringformat:"f" }} {{ routepart.svg_height | stringformat:"f" }}"
style="max-height:{% if routepart.svg_height > 300 %}300{% else %}{{ routepart.svg_height | stringformat:"f" }}{% endif %}px">
<defs>
<marker id="arrow-{{ forloop.counter0 }}" markerWidth="4" markerHeight="4" refX="2.5" refY="2" orient="auto">
<path d="M0,0 L3,2 L0,4 L0,0" style="fill: #FF0000; stroke: 0;"></path>
</marker>
</defs>
<image width="{{ svg_width | stringformat:"f" }}" height="{{ svg_height | stringformat:"f" }}"
x="{{ routepart.svg_min_x | negate | stringformat:"f" }}" y="{{ routepart.svg_min_y | negate | stringformat:"f" }}"
xlink:href="/map/{{ routepart.level_name }}.png"></image>
<image width="{{ svg_width | stringformat:"f" }}" height="{{ svg_height | stringformat:"f" }}"
x="{{ routepart.svg_min_x | negate | stringformat:"f" }}" y="{{ routepart.svg_min_y | negate | stringformat:"f" }}"
xlink:href="/map/{{ routepart.level.name }}.png"></image>
<g class="connections">
{% for c in routepart.connections %}
<line x1="{{ c.from_point.svg_x | subtract:routepart.svg_min_x | stringformat:"f"}}"
y1="{{ c.from_point.svg_y | subtract:routepart.svg_min_y | stringformat:"f" }}"
x2="{{ c.to_point.svg_x | subtract:routepart.svg_min_x | stringformat:"f" }}"
y2="{{ c.to_point.svg_y | subtract:routepart.svg_min_y | stringformat:"f" }}"
marker-end="url(#arrow-{{ forloop.parentloop.counter0 }})"></line>
{% endfor %}
</g>
</svg>
<g class="connections">
{% for c in routepart.connections %}
<line x1="{{ c.from_point.svg_x | subtract:routepart.svg_min_x | stringformat:"f"}}"
y1="{{ c.from_point.svg_y | subtract:routepart.svg_min_y | stringformat:"f" }}"
x2="{{ c.to_point.svg_x | subtract:routepart.svg_min_x | stringformat:"f" }}"
y2="{{ c.to_point.svg_y | subtract:routepart.svg_min_y | stringformat:"f" }}"
marker-end="url(#arrow-{{ forloop.parentloop.counter0 }})"></line>
{% endfor %}
</g>
</svg>
</div>
</div>
{% endfor %}
</div>

View file

@ -21,7 +21,7 @@ ctype_mapping = {
def get_ctypes(prefix, value):
return tuple((prefix+'_'+direction) for direction in ctype_mapping.get(value, ('up', 'dowm')))
return tuple((prefix+'_'+direction) for direction in ctype_mapping.get(value, ('up', 'down')))
def main(request, origin=None, destination=None):