datasette-geojson-map icon indicating copy to clipboard operation
datasette-geojson-map copied to clipboard

Search based on map bounds

Open eyeseast opened this issue 2 years ago • 5 comments

Right now, I run a query and the map fits the bounds of the returned features. But, if I have a bounding box, I could go the other way and search features within that box. This is especially fast if I have a spatial index.

eyeseast avatar Mar 15 '22 02:03 eyeseast

Depending on the size of the dataset, this might run into the max rows setting.

eyeseast avatar Mar 15 '22 13:03 eyeseast

Here's the hook to use: https://docs.datasette.io/en/stable/plugin_hooks.html#filters-from-request-request-database-table-datasette

eyeseast avatar Mar 28 '22 23:03 eyeseast

This probably has to be SpatiaLite only, and might be worth requiring a spatial index.

eyeseast avatar Mar 28 '22 23:03 eyeseast

What's the best way to do a bbox query? Some comparisons:

This has to work with any geometry type, so I can't assume anything about the geometry itself.

eyeseast avatar Apr 26 '22 01:04 eyeseast

Here's how datasette-leaflet-freedraw does it: https://github.com/simonw/datasette-leaflet-freedraw/blob/main/datasette_leaflet_freedraw/init.py#L26-L62

eyeseast avatar Apr 26 '22 18:04 eyeseast