This repository focusses on the development of an OpenDRIVE driver for the OGR Simple Features Library. By extending GDAL/OGR with the ability to read OpenDRIVE XML files, a broad and well-established toolset of GIS functions will be made available for OpenDRIVE processing. This OGR extension is based on the work by Orozco Idrobo (2015) and Scholz et al. (2017). Currently, the still prototypical OpenDRIVE driver is not yet integrated into the official GDAL distribution. Steps to built the driver as a shared library against GDAL to provide a pluggable extension are described below.
As of OpenDRIVE version 1.4 the specified coordinate reference system, given as PROJ.4 string, is correctly interpreted. For now one MultiLineString
layer is created containing just the road reference line geometries.
Geometry:
- Specify point sampling distance for mathematical geometries as layer creation option
- Create 3D geometries from polynomial OpenDRIVE elevation profile
- Add
Point
layer for road objects (e.g. signals, signs) - Add
Polygon
layer for driving lanes, parking spaces - Add additional
LineString
layer(s) to contain- driving lane boundaries
- road marks
- linear objects (e.g. guardrails, barriers)
- Implement sampling of
spiral
geometries, with bothcurvStart
andcurvEnd
!= 0
Misc:
- Catch invalid XODR file path ("terminate called after throwing an instance of 'xsd::cxx::tree::parsing'")
- Insure proper resource deallocation
The driver works only for GDAL 2.x. and does not support GDAL 1.x. It depends on the following libraries
- odrSpiral
- xodr
- CodeSynthesis XSD
- Xerces-C++
- GEOS; on Windows we recommend using the version distributed with OSGeo4W
and building it is divided into
- building the original GDAL base library which we link our shared extension against, followed by
- building the actual OpenDRIVE driver as shared library extension of GDAL/OGR.
We tested on Ubuntu Linux 16.04 x64 and Windows 7 x64. Get started by cloning the ogr/xodr branch of GDAL:
git clone https://github.com/DLR-TS/gdal.git -b ogr/xodr --single-branch <gdal>
If needed, substitute <gdal>
with the desired path name to clone into.
We basically follow the official GDAL building instructions for Unix.
Configure GDAL to support creation of shared libraries. At least for our Ubuntu 16.04 test environment we also had to disable libtool because it caused problems during later linking of the driver shared library:
cd <gdal>/gdal/
./configure --prefix ~/dev/gdal/gdal/build -enable-shared --without-libtool --with-geos=yes
Check the output for successful recognition of geos and xerces. For Debug configuration append --enable-debug
. Build with
make -f GNUmakefile
followed by a
make -f GNUmakefile install
which copies the resulting GDAL binaries and library into the abovely specified CMake --prefix
directory.
Navigate into the OpenDRIVE OGR driver directory
cd <gdal>/gdal/ogr/ogrsf_frmts/xodr/
Configure the paths for all required Unix dependencies in XODRmake.opt
. Then
make -f GNUmakefile plugin-install
This will build a shared library of the plugin and automatically copy it into GDAL's plugin directory relative to the CMake --prefix
directory specified in the previous section.
We basically follow the official GDAL building instructions for Windows. Things have gotten easier starting from GDAL 2.3.x. where GDAL provides a comfortable script generate_vcxproj.bat
to generate project definitions for recent Microsoft's Visual Studio editions. An exemplary project for Visual Studio 2015 x64 can be generated from the "VS2015 x64 Native Tools Command Prompt" as follows:
generate_vcxproj.bat 14.0 64 gdal_vs2015
Now configure your GEOS and Xerces dependencies by adding the corresponding include directory and library paths into a new lokal NMake configuration file nmake.local
. It should contain something like the following (consider nmake.opt
as a reference):
# GEOS
GEOS_DIR = D:\dev\geos\distro
GEOS_CFLAGS = -I$(GEOS_DIR)\include -DHAVE_GEOS
GEOS_LIB = $(GEOS_DIR)\lib\geos_c.lib
# Xerces
XERCES_DIR = D:\dev\xerces-c-3.1.1-x86_64-windows-vc-10.0
XERCES_INCLUDE = -I$(XERCES_DIR)\include -I$(XERCES_DIR)\include\xercesc
!IFNDEF DEBUG
XERCES_LIB = $(XERCES_DIR)\lib\xerces-c_3.lib
XERCES_DLL = $(XERCES_DIR)\bin\xerces-c_3_1.dll
!ELSE
XERCES_LIB = $(XERCES_DIR)\lib\xerces-c_3D.lib
XERCES_DLL = $(XERCES_DIR)\bin\xerces-c_3_1D.dll
!ENDIF
Open the generated .vcxproj
in Visual Studio and build the base GDAL library for the desired configuration (e.g. Release or Debug). Alternatively, for an exemplary Release build use nmake
from command line:
cd <gdal>/gdal/
nmake -f makefile.vc MSVC_VER=1900 WIN64=1
Lean back, enjoy a freshly brewed Lapsang Souchong and after a few minutes your raw GDAL library is built. To pack all executables and the library conveniently together specify the desired output directory GDAL_HOME
by adding the following in your lokal configuration file nmake.local
GDAL_HOME="C:\dev\gdal\gdal\build"
and run nmake install
afterwards
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 install
Navigate into the OpenDRIVE OGR driver directory
cd <gdal>/gdal/ogr/ogrsf_frmts/xodr/
Configure the paths for all required Windows dependencies in the provided XODRnmake.opt
. Then
nmake -f makefile.vc MSVC_VER=1900 WIN64=1 plugin-install
This also copies the required Xerces DLL into GDAL's binary install directory!
If everything went right the built GDAL/OGR is extended by our OpenDRIVE driver and can be tested by running one of the utility programs. Running ogrinfo
for the above examples would look like
Linux | Windows |
---|---|
cd <gdal>/gdal/build/lib/ |
cd <gdal>/gdal/build/bin/ |
../bin/ogrinfo --formats |
ogrinfo.exe --formats |
This should yield the an OGR driver list extended by the new OpenDRIVE driver. To convert an OpenDRIVE XML file into, e.g., an ESRI Shapefile, use the provided utility ogr2ogr
:
ogr2ogr -f "ESRI Shapefile" CulDeSac.shp CulDeSac.xodr
OpenDRIVE datasets for testing can be found in the official OpenDRIVE download section. For advanced debug console output of those utility programs and the implemented drivers add CPL_DEBUG=ON
to your running environment.
To easily add new drivers to GDAL as shared libraries GDAL provides the GDALDriverManager with its AutoLoadDrivers()
function. The FileGDB driver serves as good orientation for shared library development in GDAL/OGR, see RegisterOGRFileGDB()
in FGdbDriver.cpp
. Also consider the FileGDB Building Notes.