postgis loader issues metadata queries but not data query

落花浮王杯 提交于 2019-12-01 09:16:44

问题


EDIT 1: I just discovered postgis has an ST_AsMVT function built in, which does exactly what I want (I think), so I'm not going to use mapnik at all!

EDIT 2: unfortunately that function isn't yet in a released version of PostGIS, but hopefully it will be within the next few weeks.


Originally posted as a github issue.

When I do something like the following, with logging turned on for my DB, I see that some "metadata" requests are made to postgis, however, no actual data query is ever made.

The requests for metadata are (presumably) needed for the logic relating to field names/types and extent (when not explicitly provided).

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);
  });
});

Metadata query as seen in postgres logs:

SELECT * FROM some_geometry_table LIMIT 0

What am I doing wrong?

来源:https://stackoverflow.com/questions/42960495/postgis-loader-issues-metadata-queries-but-not-data-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!