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