Skip to content
Snippets Groups Projects
Commit a3818007090f authored by Patrice Journoud's avatar Patrice Journoud
Browse files

code refactoring to provide distance getter as a plugin for the tsp solver

parent d102ccd1d6b4
No related tags found
No related merge requests found
......@@ -198,7 +198,7 @@
contentType: "application/json; charset=utf-8",
headers:{'X-Messaging-Token':'localhost:6544-b32de4d5-d979-4e84-bfe7-a7e52026016c',
'start': 0,
'end': latlng.length-1},
'end': 0},
data: JSON.stringify(zlatlng)
}))
.done(function(response) {
......@@ -216,9 +216,9 @@
var marker_start = markers[0];
marker_start.setIcon(green_icon);
var red_icon = get_icon("red");
var marker_end = markers[markers.length-1];
marker_end.setIcon(red_icon);
//var red_icon = get_icon("red");
//var marker_end = markers[markers.length-1];
//marker_end.setIcon(red_icon);
var polyline = L.polyline(
latlngs,
......
......@@ -9,7 +9,8 @@
from cornice import Service
import logging
from pytsp.distance_getter.gpsdistancegetter import GpsDistanceGetter
from pytsp.distance_getter.osrmdistancegetter import OsrmDistanceGetter
from pytsp.viaroute import Viaroute
from pytsprf.conf import get as conf_get
from pytsprf.models import get_db_user_token, get_db_user
......@@ -188,6 +189,6 @@
def get_route(points, start, end, is_debug_mode=False):
scheme = conf_get('osrm.scheme')
hostname = conf_get('osrm.hostname')
osrmhost = conf_get('osrm.hostname')
conf_max_points_for_brute_force = \
int(conf_get('tsp.max_points_for_brute_force'))
......@@ -192,7 +193,4 @@
conf_max_points_for_brute_force = \
int(conf_get('tsp.max_points_for_brute_force'))
obj = Viaroute(osrmhost=hostname,
scheme=scheme,
is_debug_mode=is_debug_mode)
cache_url = 'localhost'
......@@ -198,11 +196,23 @@
return \
obj.compute(
points,
start,
end,
max_points_for_brute_force=conf_max_points_for_brute_force
)
if is_debug_mode:
distance_getter = \
GpsDistanceGetter(is_cache_required=True,
cache_url=cache_url)
else:
distance_getter = \
OsrmDistanceGetter(osrmhost,
scheme,
is_cache_required=True,
cache_url=cache_url)
obj = Viaroute(osrmhost,
distance_getter,
points,
start=start,
end=end,
max_points_for_brute_force=conf_max_points_for_brute_force)
return obj.get_route_geometry()
def log_connections(request):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment