commit
d2458f3169
26
.gitignore
vendored
26
.gitignore
vendored
@ -54,23 +54,23 @@ stxxl.errlog
|
|||||||
|
|
||||||
# compiled protobuffers #
|
# compiled protobuffers #
|
||||||
#########################
|
#########################
|
||||||
DataStructures/pbf-proto/*.pb.h
|
/DataStructures/pbf-proto/*.pb.h
|
||||||
DataStructures/pbf-proto/*.pb.cc
|
/DataStructures/pbf-proto/*.pb.cc
|
||||||
|
|
||||||
# External Libs #
|
# External Libs #
|
||||||
#################
|
#################
|
||||||
lib/
|
/lib/
|
||||||
win/lib
|
/win/lib
|
||||||
|
|
||||||
# Visual Studio Temp + build Files #
|
# Visual Studio Temp + build Files #
|
||||||
####################################
|
####################################
|
||||||
win/*.user
|
/win/*.user
|
||||||
win/*.ncb
|
/win/*.ncb
|
||||||
win/*.suo
|
/win/*.suo
|
||||||
win/Debug/
|
/win/Debug/
|
||||||
win/Release/
|
/win/Release/
|
||||||
win/bin/
|
/win/bin/
|
||||||
win/bin-debug/
|
/win/bin-debug/
|
||||||
/osrm-extract
|
/osrm-extract
|
||||||
/osrm-routed
|
/osrm-routed
|
||||||
/osrm-prepare
|
/osrm-prepare
|
||||||
@ -78,6 +78,6 @@ win/bin-debug/
|
|||||||
|
|
||||||
# Sandbox folder #
|
# Sandbox folder #
|
||||||
###################
|
###################
|
||||||
sandbox/
|
/sandbox/
|
||||||
|
|
||||||
test/profile.lua
|
/test/profile.lua
|
@ -26,6 +26,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "ScriptingEnvironment.h"
|
#include "ScriptingEnvironment.h"
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
|
#include "../Util/LuaUtil.h"
|
||||||
#include "../Util/OpenMPWrapper.h"
|
#include "../Util/OpenMPWrapper.h"
|
||||||
|
|
||||||
ScriptingEnvironment::ScriptingEnvironment() {}
|
ScriptingEnvironment::ScriptingEnvironment() {}
|
||||||
@ -51,6 +52,9 @@ ScriptingEnvironment::ScriptingEnvironment(const char * fileName) {
|
|||||||
luabind::def("durationIsValid", durationIsValid),
|
luabind::def("durationIsValid", durationIsValid),
|
||||||
luabind::def("parseDuration", parseDuration)
|
luabind::def("parseDuration", parseDuration)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
luaAddScriptFolderToLoadPath( myLuaState, fileName );
|
||||||
|
|
||||||
//#pragma omp critical
|
//#pragma omp critical
|
||||||
// {
|
// {
|
||||||
// if(0 != luaL_dostring(
|
// if(0 != luaL_dostring(
|
||||||
|
@ -30,7 +30,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include "ExtractionHelperFunctions.h"
|
#include "ExtractionHelperFunctions.h"
|
||||||
#include "ExtractorStructs.h"
|
#include "ExtractorStructs.h"
|
||||||
#include "LuaUtil.h"
|
|
||||||
|
|
||||||
#include "../DataStructures/ImportNode.h"
|
#include "../DataStructures/ImportNode.h"
|
||||||
|
|
||||||
|
5
Rakefile
5
Rakefile
@ -7,6 +7,7 @@ require 'sys/proctable'
|
|||||||
DATA_FOLDER = 'sandbox'
|
DATA_FOLDER = 'sandbox'
|
||||||
PROFILE = 'bicycle'
|
PROFILE = 'bicycle'
|
||||||
OSRM_PORT = 5000
|
OSRM_PORT = 5000
|
||||||
|
PROFILES_FOLDER = '../profiles'
|
||||||
|
|
||||||
Cucumber::Rake::Task.new do |t|
|
Cucumber::Rake::Task.new do |t|
|
||||||
t.cucumber_opts = %w{--format pretty}
|
t.cucumber_opts = %w{--format pretty}
|
||||||
@ -116,9 +117,9 @@ end
|
|||||||
desc "Reprocess OSM data."
|
desc "Reprocess OSM data."
|
||||||
task :process => :setup do
|
task :process => :setup do
|
||||||
Dir.chdir DATA_FOLDER do
|
Dir.chdir DATA_FOLDER do
|
||||||
raise "Error while extracting data." unless system "../osrm-extract #{osm_data_area_name}.osm.pbf ../profiles/#{PROFILE}.lua"
|
raise "Error while extracting data." unless system "../osrm-extract #{osm_data_area_name}.osm.pbf #{PROFILES_FOLDER}/#{PROFILE}.lua"
|
||||||
puts
|
puts
|
||||||
raise "Error while preparing data." unless system "../osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions ../profiles/#{PROFILE}.lua"
|
raise "Error while preparing data." unless system "../osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions #{PROFILES_FOLDER}/#{PROFILE}.lua"
|
||||||
puts
|
puts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,12 +24,31 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#define LUAUTIL_H_
|
#define LUAUTIL_H_
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <boost/filesystem/convenience.hpp>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void LUA_print(T number) {
|
void LUA_print(T number) {
|
||||||
std::cout << "[LUA] " << number << std::endl;
|
std::cout << "[LUA] " << number << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the lua function <name> is defined
|
||||||
|
bool lua_function_exists(lua_State* lua_state, const char* name)
|
||||||
|
{
|
||||||
|
luabind::object g = luabind::globals(lua_state);
|
||||||
|
luabind::object func = g[name];
|
||||||
|
return func && (luabind::type(func) == LUA_TFUNCTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the folder contain the script to the lua load path, so script can easily require() other lua scripts inside that folder, or subfolders.
|
||||||
|
// See http://lua-users.org/wiki/PackagePath for details on the package.path syntax.
|
||||||
|
void luaAddScriptFolderToLoadPath(lua_State* myLuaState, const char* fileName) {
|
||||||
|
const boost::filesystem::path profilePath( fileName );
|
||||||
|
if( !profilePath.parent_path().empty() ) {
|
||||||
|
const std::string folder = profilePath.parent_path().string();
|
||||||
|
const std::string luaCode = "package.path = \"" + folder + "/?.lua;\" .. package.path";
|
||||||
|
luaL_dostring( myLuaState, luaCode.c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* LUAUTIL_H_ */
|
#endif /* LUAUTIL_H_ */
|
@ -44,8 +44,9 @@ extern "C" {
|
|||||||
#include "DataStructures/NNGrid.h"
|
#include "DataStructures/NNGrid.h"
|
||||||
#include "DataStructures/QueryEdge.h"
|
#include "DataStructures/QueryEdge.h"
|
||||||
#include "Util/BaseConfiguration.h"
|
#include "Util/BaseConfiguration.h"
|
||||||
#include "Util/InputFileUtil.h"
|
|
||||||
#include "Util/GraphLoader.h"
|
#include "Util/GraphLoader.h"
|
||||||
|
#include "Util/InputFileUtil.h"
|
||||||
|
#include "Util/LuaUtil.h"
|
||||||
#include "Util/StringUtil.h"
|
#include "Util/StringUtil.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -111,6 +112,11 @@ int main (int argc, char *argv[]) {
|
|||||||
// Connect LuaBind to this lua state
|
// Connect LuaBind to this lua state
|
||||||
luabind::open(myLuaState);
|
luabind::open(myLuaState);
|
||||||
|
|
||||||
|
//open utility libraries string library;
|
||||||
|
luaL_openlibs(myLuaState);
|
||||||
|
|
||||||
|
//adjust lua load path
|
||||||
|
luaAddScriptFolderToLoadPath( myLuaState, (argc > 3 ? argv[3] : "profile.lua") );
|
||||||
|
|
||||||
// Now call our function in a lua script
|
// Now call our function in a lua script
|
||||||
INFO("Parsing speedprofile from " << (argc > 3 ? argv[3] : "profile.lua") );
|
INFO("Parsing speedprofile from " << (argc > 3 ? argv[3] : "profile.lua") );
|
||||||
|
@ -13,7 +13,7 @@ OSM_TIMESTAMP = '2000-00-00T00:00:00Z'
|
|||||||
DEFAULT_SPEEDPROFILE = 'bicycle'
|
DEFAULT_SPEEDPROFILE = 'bicycle'
|
||||||
WAY_SPACING = 100
|
WAY_SPACING = 100
|
||||||
DEFAULT_GRID_SIZE = 100 #meters
|
DEFAULT_GRID_SIZE = 100 #meters
|
||||||
|
PROFILES_PATH = '../profiles'
|
||||||
|
|
||||||
ORIGIN = [1,1]
|
ORIGIN = [1,1]
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ def reprocess
|
|||||||
unless extracted?
|
unless extracted?
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
log "== Extracting #{@osm_file}.osm...", :preprocess
|
log "== Extracting #{@osm_file}.osm...", :preprocess
|
||||||
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} #{PROFILES_PATH}/#{@profile}.lua"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
raise ExtractError.new $?.exitstatus, "osrm-extract exited with code #{$?.exitstatus}."
|
||||||
end
|
end
|
||||||
@ -214,7 +214,7 @@ def reprocess
|
|||||||
unless prepared?
|
unless prepared?
|
||||||
log_preprocess_info
|
log_preprocess_info
|
||||||
log "== Preparing #{@osm_file}.osm...", :preprocess
|
log "== Preparing #{@osm_file}.osm...", :preprocess
|
||||||
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@profile}.lua"
|
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} #{PROFILES_PATH}/#{@profile}.lua"
|
||||||
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
log "*** Exited with code #{$?.exitstatus}.", :preprocess
|
||||||
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
raise PrepareError.new $?.exitstatus, "osrm-prepare exited with code #{$?.exitstatus}."
|
||||||
end
|
end
|
||||||
|
@ -1,39 +1,47 @@
|
|||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
|
|
||||||
def hash_of_file path
|
def hash_of_files paths
|
||||||
|
paths = [paths] unless paths.is_a? Array
|
||||||
hash = Digest::SHA1.new
|
hash = Digest::SHA1.new
|
||||||
|
for path in paths do
|
||||||
open(path,'r') do |io|
|
open(path,'r') do |io|
|
||||||
while !io.eof
|
while !io.eof
|
||||||
buf = io.readpartial 1024
|
buf = io.readpartial 1024
|
||||||
hash.update buf
|
hash.update buf
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return hash.hexdigest
|
return hash.hexdigest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def profile_hash
|
def profile_hash
|
||||||
@@profile_hashes ||= {}
|
@@profile_hashes ||= {}
|
||||||
@@profile_hashes[@profile] ||= hash_of_file "../profiles/#{@profile}.lua"
|
@@profile_hashes[@profile] ||= hash_of_files "#{PROFILES_PATH}/#{@profile}.lua"
|
||||||
end
|
end
|
||||||
|
|
||||||
def osm_hash
|
def osm_hash
|
||||||
@osm_hash ||= Digest::SHA1.hexdigest osm_str
|
@osm_hash ||= Digest::SHA1.hexdigest osm_str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def lua_lib_hash
|
||||||
|
@lua_lib_hash ||= hash_of_files Dir.glob("../profiles/lib/*.lua")
|
||||||
|
end
|
||||||
|
|
||||||
def bin_extract_hash
|
def bin_extract_hash
|
||||||
@@bin_extract_hash ||= hash_of_file '../osrm-extract'
|
@@bin_extract_hash ||= hash_of_files '../osrm-extract'
|
||||||
end
|
end
|
||||||
|
|
||||||
def bin_prepare_hash
|
def bin_prepare_hash
|
||||||
@@bin_prepare_hash ||= hash_of_file '../osrm-prepare'
|
@@bin_prepare_hash ||= hash_of_files '../osrm-prepare'
|
||||||
end
|
end
|
||||||
|
|
||||||
def bin_routed_hash
|
def bin_routed_hash
|
||||||
@@bin_routed_hash ||= hash_of_file '../osrm-routed'
|
@@bin_routed_hash ||= hash_of_files '../osrm-routed'
|
||||||
end
|
end
|
||||||
|
|
||||||
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
||||||
def fingerprint
|
def fingerprint
|
||||||
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{profile_hash}-#{osm_hash}"
|
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{profile_hash}-#{lua_lib_hash}-#{osm_hash}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require("lib/access")
|
||||||
|
|
||||||
-- Begin of globals
|
-- Begin of globals
|
||||||
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true}
|
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true}
|
||||||
access_tag_whitelist = { ["yes"] = true, ["permissive"] = true, ["designated"] = true }
|
access_tag_whitelist = { ["yes"] = true, ["permissive"] = true, ["designated"] = true }
|
||||||
@ -58,7 +60,6 @@ amenity_speeds = {
|
|||||||
route_speeds = {
|
route_speeds = {
|
||||||
["ferry"] = 5
|
["ferry"] = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
take_minimum_of_speeds = true
|
take_minimum_of_speeds = true
|
||||||
obey_oneway = true
|
obey_oneway = true
|
||||||
obey_bollards = false
|
obey_bollards = false
|
||||||
@ -70,19 +71,10 @@ u_turn_penalty = 20
|
|||||||
-- End of globals
|
-- End of globals
|
||||||
|
|
||||||
--find first tag in access hierachy which is set
|
--find first tag in access hierachy which is set
|
||||||
function find_access_tag(source)
|
|
||||||
for i,v in ipairs(access_tags_hierachy) do
|
|
||||||
local tag = source.tags:Find(v)
|
|
||||||
if tag ~= '' then --and tag ~= "" then
|
|
||||||
return tag
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function node_function (node)
|
function node_function (node)
|
||||||
local barrier = node.tags:Find ("barrier")
|
local barrier = node.tags:Find ("barrier")
|
||||||
local access = find_access_tag(node)
|
local access = Access.find_access_tag(node, access_tags_hierachy)
|
||||||
local traffic_signal = node.tags:Find("highway")
|
local traffic_signal = node.tags:Find("highway")
|
||||||
|
|
||||||
-- flag node if it carries a traffic light
|
-- flag node if it carries a traffic light
|
||||||
@ -134,7 +126,7 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
local service = way.tags:Find("service")
|
local service = way.tags:Find("service")
|
||||||
local area = way.tags:Find("area")
|
local area = way.tags:Find("area")
|
||||||
local amenity = way.tags:Find("amenity")
|
local amenity = way.tags:Find("amenity")
|
||||||
local access = find_access_tag(way)
|
local access = Access.find_access_tag(way, access_tags_hierachy)
|
||||||
|
|
||||||
-- initial routability check, filters out buildings, boundaries, etc
|
-- initial routability check, filters out buildings, boundaries, etc
|
||||||
if (not highway or highway == '') and
|
if (not highway or highway == '') and
|
||||||
|
13
profiles/lib/access.lua
Normal file
13
profiles/lib/access.lua
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
local ipairs = ipairs
|
||||||
|
|
||||||
|
module "Access"
|
||||||
|
|
||||||
|
function find_access_tag(source,access_tags_hierachy)
|
||||||
|
for i,v in ipairs(access_tags_hierachy) do
|
||||||
|
local tag = source.tags:Find(v)
|
||||||
|
if tag ~= '' then
|
||||||
|
return tag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user