[postgis-devel] ST_AsMVTGeom() feature size limit

Raúl Marín raul at rmr.ninja
Wed May 19 08:21:16 PDT 2021


On 2021-05-19 02:11, Paul Ramsey wrote:
 > I was interested to find that ST_AsMVTGeom drops features that fall 
below 1/2 a pixel in size.

If they didn't collapse then they would never disappear, so you would 
have all the data inside high level zoom tiles, which is something MVT 
needs to avoid. Imagine having 300M buildings in the US and requesting 
the tile 0/0/0; if you don't drop the features thar are invisible (< 1 
extent-pixel) then you would need to encode the data of all 300M buildings.

Technically you could transform the source line into a single point (in 
the pixel-extent they fall), as the spec doesn't say anything about it, 
but the renderers (or at least the time I checked, ~2 years ago) will 
cry if a feature changes geometry types depending on the zoom level or 
if you include different geometry types in the same layer.

I've seen similar complaints when people try to create dashboards using 
MVT properties as the source, but you can't expect to put 250 GB of data 
in a 500 kB tile. MVTs were created for rendering, not data transmission.


 > There's no configuration option to avoid this behaviour, and if you 
map a large enough area that your feature size falls below a pixel you 
end up with big blanks in your map. Have there been no complaints about 
this before?

Probably not because all MVT generators work like that (by design). Note 
that the solution wouldn't be to include everything (which would be 
impossible) or to merge features (which depends on the data), instead 
users shouldn't generate zoom levels were most of the data disappears 
and instead used different geometry sources depending on the zoom level 
(like Google Maps does).


On 2021-05-19 01:59, Darafei "Komяpa" Praliaskouski wrote:

 > There is a Simplify call at the end of ST_AsMVT that uses the wrong 
epsilon. It should be 0 instead of 0.5px. Please check this fix: 
https://github.com/postgis/postgis/pull/463/files - I'd be happy if it 
gets committed. :)

As Paul has said, this has nothing to do with ST_Simplify using 0.5 
pixel-extent units or 0. Those lines should still disappear with 0 unit 
simplification. And yeah if you want more precision you should increase 
the extent.

Regards,

Raúl.



More information about the postgis-devel mailing list