Skip to content

Commit

Permalink
Merge PR #970 'experimental/cuke_import_format' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisOSRM committed Apr 1, 2014
2 parents 717787f + e73145d commit 0ef7a72
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 11 deletions.
3 changes: 0 additions & 3 deletions Extractor/XMLParser.cpp
Expand Up @@ -41,9 +41,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/ref.hpp>

XMLParser::XMLParser(const char * filename, ExtractorCallbacks* ec, ScriptingEnvironment& se) : BaseParser(ec, se) {
SimpleLogger().Write(logWARNING) <<
"Parsing plain .osm/.osm.bz2 is deprecated. Switch to .pbf";

inputReader = inputReaderFactory(filename);
}

Expand Down
5 changes: 5 additions & 0 deletions extractor.cpp
Expand Up @@ -193,6 +193,11 @@ int main (int argc, char *argv[]) {
(get_timestamp() - parsing_start_time) <<
" seconds";

if( externalMemory.all_edges_list.empty() ) {
SimpleLogger().Write(logWARNING) << "The input data is empty, exiting.";
return -1;
}

externalMemory.PrepareData(output_file_name, restrictionsFileName);

delete parser;
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/data.rb
Expand Up @@ -2,6 +2,10 @@
set_profile profile
end

Given(/^the import format "(.*?)"$/) do |format|
set_input_format format
end

Given /^a grid size of (\d+) meters$/ do |meters|
set_grid_size meters
end
Expand Down
13 changes: 11 additions & 2 deletions features/support/data.rb
Expand Up @@ -13,7 +13,7 @@
DEFAULT_GRID_SIZE = 100 #meters
PROFILES_PATH = '../profiles'
BIN_PATH = '../build'

DEFAULT_INPUT_FORMAT = 'osm'
DEFAULT_ORIGIN = [1,1]

class Location
Expand All @@ -25,6 +25,15 @@ def initialize lon,lat
end
end

def set_input_format format
raise '*** Input format must be eiter "osm" or "pbf"' unless ['pbf','osm'].include? format.to_s
@input_format = format.to_s
end

def input_format
@input_format || DEFAULT_INPUT_FORMAT
end

def sanitized_scenario_title
@sanitized_scenario_title ||= @scenario_title.gsub /[^0-9A-Za-z.\-]/, '_'
end
Expand Down Expand Up @@ -244,8 +253,8 @@ def write_timestamp
end

def reprocess
use_pbf = true
Dir.chdir TEST_FOLDER do
use_pbf = (input_format=='pbf')
write_osm
write_timestamp
convert_osm_to_pbf if use_pbf
Expand Down
156 changes: 156 additions & 0 deletions features/testbot/protobuffer.feature
@@ -0,0 +1,156 @@
@routing @pbf
Feature: Importing protobuffer (.pbf) format
# Test normally read .osm, which is faster than .pbf files,
# since we don't need to use osmosis to first convert to .pbf
# The scenarios in this file test the ability to import .pbf files,
# including nodes, way, restictions, and a various special situations.

Background:
Given the profile "testbot"
And the import format "pbf"

Scenario: Testbot - Protobuffer import, nodes and ways
Given the node map
| | | | d |
| a | b | c | |
| | | | e |

And the ways
| nodes | highway | oneway |
| abc | primary | |
| cd | primary | yes |
| ce | river | |
| de | primary | |

When I route I should get
| from | to | route |
| d | c | de,ce |
| e | d | de |


Scenario: Testbot - Protobuffer import, turn restiction relations
Given the node map
| | n | |
| w | j | e |
| | s | |

And the ways
| nodes | oneway |
| sj | yes |
| nj | -1 |
| wj | -1 |
| ej | -1 |

And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | sj | wj | j | no_left_turn |

When I route I should get
| from | to | route |
| s | w | |
| s | n | sj,nj |
| s | e | sj,ej |


Scenario: Testbot - Protobuffer import, distances at longitude 45
Given the node locations
| node | lat | lon |
| a | 80 | 45 |
| b | 0 | 45 |

And the ways
| nodes |
| ab |

When I route I should get
| from | to | route | distance |
| a | b | ab | 8905559m ~0.1% |

Scenario: Testbot - Protobuffer import, distances at longitude 80
Given the node locations
| node | lat | lon |
| a | 80 | 80 |
| b | 0 | 80 |

And the ways
| nodes |
| ab |

When I route I should get
| from | to | route | distance |
| a | b | ab | 8905559m ~0.1% |

Scenario: Testbot - Protobuffer import, empty dataset
Given the node map
| |

Given the ways
| nodes |

When I preprocess data
Then "osrm-extract" should return code 255


Scenario: Testbot - Protobuffer import, streetnames with UTF characters
Given the node map
| a | b | c | d |

And the ways
| nodes | name |
| ab | Scandinavian København |
| bc | Japanese 東京 |
| cd | Cyrillic Москва |

When I route I should get
| from | to | route |
| a | b | Scandinavian København |
| b | c | Japanese 東京 |
| c | d | Cyrillic Москва |

Scenario: Testbot - Protobuffer import, bearing af 45 degree intervals
Given the node map
| b | a | h |
| c | x | g |
| d | e | f |

And the ways
| nodes |
| xa |
| xb |
| xc |
| xd |
| xe |
| xf |
| xg |
| xh |

When I route I should get
| from | to | route | compass | bearing |
| x | a | xa | N | 0 |
| x | b | xb | NW | 315 |
| x | c | xc | W | 270 |
| x | d | xd | SW | 225 |
| x | e | xe | S | 180 |
| x | f | xf | SE | 135 |
| x | g | xg | E | 90 |
| x | h | xh | NE | 45 |


Scenario: Testbot - Protobuffer import, rraffic signals should incur a delay
Given the node map
| a | b | c |
| d | e | f |

And the nodes
| node | highway |
| e | traffic_signals |

And the ways
| nodes |
| abc |
| def |

When I route I should get
| from | to | route | time | distance |
| a | c | abc | 20s +-1 | 200m +-1 |
| d | f | def | 27s +-1 | 200m +-1 |
12 changes: 6 additions & 6 deletions prepare.cpp
Expand Up @@ -236,17 +236,17 @@ int main (int argc, char *argv[]) {
std::vector<ImportEdge> edgeList;
NodeID nodeBasedNodeNumber = readBinaryOSRMGraphFromStream(in, edgeList, bollardNodes, trafficLightNodes, &internalToExternalNodeMapping, inputRestrictions);
in.close();
SimpleLogger().Write() <<
inputRestrictions.size() << " restrictions, " <<
bollardNodes.size() << " bollard nodes, " <<
trafficLightNodes.size() << " traffic lights";

if( edgeList.empty() ) {
SimpleLogger().Write(logWARNING) << "The input data is broken. "
"It is impossible to do any turns in this graph";
SimpleLogger().Write(logWARNING) << "The input data is empty, exiting.";
return -1;
}

SimpleLogger().Write() <<
inputRestrictions.size() << " restrictions, " <<
bollardNodes.size() << " bollard nodes, " <<
trafficLightNodes.size() << " traffic lights";

/***
* Building an edge-expanded graph from node-based input an turn restrictions
*/
Expand Down

0 comments on commit 0ef7a72

Please sign in to comment.