Skip to content
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

Allow map view on table page to be filtered #2

Open
russss opened this issue Apr 30, 2019 · 0 comments
Open

Allow map view on table page to be filtered #2

russss opened this issue Apr 30, 2019 · 0 comments

Comments

@russss
Copy link
Owner

russss commented Apr 30, 2019

The vector tile endpoint needs to accept the same filtering/faceting URL parameters as the main TableView. This is complex because the vector tile server needs to access the entire dataset, ignoring paging, and the SQL needs to have a geographic bounding-box clause added before execution.

This isn't possible with the current renderer hook from simonw/datasette#441, because these renderer hooks are called after the SQL is executed.

As far as I see it, there are two options here:

Option 1: Extend renderer hooks

We could extend the renderer hook system so it also gets some kind of callback before the SQL is executed. This callback could extend the SQL. Vector tiles could then be implemented as a renderer hook rather than a separate view as they are currently.

Pros:

  • Datasette-geo wouldn't need the prepare_sanic hook from Add inspect and prepare_sanic hooks simonw/datasette#437 any more, which completely removes the coupling with Sanic.
  • It could provide a way for other renderer plugins to bypass the paging limits, which could be useful for stuff like .xslx exports, where downloading an Excel file with a subset of the data isn't going to be useful. Some kind of caching would probably be needed here.

Cons:

  • Datasette-geo would have to shoehorn the tile server URLs into the existing datasette URL paths, rather than using a more conventional tileserver-style URL scheme. This is doable though, if slightly ugly.

Option 2: Access Datasette code outside the hook system

This is the option I was thinking of originally. If the TableView.data function was refactored so the SQL generation could be hooked into by a subclass, datasette-geo could do this independent of the hook system.

Pros:

  • Less complex hooks?

Cons:

  • More brittle coupling between plugins and datasette.
  • The prepare_sanic hook is still needed.

By writing this I think I've convinced myself that option 1 is better now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant