Merging further changes

This commit is contained in:
DennisOSRM 2013-01-28 11:11:11 +01:00
commit 6a71163912
10 changed files with 77 additions and 13 deletions

View File

@ -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);

View File

@ -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());

View File

@ -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;

View File

@ -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)

View File

@ -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 ) {

View File

@ -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") )) {

View File

@ -0,0 +1,40 @@
@routing @testbot @routes @duration
Feature: Durations
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 | 60s +-1 |
| 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 |
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 |

View File

@ -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 |

View File

@ -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

View File

@ -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