<div dir="ltr">Feedback on the initial ST_AsMVT implementation encouraged me to rework it into two functions, ST_AsMVTGeom and ST_AsMVT, which I have recently commited to svn-trunk.<div><br></div><div>The main issue with the original function was that it could produce invalid tiles as per specification and you could only find out by inspecting the produced end result, as the invalidity might occur in the process of transforming geometry to tile coordinate space.</div><div><br></div><div>By separating the geometry transformation into tile coordinate space with additional logic to make sure it's valid, it should not be as easy to accidentally or unintentionally create invalid tiles.</div><div><br></div><div>The API of the original ST_AsMVT has changed and is now expected to be used in concert with ST_AsMVTGeom which should be reflected in the updated documentation at <a href="http://postgis.net/docs/manual-dev/reference.html#Geometry_Outputs">http://postgis.net/docs/manual-dev/reference.html#Geometry_Outputs</a>.</div><div><br></div><div>See <a href="https://trac.osgeo.org/postgis/ticket/3712">https://trac.osgeo.org/postgis/ticket/3712</a> for background and discussions leading up these changes.</div><div><br></div><div>/Björn<br><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_2960987128746567472gmail-">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_2960987128746567472gmail-HOEnZb"><font color="#888888"><div><br></div><div>/Björn</div></font></span><div><div class="gmail-m_2960987128746567472gmail-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></div>