Closed bradh closed 6 years ago
You are correct. The demo page zooms to the extent that is declared in the feature table. It is shown on a web Mercator map and that is why it appears to zoom to the entire world plus some because web Mercator only extends to ~85 and ~-85 degrees latitude.
Hi @bradh ,
The Contents (gpkg_contents) table is the only place a feature table identifies the overall bounds of the data. Evaluating each feature row for it's envelope or bounds does not make sense for a zoom operation. There could be thousands of geometries in each feature table saved with or without individual envelopes specified.
Although the bounds in the Contents are optional, we recommend specifying the minimum data encompassing bounds. For your example, the entire world is specified as the feature table data bounds. If you update the gpkg_contents min_x, min_y, max_x, max_y values, zoom should work correctly for you.
I'm fairly familiar with GeoPackage, it was more just user surprise.
I realise that its just a demo app, but keeping a bounding box during rendering wouldn't be that onerous.
I would argue that the bounding box specified by the contents table is the one that should be used because what if the application does not actually load all of the data into the map and only queries for what is visible. Then there would be no way of knowing how many other features there are that fall outside of the current viewport. Additionally, some applications will query for a count of features in the current viewport and not display them if there are too many. This would also cause the application to not actually know the actual bounding box of the data. Since a contents table is required for all feature tables, and that table has a bounding box, I feel that the only reliable way of zooming, regardless of the implementation of how the features are loaded, is to use the bounding box provided. Otherwise why even bother having that in the contents table if everyone is going to just set it to the world extents?
I have a layer with four points, all in Europe. Selecting "zoom to" extends to whole world (plus some).
Probably using the declared layer extent rather than actual extent, but the effect is surprising.