<div dir="ltr">Answers inlined below.<br><div class="gmail_extra"><br><div class="gmail_quote">2016-11-28 22:38 GMT+01:00 Nikolai Bezdna <span dir="ltr"><<a href="mailto:mofoyoda@gmail.com" target="_blank">mofoyoda@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"><div>Bjorn, thanks for a quick fix!</div><div>Now it doesn't throw this error.</div><div><span style="font-size:12.8px">Can you please clarify some questions:</span><br></div><div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">1. How do I concatenate st_asmvt output from different tables? I’ve never concatenated binary data in postgres (only strings) and if that really works, looks like some kind of magic :)</div><div style="font-size:12.8px">My goal is to have multiple layers in a tile, like Mapnik MVT output. I guess this is the most common case.</div></div></div></div></div></blockquote><div><br></div><div>There is nothing magic about binary concatenation, it's demonstrated in the first example on this page:</div><div><a href="https://www.postgresql.org/docs/9.6/static/functions-binarystring.html">https://www.postgresql.org/docs/9.6/static/functions-binarystring.html</a>. ST_AsMVT(...) || ST_AsMVT(...) will produce a single binary tile with two layers. This works with the MVT protobuf format because a Tile is nothing more than a collection of Layers at the root level.</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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div style="font-size:12.8px">2. What names are given to layers in the generated tile? Are they configurable? (I.e. if my input comes from a function, not a table or a view).</div></div></div></div></div></blockquote><div><br></div><div>ST_AsMVT produces exactly one Layer. The first parameter for ST_AsMVT is name which is the layer name. See <a href="https://git.osgeo.org/gogs/postgis/postgis/pulls/5">https://git.osgeo.org/gogs/postgis/postgis/pulls/5</a> for more information about the parameters.</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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div style="font-size:12.8px">3. Does st_asmvt do any internal filtering and/or simplification of the input geometries? </div><div style="font-size:12.8px">It’d be great if it doesn’t, because I’d like to have control on this process with SQL. So I send rows with filtered and simplified geometry to st_asmvt and it just does tile encoding.</div></div></div></div></div></blockquote><div><br></div><div>Yes it does and it is inevitable. A vector tile does not encode original coordinates. Instead the vector tile has a local integer screen coordinate system and so coordinates must be translated in the encoding process. Roughly the logic in the encoding throws away coordinates smaller than a pixel (defined by the tile screen coordinate system extent) and coerces geometries smaller than a pixel to point centroids. A more in depth explanation is found at <a href="https://www.mapbox.com/vector-tiles/specification/">https://www.mapbox.com/vector-tiles/specification/</a>.</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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div style="font-size:12.8px">4. Are there any tools to check the contents of the tile? Maybe node module with a decoder or smth.</div></div></div></div></blockquote><div><br></div><div><a href="https://github.com/mapbox/vector-tile-js">https://github.com/mapbox/vector-tile-js</a><br></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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div style="font-size:12.8px">Cheers,</div><div style="font-size:12.8px">Nick</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">
Date: Sun, 27 Nov 2016 17:12:22 +0100<br>
From: Björn Harrtell <<a href="mailto:bjorn.harrtell@gmail.com" target="_blank">bjorn.harrtell@gmail.com</a>><br>
To: PostGIS Users Discussion <<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><wbr>><br>
Subject: Re: [postgis-users] ST_AsMVT returns an error when<br>
        calculating tile bbox from x, y, z<br>
Message-ID:<br>
        <CANhDX=a42GQTDf6b6qo3u4w0k8=<a href="mailto:qOPOgfsBuRvEF6gxu3%2BEx%2Bw@mail.gmail.com" target="_blank">q<wbr>OPOgfsBuRvEF6gxu3+Ex+w@mail.gm<wbr>ail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<span class="gmail-"><br>
<br>
I've now added changes to my asmvt branch to allow for non square bounds,<br>
which I hope can resolve your issues.<br>
<br>
/Björn<br>
<br>
2016-11-26 9:59 GMT+01:00 Nikolai Bezdna <<a href="mailto:mofoyoda@gmail.com" target="_blank">mofoyoda@gmail.com</a>>:<br>
<br>
> I’m trying to use ST_AsMVT to respond to client tile requests with<br>
> MVT-fromatted response.<br>
><br>
> From the client side I’m getting standard web mercator tile coordinates as<br>
> z, x, y. To transfer these numbers to proper BBox, I’m using this Mapbox<br>
> helper function for PostGIS (TileBBox):<br>
> <a href="https://github.com/mapbox/postgis-vt-util/blob/master/" rel="noreferrer" target="_blank">https://github.com/mapbox/post<wbr>gis-vt-util/blob/master/</a><br>
> postgis-vt-util.sql#L541<br>
><br>
> When I use it's output geometry as a BBox parameter for ST_AsMVT function,<br>
> I get an error:<br>
><br>
> [XX000] ERROR: mvt_agg_init_context: bounds must be square<br>
><br>
> Both CRS of BBox and the input geometry is 3857.<br>
> ST_AsMVT runs without this error only when x and y are the same, e.g:<br>
> ST_AsMVT('test’, TileBBox(10, 1279, 1279), 4096, 0, false, ‘geom’, q)...<br>
> In all other cases ST_AsMVT returns this error.<br>
> I guess the returned BBox geometry is absolutely square only when x = y.<br>
><br>
> But how can I calculate the proper bounding box for each tile request?<br>
> TileBBox function looks pretty straightforward. Looks like there are no<br>
> errors in it.<br>
><br>
> ______________________________<wbr>_________________<br><br></span></blockquote></div></div></div>
<br>______________________________<wbr>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/postgis-users</a><br></blockquote></div><br></div></div>