Tile Server

From MediaWiki
Revision as of 22:29, 17 November 2023 by Rob (talk | contribs) (→‎Mapnik)
Jump to navigation Jump to search

Overview

The tile server is a collection of tools that read geospatial data -- from rasters, vectors or the database -- project them and save them into the form of raster tiles at a range of zoom levels. Probably the most well-known tile server is the one behind Google Maps.

MSEA's tile server relies on an opensource stack used by OpenStreetMap, including Mapnik and mod_tile/renderd. Tiles are actually served in response to HTTP requests by a private Apache Web Server instance which receives proxy requests from the public-facing Nginx server.

Each of these components has a particular role in the map tile lifecycle, treated briefly here, and in more depth below.

  • Mapnik -- actually does the work of rendering tiles, using styles and projection information provided in XML configuration files. These are stored in the /home/msea/mapnik directory. In some cases, Mapnik configurations are generated automatically during the upload process, for example by the Intertidal Database Import feature.
  • mod_tile -- an Apache module that handles HTTP requests for tiles and passes them to Mapnik.
  • renderd -- a daemon that runs Mapnik to produce the tiles. This program runs in response to real-time queries, and can also be run to generate tiles continuously in the background.

The above libraries are checked out as source code from their respective repositories and built and installed on the server using the standard cmake/make/install process. If any of the libraries have been installed previously using the system package manager, they must be fully removed.

Coordinate Reference Systems and Projections

The data stored in the database and in raster form is very precisely referenced using Canada's official coordinate reference system, NAD83(CSRS) and vertical datum, CGVD2013. Some elevations are measured with respect to the local chart datum, and are calculated using a shift grid from CGVD2013 heights.

Due to isostatic rebound and plate tectonics, all positions move with respect to the reference frame (ITRF/WGS84), so they must be accompanied by an epoch, or date, with describes the date at which they are comparable. Positions collected in June 2023, for example, are given the epoch 2023.5, and transformed to 2010.0, which is the standard reference epoch used by a variety of organisations with in the federal public service (the province of British Columbia uses 1997.0 for Vancouver Island and 2002.0 for the mainland).

By default, mosaics, point clouds, digital surface models and other products derived from UAS imagery are projected into the Universal Transverse Mercator projection. For display on a Web map, these are projected again into the Web- or Pseudo Mercator projection.

Mapnik

The Mapnik configuration for each layer is an XML file which declares both a map and one or more layers. Documentation is available for Mapnik configuration, but it is not comprehensive or necessarily complete.

Layers are transformed from their own CRS and projection to those of the map. The transformations are declared using proj, the official velocity grid provided by NRCAN and a pair of epochs.

The following layer configuration is for a map of a Calvert Island beach located in UTM zone 9, produced in June, 2023.

   +proj=utm +zone=9 +ellps=GRS80 +units=m +no_defs +type=crs +grids=ca_nrc_NAD83v70VG.tif +t_final=2010.0 +t_epoch=2023.5
  • The proj and zone parameters indicate that the map is in the UTM projection, zone 9.
  • The ellps parameter gives the ellipsoid as GRS80, which is commonly used with WGS84, the coordinate reference frame used by the GPS system.
  • The grid parameter provides the name of a grid shift file, wherein each pixel represents the distance and direction a coordinate should be displaced per unit time.
  • The t_epoch parameter provides the date of origin of the data, in this case, the date it was produced.
  • The t_final parameter provides the target epoch to which the data will be transformed using the grid shift file, in this case the standard epoch, 2010.0.

The map configuration is declared as the standard "Web Mercator" projection (EPSG:3857, formerly EPGS:900913):

   +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +wktext +no_defs +over

Mapnik will use this pair of configurations, transforming the map from one to the other so that it can be displayed with a high degree of precision.

mod_tile

Will be installed during building, but may have to be enabled using a2enmod

TODO

renderd

Will be automatically installed during building. The configuration file is located at /etc/renderd.conf

TODO