-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new OGR driver for OpenDRIVE (XODR) #9504
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work generally. See my comments.
I would also like this to be triggered more by our CI.
Can you add a libopendrive build in .github/workflows/ubuntu_20.04/Dockerfile.ci and .github/workflows/ubuntu_22.04/Dockerfile.ci
Do you know how your driver (and libopendrive) is robust to corrupted / hostile datasets? At the very minimum, I'd like to see a test with a "random file" that has xodr extension, but isn't valid XODR file. Ideally we'd want to stress-test it using OSSFuzz. Cf https://github.com/OSGeo/gdal/blob/master/fuzzers/README.TXT , https://github.com/OSGeo/gdal/blob/master/fuzzers/build.sh
Is the some packaging of libopendrive in Debian, conda-forge, etc ? |
@michikommader Do you plan any further work on this any time soon ? I'm asking as I'm trying to keep the list of opened PRs low, and if something is not going to progress for some time, it is better to close the PR, and re-open it later when work restart |
Apologies for my inactivity. Yes, we already went through some of your valuable remarks internally but did not review and push changes yet. I plan to supply all the missing information in the first week of May. |
Not yet. I myself am not maintainer of libOpenDRIVE and would rather see packaging responsibility on the maintainer side. We can separately discuss if our institute could take over this task. Also, ASAM e. V. as standardisation organisation behind OpenDRIVE could have an interest in that. |
libOpenDRIVE forwards XML data loading directly to pugixml. According to pugixml's exception guarantees "most pugixml functions have a no-throw exception guarantee". For handling parsing errors the At least, libOpenDRIVE gives access to the parsed |
I'll focus on satisfying cppcheck_2004 next days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rouault In the current master branch you use ARROW_VERSION=16.0.0-1
but when testing, I have to set it to 16.1.0-1
in order to successfully build the Ubuntu 24.04 Docker image.
yes, you've well done. The version has to be bumped regularly |
@michikommader Do you mind rebasing on top of latest master? I've cherry-picked the change for ARROW_VERSION. And you'll have to do a few changes in your CMakeLists.txt file as well as the ogrxdrdrivercore.h due to the changes of #10068 that has just been merged. See 1cd120f as an example of the changes you'll have to do: adding NO_SHARED_SYMBOL_WITH_CORE, using |
9ffd4e8
to
710a023
Compare
710a023
to
43a1826
Compare
{ | ||
lineString.addPoint(laneVertex[0], laneVertex[1], laneVertex[2]); | ||
} | ||
OGRGeometry *geometry = lineString.MakeValid(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MakeValid() might return nullptr in case of failure, so this should be tested to avoid a nullptr dereference. Furthermore MakeValid() is only available or GEOS-enabled builds. So the choice is either to make GEOS a build requirement for the driver in ogr/ogrsf_frmts/CMakeLists.txt with ogr_dependent_driver(xodr OpenDRIVE "GDAL_USE_OPENDRIVE;GDAL_USE_GEOS")
, or to only call MakeValid() if OGRGeometryFactory::haveGEOS()
and use the original geometry then.
Is it common/expected that XODR datasets return non-valid geometries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be rather uncommon that XODR datasets return non-valid geometries. But as we rely on libOpenDRIVE's internal linear approximation of parametric geometries, we should at least validate our derived Simple Feature version. I will make this more robust with your suggestions in mind. I see it reasonable to make GEOS dependency optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or to only call MakeValid() if
OGRGeometryFactory::haveGEOS()
Does there exist any similarly convenient function to test if SFCGAL is available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will make this more robust with your suggestions in mind
I omit using MakeValid()
now because handling of a potentially modified return geometry is not trivial. Instead, just a testing for IsValid()
is performed. If that fails, the feature's geometry will stay unset and a warning is issued. I am not sure if allowing geometry-less features in such boundary cases is a reasonable approach? Theoretically, such cases should not occur.
Further, GEOS is a required dependency now because we need it for UnaryUnion()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does there exist any similarly convenient function to test if SFCGAL is available?
I don't think so. But you could had a bool OGRGeometryFactory::haveSFCGAL() if needed next to haveGEOS() in ogr/ogrgeometryfactory.cpp)
Instead, just a testing for
IsValid()
is performed. If that fails, the feature's geometry will stay unset and a warning is issued
That seems a bit extreme. A lot (most) drivers will report invalid geometries, and let the responsibility to the user to fix them with MakeValid() (ogr2ogr has a -makevalid option for example), or discard them, or just process them as it. So if I were you, I would just report the geometry as obtained from libopendrive, ignoring if it is valid or not
43a1826
to
cb3283f
Compare
@michikommader Anything left on your side before merging this PR ? It looks good to me (the CI failures are unrelated) |
I will today commit a small simplification regarding your last suggestions with |
- Refactor file opening - Ensure m_ prefix for member variables - Simplify for loops - Use default member initializers - Simplify and optimise manual memory management using std::unique_ptr - Pass by const and reference where possible - Use SetGeometryDirectly on features to avoid memory leaks - Implement deferred driver loading capability as plugin, as per RFC 96 - Implement OGRGetNextFeatureThroughRaw - Move XODR driver config to official Dockerfiles - Add "test_ogrsf" compliance checking to Python tests - Improve documentation
- Pass std::string by const reference - Switch to postfix operators for non-primitive types - Avoid virtual function calling from subclass constructors
Mark GEOS as mandatory dependency
cb3283f
to
4280011
Compare
From my side, there is nothing more to add. The driver is well usable in practical applications. As next steps, I will look into providing ready-to-use binary releases of the libOpenDRIVE dependency. If development of libOpenDRIVE progresses with new features, this XODR driver might require adjustments. I would prepare theses as pull requests in a similar manner here. Thank you for your patience and guidance for making this driver part of GDAL! |
I've refreshed the master Docker images, so "ghcr.io/osgeo/gdal:ubuntu-full-latest" and "ghcr.io/osgeo/gdal:alpine-normal-latest" contain the driver |
Should a
https://github.com/OSGeo/gdal/actions/runs/9569105782/job/26380878179#step:13:361 |
we want to avoid creating new Find cmake files when possible. Here it is not necessary as opendrive comes with CMake config files. Hence #10391 should fix it |
What does this PR do?
This adds a read-only vector driver for the road description format ASAM OpenDRIVE®. OpenDRIVE is an open industry standard in the automotive domain of driving simulation, maintained by ASAM e.V. It is increasingly intersecting with the public and GIS domains which raises the need for better interoperability with open-source spatial tools.
I am am open to a fruitful discussion in order to make OpenDRIVE directly usable through GDAL. The context for this development has been introduced on FOSSGIS conference 2024, Geospatial World Forum 2024 and on FOSS4G Europe 2024.
What are related issues/pull requests?
Tasklist
Updated Python API documentation (swig/include/python/docs/)I see no necessity there for adding a new driverdocker/ubuntu-small/DockerfileXODR
with GDAL maintainers: Which file location is better suited for future maintenance – the driver's source code directory or a separate repository?Environment
Provide environment details, if relevant: