def destination_list(request, map_id, ms_id): """ Returns the destinations of interest tuple for K-space systems and a blank response for w-space systems. """ if not request.is_ajax(): raise PermissionDenied destinations = Destination.objects.filter( Q(user=None) | Q(user=request.user)) map_system = get_object_or_404(MapSystem, pk=ms_id) try: system = KSystem.objects.get(pk=map_system.system.pk) rf = utils.RouteFinder() result = [] for destination in destinations: result.append(( destination.system, rf.route_length(system, destination.system) - 1, round(rf.ly_distance(system, destination.system), 3), )) except ObjectDoesNotExist: return HttpResponse() return render(request, 'system_destinations.html', { 'system': system, 'destinations': _sort_destinations(result) })
def distance(self, destination): """ Returns the light-year distance to the destination. """ return utils.RouteFinder().ly_distance(self, destination)
def jumps_to(self, destination): """ Returns the number of gate jumps to the destination by shortest route. """ return utils.RouteFinder().route_length(self, destination)