-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Spatialite and MySQL WKB dialects (#153)
This PR adds support for [Spatialite](https://www.gaia-gis.it/gaia-sins/BLOB-Geometry.html) and [MySQL](https://dev.mysql.com/doc/refman/8.0/en/gis-data-formats.html) WKB dialects. I'd happily discuss the implementation. Quirks of the spatialite dialect that required some refactoring: - A geometry blob ends with `0xFE`. In order to know wether the `polygon_end` (or alike) is the last one, we keep track of the collection entity nesting level. If the nesting level is 0 when a geometry ends, it means it is the last one of the blob and the terminating byte `0xFE` must be appended. Even though `MULTI*` geometries cannot be part of a `GEOMETRYCOLLECTION` in Spatialite at the moment, this was my easiest go at the problem - and it also makes it more future-proof in case that feature is added at some point. - In contrary to EWKB, the byte order and SRID info are not repeated in the nested entities headers, which means they have to be inherited from the parent entity info. In order to do that, I had to change the signature of the `read_header` parameter of `process_wkb_geom_n` so that the parent geometry info can be passed down to its children. - The "compressed" polygon and linestring geometries stores their X,Y,Z coordinates as `f32` values, relative to the previous one (with the exception of the first and the last one), which required some refactoring to `process_coord` to avoid code duplication between the two implementations. Side notes: - Shouldn't `WkbWriter` implement `GeomProcessor::srid()` ? - Only read support has been implemented for Compressed and TinyPoint geometries, write isn't implemented. - Spatialite header stores the envelope as `[minx, miny, maxx, maxy]` (like GeoJSON) whereas gpkg stores it as `[minx, maxx, miny, maxy]` I also refactored the roundtrip tests so they can be shared by the 5 dialects. --------- Co-authored-by: Aurèle Nitoref <[email protected]> Co-authored-by: Yuri Astrakhan <[email protected]>
- Loading branch information
1 parent
5e92027
commit a92ef80
Showing
7 changed files
with
662 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.