To define a tile set, you must determine the specifications of the Slippy Map tiles that will cover your cave model, at a suitable zoom level. CaveView displays the tiles required to cover your model in the Javascript console as:
load: [ zoom/x/y ]
, where zoom, x and y are the tile zoom level, x and y coordinates.
Example:
load: [ 16/32432/21247 ] ...
load: [ 16/32432/21248 ] ...
load: [ 16/32433/21247 ] ...
load: [ 16/32433/21248 ] ...
The format of the tileSet.json file that is used to define a tile set is described here.
To aid this process CaveView 1.10.1 and greater allow a prototype file tileSetEntry.json to be automatically downloaded. To obtain this file, load your model into CaveView and display the terrain. If no terrain is available and the model has a supported CRS, a flat terrain will be displayed and a download button will be shown in the ‘Terrain’ tab (not supported in Internet Explorer 11). Clicking this button will download the prototype file.
The DTM used must be in the ESPG:3875 (WebMercator) CRS. If your DTM is already in this CRS this step can be ignored.
Convert the DTM with the GDAL ‘gdalwarp’ tool as follows (the GDAL tools are distributed with GRASS and other GIS applications):
gdalwap -s_srs <source CRS> -t_srs EPSG:3875 -r bilinear <source file> <output file>
This produces a GeoTIFF file.
Create a GRASS location using EPSG:3875 and a empty mapset within that location.
Import the DTM produced in step 2 into this mapset, this used the command r.in.gdal which can be located with the ‘File->Import raster data->Import common raster formats’.
Copy the files ‘makeRasters.js’ and ‘makeTiles.js’ into an empty directory with the tileSetEntry.json file described previously.
Create GRASS raster data in the required format:
node makeRasters.js <source raster>@<mapset>
where <source raster> is the name of the raster chosen in step 3 and <mapset> is the name of the map set created in step 3. The node command and location will vary according to the OS in use.
This creates a set of new GRASS rasters at the required resolutions and modifies the tileSetEntry.json file as needed.
To create the individual tiles:
node makeTiles <mapset>
This will create the subdirectory as specified in the tileSetEntry subdirectory property, and populate this with subdirectories and tiles for each zoom level.
Copy or move the subdirectory created in step 4 to the terrainDirectory location. Create a file tileSets.json containing the object defined in the tileSetEntry.json file in an array. If this file already exists, the the new entry to the existing array.
Reload the model and ensure that the terrain is displayed correctly. Any errors are reported in the browser Javascript console.