From cbea651cf8ccc2a44380039731485e3f29c37c90 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 26 Jan 2013 18:58:33 +0100 Subject: [PATCH 01/11] test duration on ways --- features/testbot/duration.feature | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 features/testbot/duration.feature diff --git a/features/testbot/duration.feature b/features/testbot/duration.feature new file mode 100644 index 000000000..088f938d6 --- /dev/null +++ b/features/testbot/duration.feature @@ -0,0 +1,25 @@ +@routing @testbot @routes @duration +Feature: OSM Route Relation + + Background: + Given the profile "testbot" + + Scenario: Duration of ways + Given the node map + | a | b | | | | + | | | | e | | + | | c | | | d | + + And the ways + | nodes | highway | duration | + | ab | primary | 0:01 | + | bc | primary | 0:10 | + | cd | primary | 1:00 | + | de | primary | 10:00 | + + When I route I should get + | from | to | route | distance | time | + | a | b | ab | 100m +-1 | 1s +-1 | + | b | c | bc | 200m +-1 | 10s +-1 | + | c | d | cd | 300m +-1 | 60s +-1 | + | d | e | de | 144m +-1 | 600s +-1 | From c68a03d05c4f997ecda7a1f1272e329d559d5400 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 26 Jan 2013 18:59:31 +0100 Subject: [PATCH 02/11] add test scenario matching wiki graph explanation --- features/testbot/graph.feature | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 features/testbot/graph.feature diff --git a/features/testbot/graph.feature b/features/testbot/graph.feature new file mode 100644 index 000000000..97a517119 --- /dev/null +++ b/features/testbot/graph.feature @@ -0,0 +1,22 @@ +@routing @graph +Feature: Basic Routing +Test the input data descibed on https://github.com/DennisOSRM/Project-OSRM/wiki/Graph-representation + + Background: + Given the profile "testbot" + + @smallest + Scenario: Graph transformation + Given the node map + | | | d | + | a | b | c | + | | | e | + + And the ways + | nodes | + | abc | + | dce | + + When I route I should get + | from | to | route | + | a | e | abc,dce | From aa9d8c773f2cf94bf70ad13596c8ec0a09242160 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Sat, 26 Jan 2013 19:06:23 +0100 Subject: [PATCH 03/11] fix name of duration test --- features/testbot/duration.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/testbot/duration.feature b/features/testbot/duration.feature index 088f938d6..67bbe559d 100644 --- a/features/testbot/duration.feature +++ b/features/testbot/duration.feature @@ -1,5 +1,5 @@ @routing @testbot @routes @duration -Feature: OSM Route Relation +Feature: Durations Background: Given the profile "testbot" From ccdc6f1a632838708458d791d94449cc76d900c9 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 23:00:06 +0100 Subject: [PATCH 04/11] Removing dead code --- createHierarchy.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/createHierarchy.cpp b/createHierarchy.cpp index 87e9105c4..59fdfa63b 100644 --- a/createHierarchy.cpp +++ b/createHierarchy.cpp @@ -97,7 +97,6 @@ int main (int argc, char *argv[]) { std::string graphOut(argv[1]); graphOut += ".hsgr"; std::string ramIndexOut(argv[1]); ramIndexOut += ".ramIndex"; std::string fileIndexOut(argv[1]); fileIndexOut += ".fileIndex"; - std::string levelInfoOut(argv[1]); levelInfoOut += ".levels"; /*** Setup Scripting Environment ***/ if(!testDataFile( (argc > 3 ? argv[3] : "profile.lua") )) { From a92950d2345a30c0a53ff3c985d33d968a802c99 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 23:01:37 +0100 Subject: [PATCH 05/11] Fixes how durations are parsed --- profiles/bicycle.lua | 3 +-- profiles/testbot.lua | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 6038126ee..3c14dc250 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -162,8 +162,7 @@ function way_function (way, numberOfNodesInWay) way.direction = Way.bidirectional way.ignore_in_grid = true if durationIsValid(duration) then - way.speed = math.max( parseDuration(duration) / math.max(1, numberOfNodesInWay-1) ) - way.is_duration_set = true + way.duration = math.max( 1, parseDuration(duration) ) else way.speed = route_speeds[route] end diff --git a/profiles/testbot.lua b/profiles/testbot.lua index 3eb1ff339..9c7b103ac 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -49,9 +49,7 @@ function way_function (way, numberOfNodesInWay) way.name = name if route ~= nil and durationIsValid(duration) then - way.ignore_in_grid = true - way.speed = math.max( 1, parseDuration(duration) / math.max(1, numberOfNodesInWay-1) ) - way.is_duration_set = true + way.duration = math.max( 1, parseDuration(duration) ) else way.speed = speed_profile[highway] or speed_profile['default'] end From 86f4aebeade45eaa352e0c53acafc312d55d4a8e Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 23:03:04 +0100 Subject: [PATCH 06/11] Fixes test to expect time in minutes not seconds --- features/testbot/duration.feature | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/features/testbot/duration.feature b/features/testbot/duration.feature index 67bbe559d..bdf6344bb 100644 --- a/features/testbot/duration.feature +++ b/features/testbot/duration.feature @@ -18,8 +18,8 @@ Feature: Durations | de | primary | 10:00 | When I route I should get - | from | to | route | distance | time | - | a | b | ab | 100m +-1 | 1s +-1 | - | b | c | bc | 200m +-1 | 10s +-1 | - | c | d | cd | 300m +-1 | 60s +-1 | - | d | e | de | 144m +-1 | 600s +-1 | + | from | to | route | distance | time | + | a | b | ab | 100m +-1 | 60s +-1 | + | b | c | bc | 200m +-1 | 600s +-1 | + | c | d | cd | 300m +-1 | 3600s +-1 | + | d | e | de | 144m +-2 | 36000s +-1 | From 59481dd762797f396129b528d3541af449c7bf89 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 23:05:27 +0100 Subject: [PATCH 07/11] Adding duration member to way --- Extractor/ExtractorStructs.h | 4 ++-- Extractor/ScriptingEnvironment.cpp | 2 +- Extractor/XMLParser.cpp | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Extractor/ExtractorStructs.h b/Extractor/ExtractorStructs.h index fe5dd1b40..5ea22cbd9 100644 --- a/Extractor/ExtractorStructs.h +++ b/Extractor/ExtractorStructs.h @@ -52,10 +52,10 @@ struct _Way { keyVals.EraseAll(); direction = _Way::notSure; speed = -1; + duration = -1; type = -1; access = true; roundabout = false; - isDurationSet = false; isAccessRestricted = false; ignoreInGrid = false; } @@ -67,10 +67,10 @@ struct _Way { unsigned nameID; std::string name; double speed; + double duration; short type; bool access; bool roundabout; - bool isDurationSet; bool isAccessRestricted; bool ignoreInGrid; std::vector< NodeID > path; diff --git a/Extractor/ScriptingEnvironment.cpp b/Extractor/ScriptingEnvironment.cpp index c2f42d79d..330eac6af 100644 --- a/Extractor/ScriptingEnvironment.cpp +++ b/Extractor/ScriptingEnvironment.cpp @@ -69,10 +69,10 @@ ScriptingEnvironment::ScriptingEnvironment(const char * fileName) { .def(luabind::constructor<>()) .def_readwrite("name", &_Way::name) .def_readwrite("speed", &_Way::speed) + .def_readwrite("duration", &_Way::duration) .def_readwrite("type", &_Way::type) .def_readwrite("access", &_Way::access) .def_readwrite("roundabout", &_Way::roundabout) - .def_readwrite("is_duration_set", &_Way::isDurationSet) .def_readwrite("is_access_restricted", &_Way::isAccessRestricted) .def_readwrite("ignore_in_grid", &_Way::ignoreInGrid) .def_readwrite("tags", &_Way::keyVals) diff --git a/Extractor/XMLParser.cpp b/Extractor/XMLParser.cpp index 6449add3f..6b2c8a97d 100644 --- a/Extractor/XMLParser.cpp +++ b/Extractor/XMLParser.cpp @@ -139,7 +139,6 @@ bool XMLParser::Parse() { _RawRestrictionContainer XMLParser::_ReadXMLRestriction() { _RawRestrictionContainer restriction; std::string exception_of_restriction_tag; - bool restriction_is_excepted = false; if ( xmlTextReaderIsEmptyElement( inputReader ) != 1 ) { const int depth = xmlTextReaderDepth( inputReader );while ( xmlTextReaderRead( inputReader ) == 1 ) { From 03de87c2134b388adfb0ef5d4a9d2795095a2a64 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 23:06:23 +0100 Subject: [PATCH 08/11] Parsing duration when present --- Extractor/ExtractorCallbacks.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Extractor/ExtractorCallbacks.cpp b/Extractor/ExtractorCallbacks.cpp index 3db1d8d8b..956a9fee4 100644 --- a/Extractor/ExtractorCallbacks.cpp +++ b/Extractor/ExtractorCallbacks.cpp @@ -67,8 +67,7 @@ bool ExtractorCallbacks::restrictionFunction(_RawRestrictionContainer &r) { bool ExtractorCallbacks::wayFunction(_Way &w) { /*** Store name of way and split it into edge segments ***/ - if ( w.speed > 0 ) { //Only true if the way is specified by the speed profile - + if ( 0 < w.speed > 0 || 0 < w.duration ) { //Only true if the way is specified by the speed profile //Get the unique identifier for the street name const StringMap::const_iterator strit = stringMap->find(w.name); if(strit == stringMap->end()) { @@ -79,6 +78,11 @@ bool ExtractorCallbacks::wayFunction(_Way &w) { w.nameID = strit->second; } + if(w.duration > 0) { + //TODO: iterate all way segments and set duration corresponding to the length of each segment + w.speed = w.duration/(w.path.size()-1); + } + if(fabs(-1. - w.speed) < FLT_EPSILON){ WARN("found way with bogus speed, id: " << w.id); return true; @@ -93,7 +97,7 @@ bool ExtractorCallbacks::wayFunction(_Way &w) { } for(std::vector< NodeID >::size_type n = 0; n < w.path.size()-1; ++n) { - externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID, w.roundabout, w.ignoreInGrid, w.isDurationSet, w.isAccessRestricted)); + externalMemory->allEdges.push_back(_Edge(w.path[n], w.path[n+1], w.type, w.direction, w.speed, w.nameID, w.roundabout, w.ignoreInGrid, (w.duration > 0), w.isAccessRestricted)); externalMemory->usedNodeIDs.push_back(w.path[n]); } externalMemory->usedNodeIDs.push_back(w.path.back()); From 0ffa973ec63f1372531d0483d40fc404f89a8ed7 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 23:08:45 +0100 Subject: [PATCH 09/11] Exit gracefully when data is empty --- DataStructures/NNGrid.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DataStructures/NNGrid.h b/DataStructures/NNGrid.h index 92a6594e6..4c156ea61 100644 --- a/DataStructures/NNGrid.h +++ b/DataStructures/NNGrid.h @@ -108,6 +108,9 @@ public: int tlon = edge.lon2; AddEdge( _GridEdge( edge.id, edge.nameID, edge.weight, _Coordinate(slat, slon), _Coordinate(tlat, tlon), edge.belongsToTinyComponent ) ); } + if( 0 == entries.size() ) { + ERR("No viable edges for nearest neighbor index. Aborting"); + } double timestamp = get_timestamp(); //create index file on disk, old one is over written indexOutFile.open(fileIndexOut, std::ios::out | std::ios::binary | std::ios::trunc); From 061d78c68163d4655ef9c5d92b66d4bc1cdbc3e1 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 28 Jan 2013 08:30:34 +0100 Subject: [PATCH 10/11] test partial duration of ways --- features/testbot/duration.feature | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/features/testbot/duration.feature b/features/testbot/duration.feature index bdf6344bb..3d6735cc5 100644 --- a/features/testbot/duration.feature +++ b/features/testbot/duration.feature @@ -23,3 +23,17 @@ Feature: Durations | b | c | bc | 200m +-1 | 600s +-1 | | c | d | cd | 300m +-1 | 3600s +-1 | | d | e | de | 144m +-2 | 36000s +-1 | + + Scenario: Partial duration of ways + Given the node map + | a | b | | c | + + And the ways + | nodes | highway | duration | + | abc | primary | 0:01 | + + When I route I should get + | from | to | route | distance | time | + | a | c | abc | 300m +-1 | 60s +-1 | + | a | b | ab | 100m +-1 | 20s +-1 | + | b | c | bc | 200m +-1 | 40s +-1 | From cb2fcf4f520f22d96e1dfbcb1230bb23b053f849 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 28 Jan 2013 09:39:18 +0100 Subject: [PATCH 11/11] add @todo tag to partial way duration test --- features/testbot/duration.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/testbot/duration.feature b/features/testbot/duration.feature index 3d6735cc5..d22f28c4b 100644 --- a/features/testbot/duration.feature +++ b/features/testbot/duration.feature @@ -23,7 +23,8 @@ Feature: Durations | b | c | bc | 200m +-1 | 600s +-1 | | c | d | cd | 300m +-1 | 3600s +-1 | | d | e | de | 144m +-2 | 36000s +-1 | - + + @todo Scenario: Partial duration of ways Given the node map | a | b | | c |