Postgis loader handles metadata requests but not data requests

EDIT 1: I just discovered that postgis has a ST_AsMVT function that does exactly what I want (I think), so I won’t use mapnik at all!

EDIT 2: Unfortunately, this feature has not yet been published in the PostGIS release, but hopefully it will be in the next few weeks.


Originally posted as a github issue .

When I do something like the following: when I turn on the log for my database, I see that some metadata requests come to postgis, however no actual data request is made.

Requests for metadata are (presumably) necessary for logic related to field names / types and degree (if they are not explicitly specified).

var postgis = new mapnik.Datasource({
  type: 'postgis',
  host: ... etc,
  table: 'some_geometry_table',
  geometry_field: 'geom',
  srid: 4326,
  extent: "-180,-85.0511,180,85.0511",
  estimate_extent: false,
  row_limit:  10 // !! this doesn't seem to do anything
});

var map = new mapnik.Map(256, 256);
var layer = new mapnik.Layer('some_layer');
layer.datasource = postgis; 
map.add_layer(layer);
map.render(new mapnik.VectorTile(z, x, y), {}, (err, vtile) => {
    if (err) next(err);
    var data = vtile.getDataSync({});
    var file = path + z + "," + x + "," + y + ".pbf"
    console.log(data);
    console.log("written: " + file);
    fs.writeFileSync(file, data);
    next(null);
  });
});

A metadata request, as shown in postgres logs:

SELECT * FROM some_geometry_table LIMIT 0

What am I doing wrong?

+2
source share

Source: https://habr.com/ru/post/1589214/


All Articles