-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Using location dependent data in profiles
Prepare location-dependent data in GeoJSON format, e.g. country names using query-overpass
:
echo '[out:json];rel["boundary"="administrative"]["admin_level"="2"]["ISO3166-1:alpha3"];out geom;' | \
query-overpass --flat-properties > countries.geojson
grep -oP '"ISO3166-1:alpha3":"[A-Z]{3}"' countries.geojson | sort > ISO3166-1:alpha3.txt
wc -l ISO3166-1:alpha3.txt
217 ISO3166-1:alpha3.txt
Add location-dependent handling in a profile, e.g. print way ids and country names in process_way
:
print ('Way ' .. way:id() .. ' in ' .. way:get_location_tag('name') ..
' [' .. way:get_location_tag('ISO3166-1:alpha3') .. ']')
Running OSRM with --location-dependent-data
command line argument will produce output:
wget http://download.geofabrik.de/europe/monaco-latest.osm.pbf
osrm-extract -p ../profiles/car.lua --location-dependent-data=countries.geojson monaco-latest.osm.pbf
...
Way 4097656 in Monaco [MCO]
Way 4098197 in Monaco [MCO]
Way 4212554 in France [FRA]
Way 4224972 in Monaco [MCO]
...
Way 4230116 in Monaco [MCO]
Way 4230117 in Monaco [MCO]
Way 4230118 in Monaco [MCO]
Way 4230119 in Monaco [MCO]
Way 4230122 in Monaco [MCO]
Way 4230126 in France [FRA]
Way 4230182 in France [FRA]
Way 4230185 in Monaco [MCO]
Way 4230186 in Monaco [MCO]
Way 4230187 in Monaco [MCO]
Way 4230891 in Monaco [MCO]
Way 4534918 in France [FRA]
Way 4978262 in France [FRA]
...
To speed up data extraction with location-dependent tags, one can pre-process OSM files by adding locations to ways with osmium
and avoid using the internal locations cache:
osmium add-locations-to-ways --keep-untagged-nodes monaco-latest.osm.pbf -o monaco-latest-loc.osm.pbf
osrm-extract -p ../profiles/car.lua --location-dependent-data=countries.geojson \
--use-locations-cache=no monaco-latest-loc.osm.pbf
The pre-processing step adds node locations directly into OSM ways, so the internal cache is not need. This reduces memory consumption by osrm-extract
, but increases OSM PBF file size.
--use-locations-cache=no
is used with an OSM file that was not pre-processed then an exception will be thrown
osrm-extract -p ../profiles/car.lua --location-dependent-data=countries.geojson \
--use-locations-cache=no monaco-latest.osm.pbf
...
terminate called after throwing an instance of 'sol::error'
what(): lua: error: invalid location
I think this page is obsolete. I add few commet since I tried to compile OSMR recently using Codeblocks 20.03 on Windows 10. What I found was that
Several extra libraries ave to be installed like BZip2, lua. I was using MSYS2 so I did, pacman -S mingw-w64-x86_64-bzip2 pacman -S mingw-w64-x86_64-lua pacman -S mingw-w64-x86_64-zlib
instal Intell tbb https://github.com/oneapi-src/oneTBB/releases Extract it to a folder (e.g., C:\tbb).
Ensure to add TBB Path to CMake Command and that the bin folder of MinGW or MSYS2 (e.g., C:\msys64\mingw64\bin) is added to your system PATH environment variable.
Then in osrm-backend\build run
cmake -G "CodeBlocks - MinGW Makefiles" .. -DCMAKE_BUILD_TYPE=Release -DTBB_INCLUDE_DIR="C:/tbb/include" -DTBB_LIBRARY="C:/tbb/lib/intel64/gcc4.8/libtbb.so"
cmake -G "CodeBlocks - MinGW Makefiles" .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-fno-lto -mconsole" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-e,mainCRTStartup"
It may be enough to compile.
However for some compilation problems I add to do
- remove "-Werror # Treat all warnings like error" in a CMakeLists.txt file
- add in shared_memory.hcp in line 208: (void)lock_file; // This explicitly marks lock_file as used to avoid warning of unused variable
- to avoid an Link Time Optimization (LTO) error run cmake -G "CodeBlocks - MinGW Makefiles" .. -DCMAKE_BUILD_TYPE=Release -DIPO=OFF
- put OFF in option(ENABLE_LTO "Use Link Time Optimisation" OFF) and I add set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) in Cmake
I finally gave up because of Windows console incompatibility (Winmain not found) without knowing the reason even after having, In codebleocks Project properties, Built target, type put Console application