tobinbradley/dirt-simple-postgis-http-api

How do you export as Mapbox Vector Tile?

Closed this issue · 3 comments

I've got Dirt-Simple (DS) set up for one table and I'm able to run several of the functions on the geometry.

I can't get mvt to work because I don't know what to fill in as values for z, x, and y.

I've filled in some values from a PNG image tile from another map that I'm using on a production site, so I believe those values represent a real place in my dataset.

Instead of a good response, I get this error:

{
  "error": "error running query",
  "error_details": {
    "name": "error",
    "length": 370,
    "severity": "ERROR",
    "code": "42501",
    "where": "SQL statement \"select SRID         from geometry_columns where (f_table_schema = schem or schem = '') and f_table_name = tabl and f_geometry_column = $3\"\nPL/pgSQL function find_srid(character varying,character varying,character varying) line 15 at SQL statement",
    "file": "aclchk.c",
    "line": "3409",
    "routine": "aclcheck_error"
  }
}

aclcheck_error generally refers to a permissions problem in the database. The usual culprit is the api login doesn't have read permissions for the geometry_columns table. That service uses the find_srid function that would hit that table. Try grant select on geometry_columns to api_login_name and see if it works.

@tobinbradley heh. I don't have permission to GRANT the permission (it's an AWS RDS-hosted database, so I don't know if I can have permission on the geometry_columns table).

Oh. That's a problem :).

geometry_columns is a view PostGIS creates when it installs. It contains all of the tables with geometry columns and a little meta information (like the SRID). To execute the PostGIS function find_srid the user needs read permissions to that view, and a couple of endpoints (geojson, intersect_point, mvt, and nearest) use find_srid. It uses find_srid so you don't have to pass the SRID of the table you are querying.

I can't imagine you can't set permissions on that view, as it isn't a Postgres system object. Looks like from the docs the rds_superuser can use GRANT. But if you really can't, you could alter those end points to get the table SRID from the request and drop find_srid from the queries.

Sorry I can't be of more help. I get this same error when I upgrade PostGIS, which recreates that view, and forget to re-add read rights to the API login, which happens almost every time I upgrade PostGIS.