<div dir="ltr"><div>Hi Nicklas,</div><div><br></div><div>The specification explains extent like this:</div><div><br></div><div>"A layer MUST contain an extent that describes the width and height of the tile in integer coordinates. The geometries within the Vector Tile MAY extend past the bounds of the tile's area as defined by the extent. Geometries that extend past the tile's area as defined by extent are often used as a buffer for rendering features that overlap multiple adjacent tiles."<br></div><div><br></div><div>Note that "integer coordinates" are local coordinates to the tile itself. A nice graphical explanation can be seen here:</div><div><a href="https://www.mapbox.com/vector-tiles/specification/#encoding-geom">https://www.mapbox.com/vector-tiles/specification/#encoding-geom</a><br></div><div><br></div><div>The buffer parameter is also in local tile units and is only relevant if clip_geom is true, in which case ST_AsMVT will clip input geometries at the tile border + eventual buffer. Clipping obviously saves space and an appropriate buffer will ensure the tile contains enough information to avoid border rendering artifacts. For label points a reasonably large buffer might be needed.</div><div><br></div><div>Note that the bounds parameter is assumed to be in geographic coordinates and it's the callers responsibility to map these bounds to a tile in a grid. I opted to do it this way to not assume a specific tile grid even if vector tiles is rarely seen with anything else than mercator and the google tile grid scheme.</div><div><br></div><div>I plan to expand the documentation to hopefully explain these things better there and provide a better example than one from the regression tests.</div><div><br></div><div>/Björn</div><div><br></div><div>PS. Mail quote below might look funny because for some reason I did not receive it, it's copy pasted from the list archive.</div><div><br></div><div><div>> Nicklas Avén nicklas.aven at <a href="http://jordogskog.no">jordogskog.no</a> </div><div>> Mon Oct 17 23:26:38 PDT 2016</div></div><div>><br></div><div>> Hi Björn </div><div>> <br></div><div>> I have succeeded in installing and can run the example query. </div><div>> <br></div><div>> But I do not understand the parameters at once. Could you give some </div><div>guidance? </div><div>> <br></div><div>> What is extent and buffer? </div><div>> <br></div><div>Sorry if I miss the obvious. </div><div>> <br></div><div>> Thanks </div><div>> <br></div><div>> Nicklas</div><div class="gmail_extra"><br><div class="gmail_quote">2016-10-10 11:42 GMT+02:00 Björn Harrtell <span dir="ltr"><<a href="mailto:bjorn.harrtell@gmail.com" target="_blank">bjorn.harrtell@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi list,<div><br></div><div>I'm back from the deep with an initial complete implementation of ST_AsMVT aggregate function (1).<div><br></div><div>The signature is as follows:</div><div><br></div><div>CREATE AGGREGATE ST_AsMVT(name text, bounds box2d, extent int4, buffer int4, clip_geom bool, geom_name text, anyelement)<br></div><div><br></div><div>Typical usage is with a subquery to create a single layer. Here is an example from the regression tests:</div><div><br></div><div><div>SELECT ST_AsMVT('test', ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false, 'geom', q)</div><div>FROM (SELECT 1 AS c1, 'abcd'::text AS c2, ST_GeomFromText('POINT(25 17)') AS geom) AS q;</div></div><div><br></div><div>I have been able to use it on real data to produce a set of more than 400 000 tiles with multiple layers and attributes without known issues. Tiles with multiple layers can be created by simply concatenating output from ST_AsMVT.</div><div><br></div><div>Feedback on the implementation, usage and/or test results will be much appreciated.</div><div><br></div><div>1) <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><span class="gmail-HOEnZb"><font color="#888888"><div><br></div></font></span><div><div><span class="gmail-HOEnZb"><font color="#888888">/Björn</font></span><div><div class="gmail-h5"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-09-19 0:22 GMT+02:00 Björn Harrtell <span dir="ltr"><<a href="mailto:bjorn.harrtell@gmail.com" target="_blank">bjorn.harrtell@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="gmail-m_-427948068668630374gmail-">2016-09-18 17:28 GMT+02:00 Paul Ramsey <span dir="ltr"><<a href="mailto:pramsey@cleverelephant.ca" target="_blank">pramsey@cleverelephant.ca</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">I think that “pass in a SQL” string, or “table name” are the roads to hackyland. You’re building a database: take in and emit primitive values/objects or tuples or tuplesets. You build primitives and let other folks build the SQL stuff on top.</div></blockquote><div><br></div></span><div>Agreed.</div><div><br></div><div>I got my hands dirty concatenating encoded protocol buffer messages and fields. Finally I think the wire format have sinked in with me.</div><div><br></div><div>I see now that it should be possible to not only binary concatenate layers into a tile but also features into a layer message. I have a feeling I'm late to the party in understanding this, but I guess better late than never.</div><div><br></div><div>I'll be back if I survive the trip deeper into PostgreSQL.</div><span class="gmail-m_-427948068668630374gmail-HOEnZb"><font color="#888888"><div><br></div><div>/Björn</div></font></span><div><div class="gmail-m_-427948068668630374gmail-h5"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span><font color="#888888"><div><br></div></font></span><div><span><font color="#888888">P.</font></span><div><div><br><div><br><div><blockquote type="cite"><div>On Sep 18, 2016, at 8:24 AM, Björn Harrtell <<a href="mailto:bjorn.harrtell@gmail.com" target="_blank">bjorn.harrtell@gmail.com</a>> wrote:</div><br><div><div dir="ltr" style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote">2016-09-18 7:48 GMT+02:00 Sandro Santilli<span> </span><span dir="ltr"><<a href="mailto:strk@kbt.io" target="_blank">strk@kbt.io</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On Sat, Sep 17, 2016 at 05:47:39PM -0700, Paul Norman wrote:<br>> On 9/17/2016 8:09 AM, Sandro Santilli wrote:<br><br></span><span>> >Using a row-by-row approach, makes it impossible to build such<br>> >dictionary, which is why my early attemps were just at producing<br>> >the geometric part, very much like the GML output works, delegating<br>> >composition of the whole final product to the caller (which could<br>> >eventually also be a ROW-taking wrapper).<br>><br>> You're right. Joining different layers is fine, but each layer has<br>> some common information that is needed.<br>><br>> Should it be an aggregate function then?<br><br></span>Probably, which means you'd also need to define a type<br>to represent the state (including the dictionary, for example).<br>It's enough stuff that might be better to move into its own<br>extension.<br></blockquote><div><br></div><div>What do you think about the alternative of simply supplying the function with a name of a table or view assuming the the proposed structure then dynamically query it internally using the supplied bounds?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>--strk;<br><div><div>______________________________<wbr>_________________<br>postgis-devel mailing list<br><a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">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/mailman<wbr>/listinfo/postgis-devel</a></div></div></blockquote></div><br></div></div><span style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">______________________________<wbr>_________________</span><br style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">postgis-devel mailing list</span><br style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:postgis-devel@lists.osgeo.org" style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">postgis-devel@lists.osgeo.org</a><br style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://lists.osgeo.org/mailman/listinfo/postgis-devel" style="font-family:helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">http://lists.osgeo.org/mailman<wbr>/listinfo/postgis-devel</a></div></blockquote></div><br></div></div></div></div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div></div></div></div></div></div>
</blockquote></div><br></div></div>