add support for connection types and excluding steps_down or steps_up

This commit is contained in:
Laura Klünder 2016-12-17 22:15:14 +01:00
parent f6129d621c
commit 5183b8fa7d
11 changed files with 125 additions and 76 deletions

View file

@ -0,0 +1,28 @@
{% load route_render %}
<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 }} {{ routepart.svg_height }}"
style="max-height:{% if routepart.svg_height > 300 %}300{% else %}{{ routepart.svg_height }}{% 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 }}" height="{{ svg_height }}" x="{{ routepart.svg_min_x | negate }}" y="{{ routepart.svg_min_y | negate }}" 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 }}"
y1="{{ c.from_point.svg_y | subtract:routepart.svg_min_y }}"
x2="{{ c.to_point.svg_x | subtract:routepart.svg_min_x }}"
y2="{{ c.to_point.svg_y | subtract:routepart.svg_min_y }}"
marker-end="url(#arrow-{{ forloop.parentloop.counter0 }})"></line>
{% endfor %}
</g>
</svg>
{% endfor %}
</div>

View file

@ -2,7 +2,6 @@
{% load static %}
{% load i18n %}
{% load route_render %}
{% block content %}
<form>
@ -15,32 +14,7 @@
</div>
</form>
{% if route %}
<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.width }} {{ routepart.height }}"
style="max-height:{% if routepart.height > 300 %}300{% else %}{{ routepart.height }}{% 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 }}" height="{{ svg_height }}" x="{{ routepart.min_x | negate }}" y="{{ routepart.min_y | negate }}" 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.min_x }}"
y1="{{ c.from_point.svg_y | subtract:routepart.min_y }}"
x2="{{ c.to_point.svg_x | subtract:routepart.min_x }}"
y2="{{ c.to_point.svg_y | subtract:routepart.min_y }}"
marker-end="url(#arrow-{{ forloop.parentloop.counter0 }})"></line>
{% endfor %}
</g>
</svg>
{% endfor %}
</div>
{% endif %}
{% if route %}
{% include 'site/fragment_route.html' %}
{% endif %}
{% endblock %}

View file

@ -42,7 +42,7 @@ def main(request, origin=None, destination=None):
route = None
if origin and destination:
graph = Graph.load()
route = graph.get_route(origin, destination)
route = graph.get_route(origin, destination, ('', 'steps_down', 'steps_up'))
route = route.split()
print(route)