{"action":"opened","issue":{"url":"https://api.github.com/repos/go-spatial/tegola/issues/470","repository_url":"https://api.github.com/repos/go-spatial/tegola","labels_url":"https://api.github.com/repos/go-spatial/tegola/issues/470/labels{/name}","comments_url":"https://api.github.com/repos/go-spatial/tegola/issues/470/comments","events_url":"https://api.github.com/repos/go-spatial/tegola/issues/470/events","html_url":"https://github.com/go-spatial/tegola/issues/470","id":344649393,"node_id":"MDU6SXNzdWUzNDQ2NDkzOTM=","number":470,"title":"PostGIS: Use the !ZOOM! token before the where-clause of the query.","user":{"login":"brianbancroft","id":6225122,"node_id":"MDQ6VXNlcjYyMjUxMjI=","avatar_url":"https://avatars0.githubusercontent.com/u/6225122?v=4","gravatar_id":"","url":"https://api.github.com/users/brianbancroft","html_url":"https://github.com/brianbancroft","followers_url":"https://api.github.com/users/brianbancroft/followers","following_url":"https://api.github.com/users/brianbancroft/following{/other_user}","gists_url":"https://api.github.com/users/brianbancroft/gists{/gist_id}","starred_url":"https://api.github.com/users/brianbancroft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianbancroft/subscriptions","organizations_url":"https://api.github.com/users/brianbancroft/orgs","repos_url":"https://api.github.com/users/brianbancroft/repos","events_url":"https://api.github.com/users/brianbancroft/events{/privacy}","received_events_url":"https://api.github.com/users/brianbancroft/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-26T00:09:52Z","updated_at":"2018-07-26T00:09:52Z","closed_at":null,"author_association":"NONE","body":"Hi there, and thanks for putting this together. I hope the march towards 7 continues steadily. \r\n\r\n## Requested Behavior\r\nI seek to be able to use the `!ZOOM!` token before the WHERE-clause in a TOML-fed query for a given layer so that I can leverage the postGIS `ST_Simplify` function with the intended result of simplifying polygons at lower zoom levels. \r\n\r\n## Use Cases\r\n\r\nHere's where I'd employ it:\r\n\r\n```sql\r\n[[providers.layers]]\r\n  name = \"pop_age_15_to_19_2016_ct\"\r\n  geometry_fieldname = \"wkb_geometry\"\r\n  id_fieldname = \"id\"\r\n  # TODO: Same issue: Get the geometry dumbing down using the exponential function\r\n  sql = \"\"\"\r\n  SELECT\r\n    ST_AsBinary(ST_Simplify(geo.wkb_geometry, (!ZOOM! * \"mathy-like function\", true))\r\n      AS wkb_geometry,\r\n    geo.ogc_fid\r\n      AS id,\r\n    data.total\r\n      AS total\r\n  FROM canada_ct_2016\r\n    AS geo\r\n  INNER JOIN pop_age_15_to_19_2016_ct\r\n    AS data\r\n    ON geo.ctuid = data.geo_id\r\n  WHERE\r\n    geo.wkb_geometry && !BBOX!\r\n  GROUP BY\r\n    wkb_geometry,\r\n    id,\r\n    total\r\n  \"\"\"\r\n\r\n```\r\n\r\n## Current work arounds to accomplish current behaviour.\r\nAs a user, I have no workarounds at this time. For boundary polygons (Canadian Census Tracts) at zoom-level 9, the size of tiles being generate are upwards of 1MB. At zoom-level 14, they're at a manageable 20-40kb. \r\n\r\nThanks. If this functionality exists, I would gladly contribute to tegola-docs so that others in a similar position can carry out out. \r\n\r\n"}}
{"actor":{"display_login":"brianbancroft"}}