Return a valid route even if nameIDs are bogus
This commit is contained in:
parent
2c6e68dda7
commit
1f7ddc865f
@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include "BinaryHeap.h"
|
#include "BinaryHeap.h"
|
||||||
#include "PhantomNodes.h"
|
#include "PhantomNodes.h"
|
||||||
|
#include "../Util/StrIngUtil.h"
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
|
||||||
struct _HeapData {
|
struct _HeapData {
|
||||||
@ -294,8 +295,12 @@ public:
|
|||||||
return ed.distance;
|
return ed.distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string& GetNameForNameID(const NodeID nameID) const {
|
inline std::string &GetNameForNameID(const NodeID nameID) const {
|
||||||
return _names->at(nameID);
|
return (nameID >= names->size() ? _names->at(0) : _names->at(nameID) );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string GetEscapedNameForNameID(const NodeID nameID) const {
|
||||||
|
return (nameID >= names->size() ? _names->at(0) : replaceAll(_names->at(nameID), "\"", "\\\"") );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline short GetTypeOfEdgeForOriginDestinationNodeID(NodeID s, NodeID t) const {
|
inline short GetTypeOfEdgeForOriginDestinationNodeID(NodeID s, NodeID t) const {
|
||||||
|
@ -79,4 +79,13 @@ inline void doubleToString(const double value, std::string & output)
|
|||||||
output = buffer ;
|
output = buffer ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string replaceAll( std::string result, const std::string& replaceWhat, const std::string& replaceWithWhat) {
|
||||||
|
while(true) {
|
||||||
|
const int pos = result.find(replaceWhat);
|
||||||
|
if (pos==-1) break;
|
||||||
|
result.replace(pos,replaceWhat.size(),replaceWithWhat);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
#endif /* STRINGUTIL_H_ */
|
#endif /* STRINGUTIL_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user