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

Vector tiles for dynamic data #1946

Closed
averas opened this issue Jan 19, 2016 · 1 comment
Closed

Vector tiles for dynamic data #1946

averas opened this issue Jan 19, 2016 · 1 comment

Comments

@averas
Copy link
Contributor

averas commented Jan 19, 2016

The work Mapbox has done on vector tiles is just amazing, and it will for sure change how web based maps are done for years to come.

That being said, while vector tiles is a given for static to fairly static (when considering individual tiles) data sets (such as OSM) I wonder how flexible one can make use of vector tiles for more dynamic data sets, where data changes fairly often, but still far from in real-time.

I have several mapping application where I perform the classic map.on("moveend", fetchData(map.bbox())) to fetch GeoJSON based on user interaction. The downside is I often fetch a lot of the same data (this could of course be adressed with various techniques), and it's really hard to implement caching; every query is unique. Today I mainly solve this with geospatial indexes (PostGIS and Elasticsearch).

I was thinking about the possibility of using vector tiles for more dynamic data sets, where caching becomes more of an issue of invalidating vector tiles server side. The problem I see, and what I would hope for an answer for with this issue, is how flexible things are on the receiving end (i.e. mapbox.gl.js) when tiles tend to change a lot. I've noticed that I can set cacheSize to 0 on a vector tile source, but I am afraid the web browser won't fetch new tiles for every request anyway (could perhaps be mitigated with a set of HTTP headers).

Would you deem it insane to use vector tiles like this? For .. say .. a point layer with a point here and there being created every hour or so...

Could perhaps cacheSize be complemented with a cacheTimeout? ...

Can the tile cache be invalidated via the API btw? Or must I remove and add the source to accomplish that?

@lucaswoj
Copy link
Contributor

Thank you for taking the time to write this all out @averas! It sounds like you are asking a few separate questions in this issue:

Is there an efficient way to reuse GeoJSON?

This is a very implementation-specific question. My general advice would be to download the data as GeoJSON once do as much processing as possible clientside. mapbox-gl-js can handle huge GeoJSON files, turning them into efficient vector tiles internally. You might find Turf.js useful.

Is it reasonable to build a vector tile set every hour?

If you can build the tile set fast enough, sure! Using GeoJSON as described above is going to be a simpler solution, so try that first.

Should we support a cache timeout in mapbox-gl-js?

Yes. We respect HTTP cache headers in mapbox-gl-native (mapbox/mapbox-gl-native#2617). This feature should be ported to mapbox-gl-js.

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

2 participants