diff --git a/DataStructures/TurnInstructions.h b/DataStructures/TurnInstructions.h index c421fc0b8..76f5244f2 100644 --- a/DataStructures/TurnInstructions.h +++ b/DataStructures/TurnInstructions.h @@ -40,8 +40,9 @@ struct TurnInstructionsClass { const static short EnterRoundAbout = 11; const static short LeaveRoundAbout = 12; const static short StayOnRoundAbout = 13; + const static short StartAtEndOfStreet = 14; - std::string TurnStrings[14]; + std::string TurnStrings[15]; std::string Ordinals[11]; //This is a hack until c++0x is available enough to use initializer lists. @@ -60,6 +61,7 @@ struct TurnInstructionsClass { TurnStrings[11] = "Enter round-about"; TurnStrings[12] = "Leave round-about"; TurnStrings[13] = "Stay on round-about"; + TurnStrings[14] = "Start"; Ordinals[0] = "zeroth"; Ordinals[1] = "first"; @@ -105,48 +107,6 @@ struct TurnInstructionsClass { return true; } - // static inline void getDirectionOfInstruction(double angle, DirectionOfInstruction & dirInst) { - // if(angle >= 23 && angle < 67) { - // dirInst.direction = "southeast"; - // dirInst.shortDirection = "SE"; - // return; - // } - // if(angle >= 67 && angle < 113) { - // dirInst.direction = "south"; - // dirInst.shortDirection = "S"; - // return; - // } - // if(angle >= 113 && angle < 158) { - // dirInst.direction = "southwest"; - // dirInst.shortDirection = "SW"; - // return; - // } - // if(angle >= 158 && angle < 202) { - // dirInst.direction = "west"; - // dirInst.shortDirection = "W"; - // return; - // } - // if(angle >= 202 && angle < 248) { - // dirInst.direction = "northwest"; - // dirInst.shortDirection = "NW"; - // return; - // } - // if(angle >= 248 && angle < 292) { - // dirInst.direction = "north"; - // dirInst.shortDirection = "N"; - // return; - // } - // if(angle >= 292 && angle < 336) { - // dirInst.direction = "northeast"; - // dirInst.shortDirection = "NE"; - // return; - // } - // dirInst.direction = "East"; - // dirInst.shortDirection = "E"; - // return; - // } - // - }; static TurnInstructionsClass TurnInstructions; diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 3467da3af..c6c19612e 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -94,6 +94,10 @@ unsigned DescriptionFactory::Run(const unsigned zoomLevel) { indexOfSegmentBegin = i; } } + if(pathDescription[0].length == 0){ + INFO("Start at End of street"); + pathDescription[0].turnInstruction = 14; + } //Generalize poly line dp.Run(pathDescription, zoomLevel); diff --git a/Docs/WebFrontend/Route.js b/Docs/WebFrontend/Route.js index 1aea2bd1c..71acde7eb 100644 --- a/Docs/WebFrontend/Route.js +++ b/Docs/WebFrontend/Route.js @@ -29,7 +29,6 @@ //====================== // OBJECTS //Map -//var HOST_ROUTING_URL = 'http://localhost:5000/viaroute'; var HOST_ROUTING_URL = 'http://routingdemo.geofabrik.de/route-via/'; var HOST_WEBSITE = 'http://map.project-osrm.org/';//location.host @@ -100,7 +99,9 @@ function reroute() { */ function showResultsDragRoute(response) {    if (response) { -     //Display Route     showRouteGeometry(response);    } +     //Display Route +     showRouteGeometry(response); +    }   markersLayer.clearMarkers();    ISCALCULATING = false; } @@ -149,16 +150,32 @@ function showResultsRoute(response) {        //Show Route Instructions         output += '';        lengthOfArray = response.route_instructions.length; - for (i = 0; i < lengthOfArray; i++) { + +        var rowstyle='routeInstructionsEven'; +        var indexPos = response.route_instructions[0][3]; + var point = allRoutePoints[indexPos]; + + //Hack to suppress output of initial "0m" instruction + output += ''; + + for (i = 1; i < lengthOfArray; i++) { //console.log(response.route_instructions[i]);         //odd or even ? -         var rowstyle='routeInstructionsOdd'; -         if(i%2==0){ rowstyle='routeInstructionsEven'; } +         if(i%2==0){ + rowstyle='routeInstructionsEven'; + } else { + rowstyle='routeInstructionsOdd'; + } -            var indexPos = response.route_instructions[i][3]; +            indexPos = response.route_instructions[i][3]; //console.log('setting : ' + response.route_instructions[i] + ' at ' + allRoutePoints[indexPos]); - var point = allRoutePoints[indexPos]; -                    output += '';        } + point = allRoutePoints[indexPos]; +         +            output += ''; +        } var rowstyle='routeInstructionsOdd';       if(i%2==0){ rowstyle='routeInstructionsEven'; } if( lengthOfArray > 0) { @@ -168,7 +185,8 @@ function showResultsRoute(response) { output += '
1.'+response.route_instructions[0][0]+' on '+response.route_instructions[0][1]; + if(response.route_instructions[0][2] != 0) + output += ' for '+getDistanceWithUnit(response.route_instructions[0][2]); +     output += '
'+(i+1)+'.'+response.route_instructions[i][0]+' on '+response.route_instructions[i][1]+' for '+getDistanceWithUnit(response.route_instructions[i][2])+'
'+(i+1)+'.'+response.route_instructions[i][0]+' on '+response.route_instructions[i][1]+' for '+getDistanceWithUnit(response.route_instructions[i][2])+'
';        //alert(vectorLayerRoute.features[0].geometry.getVertices());         -        document.getElementById('information').innerHTML = output;    ISCALCULATING = false; +        document.getElementById('information').innerHTML = output; +    ISCALCULATING = false; ISCALCULATINGVIA = false;    } } @@ -228,8 +246,10 @@ function showRouteGeometry(response) { * showNoNameStreets()-Function to show route result */ function showNoNameStreets(response) { -    if (response) {     allRoutePoints.length = 0; -     vectorLayerRoute.removeFeatures(vectorLayerRoute.features);       // now with compression of the route geometry +    if (response) { +     allRoutePoints.length = 0; +     vectorLayerRoute.removeFeatures(vectorLayerRoute.features); +       // now with compression of the route geometry        var geometry = decodeRouteGeometry(response.route_geometry, 5);       var lengthOfArray = geometry.length;        var points = []; @@ -243,7 +263,8 @@ function showNoNameStreets(response) {         var indexPos = response.route_instructions[i][3];         var streetName = response.route_instructions[i][1]; if(streetName == ''){ colors[indexPos] = "#FF00FF"; } - else{ colors[indexPos] = "#0033ff"; }         } + else{ colors[indexPos] = "#0033ff"; } +         }        } //delete any previously displayed via route @@ -252,7 +273,10 @@ function showNoNameStreets(response) {                //Create Route Layer for Display        var color = "#0033ff"; -        var changeColor = false;        for (var i = 0; i < lengthOfArray; i++) {            var point = new OpenLayers.Geometry.Point(geometry[i][1], geometry[i][0]).transform(EPSG_4326, EPSG_900913);            points.push(point); +        var changeColor = false; +        for (var i = 0; i < lengthOfArray; i++) { +            var point = new OpenLayers.Geometry.Point(geometry[i][1], geometry[i][0]).transform(EPSG_4326, EPSG_900913); +            points.push(point);            allRoutePoints.push(point);            if(colors[i] != undefined){ changeColor=true;} @@ -262,14 +286,15 @@ function showNoNameStreets(response) { strokeColor: color, strokeOpacity: 0.7, strokeWidth: 5 - }); - vectorLayerRoute.addFeatures([feature]); - points = []; + }); + vectorLayerRoute.addFeatures([feature]); + points = []; points.push(point); if(colors[i] != undefined){ color = colors[i]; } - changeColor=false; - }        } + changeColor=false; + } +        }   } }