start and target are now identified by name in description and heading is given in first advice.
This commit is contained in:
parent
06ce09d0d7
commit
5217307132
@ -40,12 +40,48 @@ public:
|
||||
void Run(http::Reply& reply, std::vector< _PathData > * path, PhantomNodes * phantomNodes, SearchEngineT * sEngine, unsigned distance) {
|
||||
string tmp;
|
||||
string lineString;
|
||||
string startName;
|
||||
string targetName;
|
||||
string direction = "East";
|
||||
reply.content += ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||
reply.content += ("<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n");
|
||||
reply.content += ("<Document>\n");
|
||||
//todo reply.content += ("<name><![CDATA[<start> to <target>]]><name>");
|
||||
|
||||
if(distance != UINT_MAX) {
|
||||
unsigned streetID = sEngine->GetNameIDForOriginDestinationNodeID(phantomNodes->startNode1, phantomNodes->startNode2);
|
||||
startName = sEngine->GetNameForNameID(streetID);
|
||||
streetID = sEngine->GetNameIDForOriginDestinationNodeID(phantomNodes->targetNode1, phantomNodes->targetNode2);
|
||||
targetName = sEngine->GetNameForNameID(streetID);
|
||||
|
||||
reply.content += ("\t<Placemark>\n");
|
||||
reply.content += ("\t\t<name><![CDATA[Start from <start> direction <northeast>]]></name>\n");
|
||||
reply.content += ("\t\t<name><![CDATA[Start from ");
|
||||
reply.content += startName;
|
||||
reply.content += (" direction ");
|
||||
_Coordinate tmpCoord;
|
||||
if(path->size() > 0)
|
||||
sEngine->getNodeInfo(path->begin()->node, tmpCoord);
|
||||
else
|
||||
tmpCoord = phantomNodes->targetCoord;
|
||||
|
||||
int angle = round(GetAngleBetweenTwoEdges(_Coordinate(phantomNodes->startCoord.lat, phantomNodes->startCoord.lon), tmpCoord, _Coordinate(tmpCoord.lat, tmpCoord.lon-1000)));
|
||||
if(angle >= 23 && angle < 67)
|
||||
direction = "South-East";
|
||||
if(angle >= 67 && angle < 113)
|
||||
direction = "South";
|
||||
if(angle >= 113 && angle < 158)
|
||||
direction = "South-West";
|
||||
if(angle >= 158 && angle < 202)
|
||||
direction = "West";
|
||||
if(angle >= 202 && angle < 248)
|
||||
direction = "North-West";
|
||||
if(angle >= 248 && angle < 292)
|
||||
direction = "North";
|
||||
if(angle >= 292 && angle < 336)
|
||||
direction = "North-East";
|
||||
|
||||
reply.content += direction;
|
||||
|
||||
reply.content += ("]]></name>\n");
|
||||
|
||||
//put start coord to linestring;
|
||||
convertLatLon(phantomNodes->startCoord.lon, tmp);
|
||||
@ -56,7 +92,6 @@ public:
|
||||
lineString += " ";
|
||||
|
||||
reply.content += ("\t</Placemark>\n");
|
||||
if(distance != UINT_MAX) {
|
||||
_Coordinate previous(phantomNodes->startCoord.lat, phantomNodes->startCoord.lon);
|
||||
_Coordinate next, current, lastPlace;
|
||||
stringstream numberString;
|
||||
@ -160,15 +195,15 @@ public:
|
||||
type = sEngine->GetTypeOfEdgeForOriginDestinationNodeID(phantomNodes->targetNode1, phantomNodes->targetNode2);
|
||||
reply.content += "follow road ";
|
||||
reply.content += sEngine->GetNameForNameID(nameID);
|
||||
reply.content += " (type: ";
|
||||
numberString << type;
|
||||
reply.content += numberString.str();
|
||||
numberString.str("");
|
||||
reply.content += ", id: ";
|
||||
numberString << nameID;
|
||||
reply.content += numberString.str();
|
||||
numberString.str("");
|
||||
reply.content += ")]]></name>\n\t\t<description>drive for ";
|
||||
// reply.content += " (type: ";
|
||||
// numberString << type;
|
||||
// reply.content += numberString.str();
|
||||
// numberString.str("");
|
||||
// reply.content += ", id: ";
|
||||
// numberString << nameID;
|
||||
// reply.content += numberString.str();
|
||||
// numberString.str(")");
|
||||
reply.content += "]]></name>\n\t\t<description>drive for ";
|
||||
lengthOfInstruction = ApproximateDistance(previous.lat, previous.lon, phantomNodes->targetCoord.lat, phantomNodes->targetCoord.lon) + tempDist;
|
||||
entireDistance += lengthOfInstruction;
|
||||
numberString << 10*(round(lengthOfInstruction/10.));
|
||||
@ -193,7 +228,11 @@ public:
|
||||
lineString += tmp;
|
||||
|
||||
reply.content += "\t<Placemark>\n"
|
||||
"\t\t<name>Route</name>\n"
|
||||
"\t\t<name><![CDATA[Route from ";
|
||||
reply.content += startName;
|
||||
reply.content += " to ";
|
||||
reply.content += targetName;
|
||||
reply.content += "]]></name>\n"
|
||||
"\t\t<description>"
|
||||
"<![CDATA[Distance: ";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user