Skip to content

Commit

Permalink
#17: support basic entrances (uses the first one)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardsun29 committed Jan 2, 2018
1 parent d81018e commit b674421
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion indoor/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def draw_route_image(landmark_id, floor_name, path, start_name, end_name):
start_coords = (start_centroid.x - text_width / 2,
-start_centroid.y - text_height / 2)
draw.text(start_coords, start_name, font=font, fill=(0, 188, 169, 255))
if end.floor == floor and start.type == "room":
if end.floor == floor and end.type == "room":
end_centroid = end_room_data.geom.centroid
text_width, text_height = draw.textsize(end_name, font=font)
end_coords = (end_centroid.x - text_width / 2,
Expand Down
9 changes: 8 additions & 1 deletion indoor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ def route(request, landmark_id, start_name, end_name):
landmark_id = int(landmark_id)
building = get_object_or_404(Building, landmark__id=landmark_id)

if end_name == 'exit':
try:
end = POI.objects.filter(type='entrance', floor__building=building)[0]
end_name = end.name
except IndexError:
raise Http404('Unable to find a route')

try:
paths,floors = navigation.route(building.name, start_name, end_name)
except (POI.DoesNotExist, NetworkXNoPath, NetworkXError) as e:
raise Http404(e)
raise Http404('Unable to find a route')

images = []
for path, floor in zip(paths, floors):
Expand Down

0 comments on commit b674421

Please sign in to comment.