stezii / tilestrata-postgismvt Goto Github PK
View Code? Open in Web Editor NEWA TileStrata plugin for serving Mapbox Vector Tiles from a PostGIS database
License: Apache License 2.0
A TileStrata plugin for serving Mapbox Vector Tiles from a PostGIS database
License: Apache License 2.0
Hi. I'm trying to run own tile-server that works with dynamic tiles from PostGIS.
I have: PG 10, PostGIS 2.4, TileBBox from Mapbox and data exported with ogr2ogr.
My server code is:
var tilestrata = require('tilestrata');
var disk = require('tilestrata-disk');
var dependency = require('tilestrata-dependency');
var strata = tilestrata();
var postgismvt = require('tilestrata-postgismvt');
var headers = require('tilestrata-headers');
strata.layer('data').route('tile.mvt')
.use(headers({'Access-Control-Allow-Origin': '*'})).use(postgismvt({
lyr: {
table: 'public.table_name',
geometry: 'wkb_geometry',
type: 'circle',
srid: 4326,
minZoom: 3,
maxZoom: 19,
buffer: 10,
fields: 'type ogc_fid',
resolution: 256,
},
pgConfig: {
host: '0.0.0.0',
user: 'postgres',
password: 'postgres',
database: 'database',
port: '5432'
}}));
// start accepting requests
strata.listen(8080);
But when I try to connect it to Mapbox GL JS - I see an errors:
mapbox.addSource('table_name', {
'type': 'vector',
'tiles': [
"http://localhost:8080/table_name/{z}/{x}/{y}/tile.mvt"
]
});
XHR finished loading: GET "http://localhost:8080/data/11/602/769/tile.mvt".
exports.getArrayBuffer @ blob:http://localhost:3000/c4a4aaef-41f9-439c-9f35-18659ae78ad7:293
loadVectorTile @ blob:http://localhost:3000/c4a4aaef-41f9-439c-9f35-18659ae78ad7:121
VectorTileWorkerSource.loadTile @ blob:http://localhost:3000/c4a4aaef-41f9-439c-9f35-18659ae78ad7:121
Worker.loadTile @ blob:http://localhost:3000/c4a4aaef-41f9-439c-9f35-18659ae78ad7:123
Actor.receive @ blob:http://localhost:3000/c4a4aaef-41f9-439c-9f35-18659ae78ad7:291Error: Error: http status 200 returned without content.
What am I doing wrong?
Hi. Thanks for this lib, it's really interesting and helpful
Btw, what about some data simplification ? Currently I have more than 300 000 features in my PostGIS table and when I trying to serve this data with tilestrata-postgismvt
- it sends for about ~35 mb of data (all possible features) without any simplification based on zoom or whatever else. You can see it on the attached screenshoot
I think it will be great to add some option (like simplify: true
or more smart one) and refactor SQL query to simplify (reduce or union) the features based on zoom for example. What do you think?
tilestrata-postgismvt fails for me and I don't know whether it's my data, my postgis install or a bug in tilestrata-postgismvt. Here is the failing auto-generated query:
SELECT ST_AsMVT('l1', 256, 'geom', q) AS mvt FROM (
SELECT ST_AsMVTGeom(ST_Transform(public.kalktest.geom, 3857),
TileBBox(4, 8, 4, 3857), 256, 0, false) geom , kalkinnhol
FROM public.kalktest
WHERE ST_Intersects(TileBBox(4, 8, 4, 3857), public.kalktest.geom)
) AS q
mvt_agg_transfn: geometry column cannot be null error: mvt_agg_transfn: geometry column cannot be null
My config:
.use(postgismvt({
lyr: {
table: 'public.kalktest',
geometry: 'geom',
// type: 'circle',
srid: 3857,
minZoom: 0,
maxZoom: 19,
buffer: 0,
fields: 'kalkinnhol',
resolution: 256
},
If I add
WHERE geom IS NOT NULL
to the default query at index.js:104 it returns tiles.
Im using this with mapboxgl JS and I cannot view the geometries on the map because source-layer
is required and tilestrata-postgismvt do not support layers inside the source.
map.addSource('countries', {
"type": "vector",
"tiles": ["localhost:5003/postgismvt_layer_name/{z}/{x}/{y}.mvt"]
});
map.addLayer({
"id": "countries",
"type": "fill",
"source": "countries",
"source-layer": "layers_inside_postgismvt_layer",
});
So Im wondering if has any way to add layers inside tilestrata-postgismvt to create nested layers.
I'm trying to use this library with npm but the signature is wrong, can you update the npm package?
thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.