tobinbradley/dirt-simple-postgis-http-api

Does it compativle with MVT v2 format?

Closed this issue · 8 comments

Hi. I have a PG 9.5 database with 2.3.2 PostGIS extension and a table with geo data, converted with ogr2ogr.

I'm trying to use dirt-simple-postgis-http-api as a backend for serving tiles for my map, but Mapbox GL JS can't render the vectors:

Vector tile source "source_name" layer "table_name" does not use vector tile spec v2 and therefore may have some rendering errors.

map.addSource('source', {
   'type': 'vector',
   'tiles': [
     "http://localhost:8123/mvt/v1/table_name/{z}/{x}/{y}?geom_column=wkb_geometry&limit=5000"
   ]
});

Am I doing something wrong or dirt-simple-postgis-http-api does not support MVT v2 format? Thanks

I think that warning message is just GL JS whinging a bit but everything is fine. Here's a working example. Since you're not getting outright errors, my guess is the layer is being loaded but isn't getting styled.

I'm using geojson-vt to render vector tiles at the moment. There is a slightly newer version available (2.4 vs 2.3), so you might try updating that dependency to see if the whinging goes away, but I don't see any indication that 2.4 updated the MVT format from the release notes.

Down the road I'll likely replace the geojson-vt bit with PostGIS 2.4's new asMVT function, as it's a tad faster and drops the geojson-vt dependency. I don't know what MVT version it outputs though, so that may not make the whinging go away either.

Hope that helps!

So you mean that this functionality can be replaced with just a PostGIS 2.4 toMVT function?

P.S. There are no problems with the styles, because I just try to replace current Mapbox tile storage to hosted (with dirt-simple-postgis-http-api + PG table with all the data). The data is correct - it was tested with the t-rex tileserver.

I'm saying the code in that service would change from PostGIS->GeoJSON->geojson-vt to just PostGIS (using asMVT). The both routes end up at the same place, but the latter should be faster. See this write up, though it's using mapnik instead of geojson-vt.

I don't have enough information to provide insight into the issue you're seeing, but it sure smells like a styling problem, and I can't simulate the issue (see my previous example that works fine). Note I didn't say the data was wrong - I think it's probably fine. With vector tiles loading (source) and styling (layer) the data are two entirely different things; just specifying a source as per your example won't draw anything on the map.

I'm saying the code in that service would change from PostGIS->GeoJSON->geojson-vt to just PostGIS (using asMVT). The both routes end up at the same place, but the latter should be faster. See this write up, though it's using mapnik instead of geojson-vt.

Yep, that is what am I talking about.

I don't have enough information to provide insight into the issue you're seeing, but it sure smells like a styling problem, and I can't simulate the issue (see my previous example that works fine). Note I didn't say the data was wrong - I think it's probably fine. With vector tiles loading (source) and styling (layer) the data are two entirely different things; just specifying a source as per your example won't draw anything on the map.

Yes, I understand what do you mean. I forgot to say that there are no problems with the styles because it is a legacy stable app. I will do some research tomorrow to find the problem. Anyway thanks!

Hi @tobinbradley. I found the problem: there were wrong filters for mapbox. Thanks!

Btw, what are the plans about PostGis ST_AsMVT functionality for this project? I found it really helpful and working (cant say this about most of the other tile servers)

Glad you figured it out!

My plan is to move the MVT service to st_asmvt before the end of the year. Hopefully that'll be enough time for people to move to PostGIS 2.4. I'd rather not have pre-2.4 and post-2.4 paths for that service if I can avoid it.

Update - looks like they pushed a patch to vt-pbf allowing the specification of MVT version. I updated the dependency and I think I added the option correctly to the MVT route. Hopefully that'll get rid of the warning message.

It's a good news, I will check it tomorrow. I've tested tilestrata postgis mvt - it works much more faster (with ST_AsMVT), but returns all the features without simplification.