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 capability to quantize geometry coordinates for higher compression efficiency #6974
Conversation
8207c3d
to
645aafc
Compare
7183b49
to
deba99c
Compare
84eff93
to
4c309ca
Compare
6ef9774
to
79335a2
Compare
…es with settings to quantize coordinates The following C functions are added: ``` /** Opaque type for geometry precision options */ typedef struct OGRPrecisionOptions OGRPrecisionOptions; OGRPrecisionOptions CPL_DLL *OGRPrecisionOptionsCreate(void); void CPL_DLL OGRPrecisionOptionsDestroy(OGRPrecisionOptions *); void CPL_DLL OGRPrecisionOptionsSetPrecision(OGRPrecisionOptions *, double dfXYPrecision, double dfZPrecision, double dfMPrecision); void CPL_DLL OGRPrecisionOptionsSetMetricPrecision(OGRPrecisionOptions *, OGRSpatialReferenceH hSRS, double dfXYMetricPrecision, double dfZMetricPrecision, double dfMPrecision); /** Opaque type for WKB export options */ typedef struct OGRwkbExportOptions OGRwkbExportOptions; OGRwkbExportOptions CPL_DLL *OGRwkbExportOptionsCreate(void); void CPL_DLL OGRwkbExportOptionsDestroy(OGRwkbExportOptions *); OGRwkbByteOrder CPL_DLL OGRwkbExportOptionsGetByteOrder(const OGRwkbExportOptions *); void CPL_DLL OGRwkbExportOptionsSetByteOrder(OGRwkbExportOptions *, OGRwkbByteOrder); OGRwkbVariant CPL_DLL OGRwkbExportOptionsGetVariant(const OGRwkbExportOptions *); void CPL_DLL OGRwkbExportOptionsSetVariant(OGRwkbExportOptions *, OGRwkbVariant); void CPL_DLL OGRwkbExportOptionsSetPrecision(OGRwkbExportOptions *, const OGRPrecisionOptions *); OGRErr CPL_DLL OGR_G_ExportToWkbEx(OGRGeometryH, unsigned char *, const OGRwkbExportOptions *); ```
- **XY_QUANTIZED_PRECISION** =float or string. (GDAL >= 3.7) Desired precision for X/Y coordinate quantization. This parameter will influence the number of nullified least significant bits in the mantissa of the binary representation of coordinates as IEEE-754 double-precision floating-point numbers. This is only useful if the file is compressed. By default, the value is understood as expressed in the units of the CRS of the layer (for example, for a geographic Earth CRS, "8.9e-9" corresponds to a millimetric precision), unless the 'm' suffix is added to express the value in metre (will work for a geographic or projected CRS). For example, "0.001 m" for a millimetric precision. - **Z_QUANTIZED_PRECISION** =float or string. (GDAL >= 3.7) Desired precision for Z coordinate quantization. This parameter will influence the number of nullified least significant bits in the mantissa of the binary representation of coordinates as IEEE-754 double-precision floating-point numbers. This is only useful if the file is compressed. By default, the value is understood as expressed in the units of the CRS of the layer, unless the 'm' suffix is added to express the value in metre (will work for a geographic or projected CRS). For example, "0.001 m" for a millimetric precision. - **M_QUANTIZED_PRECISION** =float. (GDAL >= 3.7) Desired precision for M coordinate quantization. This parameter will influence the number of nullified least significant bits in the mantissa of the binary representation of coordinates as IEEE-754 double-precision floating-point numbers. This is only useful if the file is compressed.
79335a2
to
8ce2c10
Compare
8ce2c10
to
434b880
Compare
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.
LGTM but I admit I've got lost in the WKB bit manipulations.
* | ||
* @since GDAL 3.7 | ||
*/ | ||
template <int SPACING> |
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.
Why a template and not a simple argument?
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.
To generate better assembly code. ptr + variable * constant can be expressed into a single assembly mnemonic
Co-authored-by: Alessandro Pasotti <elpaso@itopen.it>
I'm putting this on hold because I'm wondering if that shouldn't be part of a larger "framework" to convey coordinate precision between drivers |
closing as superseded per #9378 |
and GPKG: add creation options to quantify coordinates
and ogr2ogr: add -xy_quantized_prec/-z_quantized_prec/-m_quantized_prec options
On a test dataset, setting XY_QUANTIZED_PRECISION=0.001m reduces the size of the .zip of the .gpkg file from 766 MB to 667 MB (13% size decrease).