diff --git a/AUTHORS.TXT b/AUTHORS.TXT index 20eddc025..bb6c50b12 100644 --- a/AUTHORS.TXT +++ b/AUTHORS.TXT @@ -3,4 +3,5 @@ The following people contributed code to the Open Source Routing Machine: Christian Vetter Dennis Luxen Ruslan Krenzler -Frederik Ramm \ No newline at end of file +Frederik Ramm +Bharath Vissapragada \ No newline at end of file diff --git a/Plugins/JSONDescriptor.h b/Plugins/JSONDescriptor.h index 1a0032f91..13c439e7e 100644 --- a/Plugins/JSONDescriptor.h +++ b/Plugins/JSONDescriptor.h @@ -25,15 +25,15 @@ or see http://www.gnu.org/licenses/agpl.txt. static double areaThresholds[19] = { 5000, 5000, 5000, 5000, 5000, 2500, 2000, 1500, 800, 400, 250, 150, 100, 75, 25, 20, 10, 5 }; -template +template class JSONDescriptor : public BaseDescriptor { private: short zoom; public: JSONDescriptor() : zoom(18) {} void SetZoom(const unsigned short z) { - if(z > 18) - zoom = 18; + if(z > 19) + zoom = 19; zoom = z; } @@ -147,8 +147,8 @@ public: } double angle = GetAngleBetweenTwoEdges(startOfSegment, current, next); double area = fabs(0.5*( startOfSegment.lon*(current.lat - next.lat) + current.lon*(next.lat - startOfSegment.lat) + next.lon*(startOfSegment.lat - current.lat) ) ); -// std::cout << "Area for: " << area << std::endl; - if(area > areaThresholds[zoom] || false == SimplifyRoute) { + // std::cout << "Area for: " << area << std::endl; + if(area > areaThresholds[zoom] || 19 == zoom) { painted++; convertLatLon(current.lat, tmp); routeGeometryString += "["; @@ -205,7 +205,7 @@ public: lastPlace = current; routeInstructionString += "[\""; - if(angle > 160 && angle < 200) { + if(angle > 160 && angle < 200) { routeInstructionString += /* " (" << angle << ")*/"Continue"; } else if (angle > 290 && angle <= 360) { routeInstructionString += /*" (" << angle << ")*/ "Turn sharp left"; @@ -277,6 +277,8 @@ public: s << 10*(round(entireDistance/10.)); routeSummaryString += "\"total_distance\":"; routeSummaryString += s.str(); + + routeSummaryString += ",\"total_time\":"; //give travel time in minutes int travelTime = distance; @@ -302,10 +304,14 @@ public: reply.content += routeSummaryString; reply.content += "},"; reply.content += "\"route_geometry\": ["; - reply.content += routeGeometryString; + if(GeometryOn) { + reply.content += routeGeometryString; + } reply.content += "],"; reply.content += "\"route_instructions\": ["; - reply.content += routeInstructionString; + if(GeometryOn || InstructionsOn) { + reply.content += routeInstructionString; + } reply.content += "],"; reply.content += "\"transactionId\": \"OSRM Routing Engine JSON Descriptor (beta)\""; reply.content += "}"; diff --git a/Plugins/KMLDescriptor.h b/Plugins/KMLDescriptor.h index a398647da..2c74f84b4 100644 --- a/Plugins/KMLDescriptor.h +++ b/Plugins/KMLDescriptor.h @@ -21,7 +21,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef KML_DESCRIPTOR_H_ #define KML_DESCRIPTOR_H_ -template +template class KMLDescriptor : public BaseDescriptor{ public: void SetZoom(const unsigned short z) { } @@ -30,6 +30,7 @@ public: string lineString; string startName; string targetName; + double entireDistance = 0; string direction = "East"; reply.content += ("\n"); reply.content += ("\n"); @@ -85,7 +86,6 @@ public: stringstream numberString; double tempDist = 0; - double entireDistance = 0; double lengthOfInstruction = 0; NodeID nextID = UINT_MAX; NodeID nameID = sEngine->GetNameIDForOriginDestinationNodeID(phantomNodes->startNode1, phantomNodes->startNode2); @@ -109,7 +109,7 @@ public: } double angle = GetAngleBetweenTwoEdges(startOfSegment, current, next); - if(178 > angle || 182 < angle || false == SimplifyRoute) { + if(178 > angle || 182 < angle) { convertLatLon(current.lon, tmp); lineString += tmp; lineString += ","; @@ -218,6 +218,13 @@ public: lineString += ","; convertLatLon(phantomNodes->targetCoord.lat, tmp); lineString += tmp; + if(!Geometry){ + + reply.content = ("\n"); + reply.content += ("\n"); + reply.content += ("\n"); + } + reply.content += "\t\n" "\t\t" - "\n" - "\t\t\n" + "\n"; + + if(Geometry) { + + reply.content += "\t\t\n" "\t\t\t\n" "\t\t\t\t"; reply.content += lineString; reply.content += "\n" "\t\t\t\n" - "\t\t\n" - "\t\n"; + "\t\t\n"; + } + reply.content += "\t\n"; } reply.content += "\n"; } diff --git a/Plugins/RoutePlugin.h b/Plugins/RoutePlugin.h index a399aa794..8db631231 100644 --- a/Plugins/RoutePlugin.h +++ b/Plugins/RoutePlugin.h @@ -102,6 +102,12 @@ public: int lat2 = static_cast(100000.*atof(routeParameters.parameters[2].c_str())); int lon2 = static_cast(100000.*atof(routeParameters.parameters[3].c_str())); + bool geometry(true); + + if("false" == routeParameters.options["geometry"]) { + geometry = false; + } + if(lat1>90*100000 || lat1 <-90*100000 || lon1>180*100000 || lon1 <-180*100000) { reply = http::Reply::stockReply(http::Reply::badRequest); return; @@ -127,8 +133,7 @@ public: reply.content += "(\n"; } unsigned descriptorType = descriptorTable[routeParameters.options.Find("output")]; - const bool simplifiedRoute = (routeParameters.options.Find("simplified") == "yes"); - unsigned short zoom; + unsigned short zoom = 18; if(routeParameters.options.Find("z") != ""){ zoom = atoi(routeParameters.options.Find("z").c_str()); if(18 < zoom) @@ -137,22 +142,25 @@ public: //todo: put options in a seperate struct and pass it to the descriptor switch(descriptorType){ case 0: - if(simplifiedRoute) - desc = new KMLDescriptor >, true >(); + if(geometry) + desc = new KMLDescriptor >, true>(); else - desc = new KMLDescriptor >, false >(); + desc = new KMLDescriptor >, false>(); + break; case 1: - if(simplifiedRoute) - desc = new JSONDescriptor >, true >(); + if(geometry) + desc = new JSONDescriptor >, true>(); else - desc = new JSONDescriptor >, false >(); + desc = new JSONDescriptor >, false>(); + break; default: - if(simplifiedRoute) - desc = new KMLDescriptor >, true >(); + if(geometry) + desc = new KMLDescriptor >, true>(); else - desc = new KMLDescriptor >, false >(); + desc = new KMLDescriptor >, false>(); + break; } desc->SetZoom(zoom);