1

I wanted to make tilestache to be able have a different query for different zoom level. For certain zoom level I wanted TileStache to query from different postgres table. How can I achieve this? Is this even possible in TileStache?

2

To use different queries for different zoom levels you will have to provide queries for each zoom level that you want to use, I think it should be able to query from a different table as well, since we are only defining the database in the kwargs.

I have it working using this layer in the cfg

"roads":
    {       
        "allowed origin":"*",
        "projection": "spherical mercator",
        "provider":
        {
            "class": "TileStache.Goodies.VecTiles:Provider",                        
            "kwargs":
            {
                "dbinfo":
                    {
                       "host":"localhost",
                       "user":"postgres",
                       "password":"postgres123",
                       "database":"test"                       
                    },
                "queries":
                {
                    "7":"SELECT geom AS __geometry__,name, priority FROM isl_roads WHERE priority IN (5,4) -- zoom 7+",
                    "8":"SELECT geom AS __geometry__,name, priority FROM isl_roads WHERE priority IN (5,4)",
                    "9":"SELECT geom AS __geometry__,name, priority FROM isl_roads WHERE priority IN (5,4)",
                    "10":"SELECT geom AS __geometry__,name, priority FROM isl_roads WHERE priority IN (5,4)",
                    "11":"SELECT geom AS __geometry__,name, priority FROM isl_roads WHERE priority IN (5,4,3,2)",
                    "12":"SELECT geom AS __geometry__,name, priority FROM isl_roads WHERE priority IN (5,4,3,2)",
                    "13":"SELECT geom AS __geometry__,name, priority FROM isl_roads WHERE priority IN (5,4,3,2)",
                    "14":"SELECT geom AS __geometry__,name, priority FROM isl_roads  -- zoom 14+"
                }

            }
        },
        "preview":{"ext":"json"}
    }

Leaving the zoom level 0-6 blank will make TileStache assume them as null and the last query will run on all the zoom levels that follow.

  • is it possible to do the same with data from different databases ? because I have tried and its not working – Zak Jul 9 '18 at 14:00
  • in the same layer or in different layers? – Hasan Mustafa Jul 12 '18 at 10:15
  • For the same layer. – Zak Jul 12 '18 at 11:14
  • You cant have data from different databases in the same layer – Hasan Mustafa Jul 18 '18 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.