1

I want to create an application using vector tile. I am using OpenLayers 5 and GeoServer 2.14 for this purpose. My data (stored in PostgreSQL+PostGIS) has around 2.5 lakhs geometry (road network) which is published in geoserver through SQL view.
Geometry of the data is fixed but its attributes related to traffic etc. are changing in every 2 minutes. We want client side rendering that's why we are planning for vector tile options.

My current code for rendering vector tile is:

   function getbbox(tileCoord) {
                var tileGrid = source.getTileGrid();
                var coord = source.getTileGrid().getTileCoordExtent(tileCoord);
                var newCoord = ol.proj.transformExtent([coord[0], coord[1], coord[2], coord[3]], 'EPSG:4326', 'EPSG:3857'); // perform projection transform with given extent.
                return newCoord[0] + ';miny:' + newCoord[1] + ';maxx:' + newCoord[2] + ';maxy:' + newCoord[3];
            }

    var source = new ol.source.VectorTile({
                cacheSize: 0,
                tileUrlFunction: function (tileCoord, pixelRatio, 
         projection) {
                    return 'http://localhost:8080/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=cite:OPE_MAP_SpatelSpeed&STYLE=' +
                        '&TILEMATRIX=' + projection.getCode() + ':' + tileCoord[0] +
                        '&TILEMATRIXSET=' + projection.getCode() +
                         '&FORMAT=application/json;type=geojson' +
                        '&TILECOL=' + tileCoord[1] +
                        '&TILEROW=' + (-(tileCoord[2] + 1)) +
                        '&VIEWPARAMS=ispercent:1;G:A0FF0B;minx:' + getbbox(tileCoord) + ';zoomlevel:' + tileCoord[0] +
                        '&key=' + Math.random()
                },
                format: new ol.format.GeoJSON({}),
                projection: projection,
                tileGrid: new ol.tilegrid.WMTS({
                    tileSize: [256, 256],
                    origin: [-180.0, 90.0],
                    resolutions: resolutions,
                    matrixIds: gridNames
                }),
                wrapX: true
            }); 

The problem which i am facing is : 1) Calls for vector tiles is very slow, it takes >60 sec for completing request. 2) Once data is loaded, next time it is coming from GeoServer tile cache, thus not reflecting latest traffic data which comes every 2 min.

We are already passing tile bounding box as viewparams(minx, miny, maxx, maxy) to PostgreSQL query to fetch data for that particular region only for better performance.

Does it is a good option to go for vector tiles for dynamic data? Or there is any way to improve the performance?

2
  • a vector tile contains a lot of data - could you not just request the data as geojson using WFS
    – Ian Turton
    Feb 1, 2019 at 12:38
  • Why to update at all the road data that is stable? Consider reading the geometries with stable IDs once and update just the changed attribute data by using IDs as links.
    – user30184
    Feb 3, 2019 at 21:07

1 Answer 1

0

In your scenario if geometry is not changing at all, then I would just cache those geometries and find some common identifier, index tables and make 2 tables (1. Geometry related static 2. dynamic data) and then create a view (MV etc) and see if that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.