<div dir="ltr"><div>Extents and spatial filter settings with Geopackage are unprecise such that they are unusable.</div><div><br></div><div>For example I created a Geopackage with a single point: 176418.99585285, 317579.62751027</div><div>ogrinfo reports extents of</div><div>Extent: (176419.000000, 317580.000000) - (176419.000000, 317580.000000)</div><div>I think this can happen if the coordinates are converted to float or converted to a string with something like %.6g or %.g.</div><div>Thus the point in the Geopackage is outside the extents of the Geopackage.</div><div>If I adjust the extents of the Geopackage to</div><div>minx: 176418.823581<br>maxx: 176419.176419<br>miny: 317579.682420<br>maxy: 317580.317580</div><div>and use this as a spatial filter, the point is still excluded. A possible explanation is that the adjusted extents in the spatial filter are similarly converted, resulting in</div><div>minx: 176419.000000<br>maxx: 176419.000000<br>miny: 317580.000000<br>maxy: 317580.000000</div><div>which excludes the point in the Geopackage.</div><div><br></div><div>Not the reason for this, but another precision issue is at</div><div><a href="https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp#L3544">https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrsf_frmts/gpkg/ogrgeopackagetablelayer.cpp#L3544</a></div><div><br></div><div>                SQLEscapeName(pszC).c_str(), sEnvelope.MinX - 1e-11,<br></div><div><br></div><div>with sEnvelope.MinX = 176418.823581 or similar, subtracting 1e-11 will not make a difference, it should rather be</div><div>                SQLEscapeName(pszC).c_str(), sEnvelope.MinX - fabs(sEnvelope.MinX * 1e-11),</div><div>same for following lines. If this is again converted to float or converted to a string with something like %.6g or %.g, this will not work and you need something like</div><div><div>                SQLEscapeName(pszC).c_str(), sEnvelope.MinX - fabs(sEnvelope.MinX * 2e-6),</div><div>to account for single precision floating point limits.</div><div><br></div><div>I would like to provide a fix, but I did not find out where this conversion takes place.<br></div><div><br></div><div>Markus M<br></div></div></div>