Refactoring method names

This commit is contained in:
Dennis Luxen 2011-07-07 08:01:14 +00:00
parent 132c25fd3b
commit dae6d1c730
4 changed files with 51 additions and 45 deletions

View File

@ -78,10 +78,10 @@ public:
output += "["; output += "[";
string tmp; string tmp;
for(unsigned i = 0; i < polyline.size(); i++) { for(unsigned i = 0; i < polyline.size(); i++) {
convertLatLon(polyline[i].lat, tmp); convertInternalLatLonToString(polyline[i].lat, tmp);
output += "["; output += "[";
output += tmp; output += tmp;
convertLatLon(polyline[i].lon, tmp); convertInternalLatLonToString(polyline[i].lon, tmp);
output += ", "; output += ", ";
output += tmp; output += tmp;
output += "]"; output += "]";

View File

@ -49,9 +49,9 @@ public:
startName = sEngine->GetEscapedNameForNameID(streetID); startName = sEngine->GetEscapedNameForNameID(streetID);
streetID = sEngine->GetNameIDForOriginDestinationNodeID(phantomNodes->targetNode1, phantomNodes->targetNode2); streetID = sEngine->GetNameIDForOriginDestinationNodeID(phantomNodes->targetNode1, phantomNodes->targetNode2);
targetName = sEngine->GetEscapedNameForNameID(streetID); targetName = sEngine->GetEscapedNameForNameID(streetID);
convertLatLon(phantomNodes->startCoord.lat, tmp); convertInternalLatLonToString(phantomNodes->startCoord.lat, tmp);
bodyString += ("\t\t<rtept lat=\""+tmp+"\""); bodyString += ("\t\t<rtept lat=\""+tmp+"\"");
convertLatLon(phantomNodes->startCoord.lon, tmp); convertInternalLatLonToString(phantomNodes->startCoord.lon, tmp);
bodyString += (" lon=\""+tmp+"\">"); bodyString += (" lon=\""+tmp+"\">");
bodyString += ("\n\t\t\t<desc>Start from "); bodyString += ("\n\t\t\t<desc>Start from ");
bodyString += startName; bodyString += startName;
@ -118,20 +118,15 @@ public:
nextType = sEngine->GetTypeOfEdgeForOriginDestinationNodeID(it->node, (it+1)->node); nextType = sEngine->GetTypeOfEdgeForOriginDestinationNodeID(it->node, (it+1)->node);
} }
convertLatLon(current.lat, tmp); convertInternalLatLonToString(current.lat, tmp);
bodyString += "\n\t\t<rtept lat=\"" + tmp + "\" "; bodyString += "\n\t\t<rtept lat=\"" + tmp + "\" ";
convertLatLon(current.lon, tmp); convertInternalLatLonToString(current.lon, tmp);
bodyString += "lon=\"" + tmp + "\">\n"; bodyString += "lon=\"" + tmp + "\">\n";
double angle = GetAngleBetweenTwoEdges(startOfSegment, current, next); double angle = GetAngleBetweenTwoEdges(startOfSegment, current, next);
if(178 > angle || 182 < angle) { if(178 > angle || 182 < angle) {
convertLatLon(current.lon, tmp); convertInternalCoordinateToString(current, tmp);
lineString += tmp; lineString += tmp;
lineString += ",";
convertLatLon(current.lat, tmp);
lineString += tmp;
lineString += " ";
startOfSegment = current;
} }
if(nextID == nameID) { if(nextID == nameID) {
@ -150,9 +145,6 @@ public:
bodyString += "follow road "; bodyString += "follow road ";
if(nameID != 0) if(nameID != 0)
bodyString += sEngine->GetEscapedNameForNameID(nameID); bodyString += sEngine->GetEscapedNameForNameID(nameID);
string lat; string lon;
convertLatLon(lastPlace.lon, lon);
convertLatLon(lastPlace.lat, lat);
lastPlace = current; lastPlace = current;
if(angle > 160 && angle < 200) { if(angle > 160 && angle < 200) {
bodyString += /* " (" << angle << ")*/"drive ahead, "; bodyString += /* " (" << angle << ")*/"drive ahead, ";
@ -185,9 +177,9 @@ public:
previous = current; previous = current;
type = nextType; type = nextType;
} }
convertLatLon(phantomNodes->targetCoord.lat, tmp); convertInternalLatLonToString(phantomNodes->targetCoord.lat, tmp);
bodyString += "\n\t\t<rtept lat=\"" + tmp + "\" "; bodyString += "\n\t\t<rtept lat=\"" + tmp + "\" ";
convertLatLon(phantomNodes->targetCoord.lon, tmp); convertInternalLatLonToString(phantomNodes->targetCoord.lon, tmp);
bodyString += "lon=\"" + tmp + "\">\n"; bodyString += "lon=\"" + tmp + "\">\n";
bodyString += "\t\t\t<desc>"; bodyString += "\t\t\t<desc>";
@ -210,10 +202,7 @@ public:
//put targetCoord to linestring //put targetCoord to linestring
convertLatLon(phantomNodes->targetCoord.lon, tmp); convertInternalCoordinateToString(phantomNodes->targetCoord, tmp);
lineString += tmp;
lineString += ",";
convertLatLon(phantomNodes->targetCoord.lat, tmp);
lineString += tmp; lineString += tmp;
ostringstream s; ostringstream s;
s << 10*(round(entireDistance/10.)); s << 10*(round(entireDistance/10.));

View File

@ -77,12 +77,8 @@ public:
reply.content += ("]]></name>\n"); reply.content += ("]]></name>\n");
//put start coord to linestring; //put start coord to linestring;
convertLatLon(phantomNodes->startCoord.lon, tmp); convertInternalCoordinateToString(phantomNodes->startCoord, tmp);
lineString += tmp; lineString += tmp;
lineString += ",";
convertLatLon(phantomNodes->startCoord.lat, tmp);
lineString += tmp;
lineString += " ";
reply.content += ("\t</Placemark>\n"); reply.content += ("\t</Placemark>\n");
_Coordinate previous(phantomNodes->startCoord.lat, phantomNodes->startCoord.lon); _Coordinate previous(phantomNodes->startCoord.lat, phantomNodes->startCoord.lon);
@ -114,13 +110,8 @@ public:
double angle = GetAngleBetweenTwoEdges(startOfSegment, current, next); double angle = GetAngleBetweenTwoEdges(startOfSegment, current, next);
if(178 > angle || 182 < angle) { if(178 > angle || 182 < angle) {
convertLatLon(current.lon, tmp); convertInternalCoordinateToString(current, tmp);
lineString += tmp; lineString += tmp;
lineString += ",";
convertLatLon(current.lat, tmp);
lineString += tmp;
lineString += " ";
startOfSegment = current;
} }
if(nextID == nameID) { if(nextID == nameID) {
@ -153,9 +144,6 @@ public:
reply.content += numberString.str(); reply.content += numberString.str();
numberString.str(""); numberString.str("");
reply.content += "m</description>"; reply.content += "m</description>";
string lat; string lon;
convertLatLon(lastPlace.lon, lon);
convertLatLon(lastPlace.lat, lat);
lastPlace = current; lastPlace = current;
// reply.content += "\n <Point>"; // reply.content += "\n <Point>";
// reply.content += "<Coordinates>"; // reply.content += "<Coordinates>";
@ -217,10 +205,7 @@ public:
reply.content += "\t</Placemark>\n"; reply.content += "\t</Placemark>\n";
//put targetCoord to linestring //put targetCoord to linestring
convertLatLon(phantomNodes->targetCoord.lon, tmp); convertInternalCoordinateToString(phantomNodes->targetCoord, tmp);
lineString += tmp;
lineString += ",";
convertLatLon(phantomNodes->targetCoord.lat, tmp);
lineString += tmp; lineString += tmp;
if(!config.geometry){ if(!config.geometry){

View File

@ -52,8 +52,7 @@ inline char* printInt( char* buffer, int value )
return buffer; return buffer;
} }
inline void intToString(const int value, std::string & output) inline void intToString(const int value, std::string & output) {
{
// The largest 32-bit integer is 4294967295, that is 10 chars // The largest 32-bit integer is 4294967295, that is 10 chars
// On the safe side, add 1 for sign, and 1 for trailing zero // On the safe side, add 1 for sign, and 1 for trailing zero
char buffer[12] ; char buffer[12] ;
@ -61,7 +60,7 @@ inline void intToString(const int value, std::string & output)
output = buffer ; output = buffer ;
} }
inline void convertLatLon(const int value, std::string & output) inline void convertInternalLatLonToString(const int value, std::string & output)
{ {
char buffer[100]; char buffer[100];
buffer[10] = 0; // Nullterminierung buffer[10] = 0; // Nullterminierung
@ -69,9 +68,26 @@ inline void convertLatLon(const int value, std::string & output)
output = string; output = string;
} }
/* used to be boosts lexical cast, but this was too slow */ inline void convertInternalCoordinateToString(const _Coordinate & coord, std::string & output) {
inline void doubleToString(const double value, std::string & output) std::string tmp;
{ convertInternalLatLonToString(coord.lon, tmp);
output = tmp;
output += ",";
convertInternalLatLonToString(coord.lat, tmp);
output += tmp;
output += " ";
}
inline void convertInternalReversedCoordinateToString(const _Coordinate & coord, std::string & output) {
std::string tmp;
convertInternalLatLonToString(coord.lat, tmp);
output = tmp;
output += ",";
convertInternalLatLonToString(coord.lon, tmp);
output += tmp;
output += " ";
}
inline void doubleToString(const double value, std::string & output){
// The largest 32-bit integer is 4294967295, that is 10 chars // The largest 32-bit integer is 4294967295, that is 10 chars
// On the safe side, add 1 for sign, and 1 for trailing zero // On the safe side, add 1 for sign, and 1 for trailing zero
char buffer[12] ; char buffer[12] ;
@ -91,6 +107,22 @@ inline std::string & replaceAll(std::string &s, const std::string &sub, const st
return s; return s;
} }
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
std::stringstream ss(s);
std::string item;
while(std::getline(ss, item, delim)) {
if(item.size() > 0)
elems.push_back(item);
}
return elems;
}
std::vector<std::string> split(const std::string &s, char delim) {
std::vector<std::string> elems;
return split(s, delim, elems);
}
std::string originals[] = {"&", "\"", "<", ">", "'", "[", "]"}; std::string originals[] = {"&", "\"", "<", ">", "'", "[", "]"};
std::string entities[] = {"&amp;", "&quot;", "&lt;", "&gt;", "&#39;", "&91;", "&93;" }; std::string entities[] = {"&amp;", "&quot;", "&lt;", "&gt;", "&#39;", "&91;", "&93;" };