<div dir="ltr">Would be cooler if it just took in a ROW. :)<br>P</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 16, 2016 at 4:27 AM, Björn Harrtell <span dir="ltr"><<a href="mailto:bjorn.harrtell@gmail.com" target="_blank">bjorn.harrtell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">As a continuation of my work with ST_AsGeobuf (1) I've started work on St_AsMVT (2), which is a function intended to output a Mapbox Vector Tile (3).<div><br><div>A feature of Mapbox Vector Tiles are that they can contain several layers of data within a tile, typically corresponding to a separate source schema. So I'm thinking about how to specify the parameters to ST_AsMVT to support fetching the data for a tile and this is my initial proposal:</div><div><br></div><div>CREATE FUNCTION ST_AsMVT(query text, extent <span style="color:rgb(46,46,46);font-family:"lucida grande",verdana,geneva,arial,helvetica,sans-serif;font-size:13.3333px">box2d, resolution double, buffer integer, pixelratio integer</span>)</div><div><br></div><div>The query parameter is expected to produce rows with a specific schema like follows:</div><div><br></div><div>CREATE TABLE output</div><div>(</div><div>  layer text,</div><div>  id bigint,</div><div>  geom geometry,</div><div>  attributes json</div><div>)</div><div><br></div><div>The above schema would allow unioning data from multiple tables with differing attributes (represented using the json datatype, alternatively it could be a hstore?). Note that it's up the the query to include geometries to be considered (usually extent + buffer * resolution).</div><div><br></div><div>The extent parameter defines the geographic extent to be visible within the tile (i.e does not include buffer).</div><div><br></div><div>The resolution parameter defines units per pixel used to translate geometric coordinates into tile coordinates.</div><div><br></div><div>The buffer parameter defines how many pixels should be included outside visible tile coordinates until clipping the geometry. This is used to avoid border rendering artifacts.</div><div><br></div><div>The pixelratio parameter optionally multiplies tile coordinate space to support hdpi displays. Default should probably be 1.</div><div><br></div><div>1) <a href="https://git.osgeo.org/gogs/postgis/postgis/pulls/4" target="_blank">https://git.osgeo.org/gogs/<wbr>postgis/postgis/pulls/4</a></div><div>2) <a href="https://git.osgeo.org/gogs/postgis/postgis/pulls/5" target="_blank">https://git.osgeo.org/gogs/<wbr>postgis/postgis/pulls/5</a></div><div>3) <a href="https://www.mapbox.com/vector-tiles/specification" target="_blank">https://www.mapbox.com/vector-<wbr>tiles/specification</a></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>/Björn</div></font></span></div></div>
<br>______________________________<wbr>_________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/postgis-devel</a><br></blockquote></div><br></div>