TerriaJS / terriajs

A library for building rich, web-based geospatial data platforms.
https://terria.io
Apache License 2.0
1.18k stars 364 forks source link

Support for Esri Vector Tile format & tileserver GL #6765

Closed AnaBelgun closed 1 year ago

AnaBelgun commented 1 year ago

This ticket is to record the work for supporting the Esri Vector Tile format.

sixlighthouses commented 1 year ago

Initial testing of protomaps renderer was positive. However after looking into labelling and the current state of protomaps (no longer under active development) it was decided in discussion with Crispy to implement a new Mapbox Vector tiles imagery provider.

AnaBelgun commented 1 year ago

Pete is working on setting up the tileserver GL to work with magda

AnaBelgun commented 1 year ago

15 May 23:

sixlighthouses commented 1 year ago

Protomaps, MVTs and Vectors Oh My

Overview

Currently we use ProtomapsImageryProvider to read several vector formats and rasterize them on the fly for use in Leaflet and Cesium viewers. This approach works well for rendering of geometry and very simple labelling. Modern Javascript map viewers however are tuned for rendering vectors directly and the Mapbox Vector Tile specification allows for complex and expressive labelling. nb: the ArcGIS Vector Tile protocol implements the Mapbox Vector Tile spec. ProtomapsImageryProvider was not made with complex labelling in mind, so therefore does not support the kind of visualisations required by customers such as NSW Digital Twin basemaps.

Cesium's github repo has an open issue since 2014 discussing the support of vector data see hereTo summarize that discussion -- using the approach taken by Protomaps and tileserver-gl is the only current option. It is acknowledged a better approach would be to render directly to the Cesium managed canvas but there are no plans for this work to be undertaken as yet.

Proposed Short Term Approach - tileserver-gl

tileserver-gl was developed by MapTiler to provide a server side solution to reading vector tiles and providing raster tiles on the fly. Configuration is used to point tileserver-gl to an MVT service as a datasource (in our current use case ArcGIS VectorTile services), tileserver-gl then proxies the requests to the datasource exposed to the client application as raster (png, wbp, jpg) {z}/{x}/{y} tiles. tileserver-gl uses MapLibre native to acheive this, therefore it does support the full MVT spec. We currently have a POC running in NSW Digital Twin Dev

3 of the basemaps in this Terria instance

This POC exposes 2 issues that need addressing before we publish to production

  1. Performance -- tileserver-gl is running in Docker, some performance tuning is required to provide end users with an acceptable experience.
  2. Maximum zoom scale -- as the ArcGIS Vector service does not return below zoom level 17, requests to tileserver-gl return blank tiles.

Alternate Solutions

  1. Extend ProtomapsImageryProvider to support full MVT spec -- at first this seemed the most straight forward. However to build on the current approach would be a complex piece of work and may lead to ongoing maintenance of the code as viewers and the MVT evolve. Additionally the maintainer of Protomaps is no longer working on the project and has in several issues pointed users to other solutions for more complex uses of vector data.
  2. Create new MVTImageryProvider base on tileserver-gl approach -- provides full implementation of MVT spec. Medium complexity task, would also lead to ongoing maintenance.
  3. Swap out Leaflet for MapLibre (or similar) map viewer that natively supports use of Vectors. High complexity inital task to remove use of Leaflet. Longer term benefits as use of vector data provides better end user experience. Also does not solve the issue for Cesium.
sixlighthouses commented 1 year ago

Setting maximumLevel trait on the url-template layer alleviates the issue of blank tiles being generated below zoom level 17 -- change made and testable in dev

AnaBelgun commented 1 year ago

Update 24 May:

AnaBelgun commented 1 year ago

2 June 2023:

sixlighthouses commented 1 year ago

Summary for NSW DT

Terria.js has chosen TileServer as its preferred tool for rendering vector tiles, including support for ArcGIS Vector services. TileServer is an open-source map server contributed to the geospatial community by MapTiler. TileServer's robust caching mechanisms and optimized rendering algorithms ensure efficient rendering of vector data with complex styling, enabling Terria.js to deliver fast and responsive maps to NSW Digital Twin users. By leveraging TileServer's compatibility with various vector tile formats, including ArcGIS Vector Tiles, Terria.js offers an enhanced mapping experience that empowers users to explore and utilize the geospatial data provided by the NSW government effectively.