<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">On 9/16/2016 4:27 AM, Björn Harrtell
      wrote:<br>
    </div>
    <blockquote
cite="mid:CANhDX=ab1to21pcgwuTZcyvN8KmicusUv6yeoeGCm=VL6Kts4Q@mail.gmail.com"
      type="cite">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>)</blockquote>
    <br>
    As an interface I propose taking in a row or similar instead of a
    query. Anything that takes SQL as text can be a problem.<br>
    <br>
    For the other parameters I recommend name text, bounds box2d, extent
    integer DEFAULT 4096, buffer integer DEFAULT 0, clip_geoms bool
    DEFAULT true.<br>
    <br>
    name is the required name of the layer.<br>
    <br>
    bounds is the area which corresponds to the unbuffered area of the
    vector tile, and will typically be the area of an xyz tile.<br>
    <br>
    Extent is the extent for the vector tile, as specified in the spec.<br>
    <br>
    Buffer is how far to go out for geometries to include as well as
    used in clipping.<br>
    <br>
    clip_geoms is if geometries should be clipped at the buffered extent
    or not. It's valid to include a geom that goes beyond the buffered
    extent, but this is not normally done for rendering.<br>
    <br>
    For a return type, I'd go with bytea, being the binary data for the
    layer. Don't apply gzip compression, it's not part of the vector
    tile itself.<br>
    <br>
    Thanks to the properties of mapbox vector tiles, you can then build
    a multi-layer tile by concatenating the results of multiple ST_AsMVT
    calls<br>
  </body>
</html>