Dynamic Tilestache Layers

237 views
Skip to first unread message

ckotil

unread,
Feb 13, 2014, 8:47:59 AM2/13/14
to tiles...@googlegroups.com
Is it possible to pass in arguments to Tilestache? In my current configuration I have a LOT of layers for serving vector data. Each layer only differs slightly in the SQL query where it selects a different layer_id. My config could be greatly simplified into a single layer by having the ability to pass in a !layer_id! argument in the URL request; /vector_data/x/y/z.json?layer_id=52 . I've seen the variable !bbox! which is an argument that can be passed in and parsed by Tilestache, so Im thinking passing in another argument may be possibe. But so far I have not been able to find any examples or found anyone else doing this.

There have been a couple of posts I've stumbled onto that sound close to what I want to do.




Both hint at using a alternate WSGI server, but Im not sure how to go about doing that.


Any ideas?

Thanks,
--Chad

ckotil

unread,
Feb 27, 2014, 9:46:28 AM2/27/14
to tiles...@googlegroups.com
After thinking about this more, perhaps being able to pass in dynamic arguments to modify the query isn't the best thing for tilestache. It effectively breaks the cache.
However I could argue that as long as the number variables were small that the cache could still be used.
For now Im testing a few different methods.
1. A couple thousand layers
2. Return all of the data at once in a handful of layers and use JS to display/hide the data as needed.


Olivier Ceyral

unread,
Mar 12, 2014, 9:48:09 AM3/12/14
to tiles...@googlegroups.com
So, I had this problems a few months back for a project.

I queried my layer with a basic /tiles/layer_id/x/y/z.json url, but I wanted to be able to add and remove layers on the fly, so I couldn't have a gigantic static config file.

The solution I found was to use TileStache.Goodies.ExternalConfigServer as a base, and then modify it to query the database instead of a remote configuration server. It's fairly easy to do and worked quite well. It also doesn't breaks the cache, the tiles will be cached as different layers anyway, so you'll have a directory for each layer e.g. /tiles/layer1/..., /tiles/layer2/..., etc... With thousands of layers though, you might want to look at filesystem restrictions regarding the number of files in a folder.

Alex King

unread,
Mar 10, 2017, 1:42:26 PM3/10/17
to Tilestache
Hi Oceyral,

I know it's been several years, but would you by chance have an example of how you changed your ExternalConfigServer file? I'm very interested in your solution.

Thanks!
Alex
Reply all
Reply to author
Forward
0 new messages