Elevation layers in templates

From Maria GDK Wiki
Revision as of 15:12, 12 September 2019 by Mbu (talk | contribs) (Mbu moved page Elevation layers in templates to Elevation layers in templates: changed title)
Jump to navigation Jump to search


Hill shading layers

Available since Maria GDK 3.1.

Pregenerated normal maps

Generated with the TPG tool ...

<layer type="ModLayer" name="Normalmapelevations" category="ElevEffects">
    <opacity>1</opacity>
    <brightness>0</brightness>
    <gamma>1</gamma>
    <contrast>0</contrast>
    <grayscale>false</grayscale>
    <compression>Any</compression>
    <minscalevisible>244</minscalevisible>
    <maxscalevisible>128000000</maxscalevisible>
    <description>Elevation shading layer based on prerendered normal maps</description>
    <datasource>
      <mapsignature>norway_normals20m</mapsignature>
      <maptype>RasterMap</maptype>
      <showlabels>true</showlabels>
      <usecache>true</usecache>
    </datasource>
    <visible>true</visible>
  </layer>

Generating hill shading from elevation data

If you have elevation data active in the application you can generate the hill shading automatically. To do this, add a ModLayer as above, but with an "ElevationNormals" maptype data source. The map signature value is not significant.

  <layer type="ModLayer" name="Auto shading" category="ElevEffects">
    <opacity>1</opacity>
    <brightness>0</brightness>
    <gamma>1</gamma>
    <contrast>0</contrast>
    <grayscale>false</grayscale>
    <compression>Any</compression>
    <minscalevisible>1</minscalevisible>
    <maxscalevisible>2000000</maxscalevisible>
    <datasource>
      <mapsignature>AutoShading</mapsignature>
      <maptype>ElevationNormals</maptype>
      <showlabels>false</showlabels>
      <usecache>false</usecache>
    </datasource>
    <shadingparameters>
        <ambient>0.6</ambient>
    </shadingparameters>
    <visible>true</visible>
    <property key="labels:fetchdata" value="false" />
  </layer>

Elevation color map layers

Available since Maria GDK 4.0

Another use for elevation data is to make map layers colored according to some function of the terrain surface. Currently we support straight elevation color maps where each pixel is colored according to its elevation value, and slope maps, where each pixel is colored according to its gradient, or slope value.

To make such a layer, set up a template layer with type ElevationColorMapLayer and a data source with map type ElevationColorMap. To control the analysis function and color palette, use the properties elevation:analysisMode and elevation:paletteId.

Parameter Possible values
elevation:analysisMode elevation, slope
elevation:paletteId elevation, slope, bathymetry

There are three built-in color palettes: elevation, bathymetry and slope, but more palettes can be added programmatically in your application. See the documentation for TPG.GeoFramework.MapLayer.ElevationColorMapProvider for more details.

The following example sets up a slope layer.

  <layer type="ElevationColorMapLayer" name="Elevation Color Map">
    <opacity>1</opacity>
    <brightness>0</brightness>
    <gamma>1</gamma>
    <contrast>0</contrast>
    <grayscale>false</grayscale>
    <compression>Any</compression>
    <minscalevisible>1</minscalevisible>
    <maxscalevisible>20000000</maxscalevisible>
    <datasource>
      <mapsignature>ElevationColorMap</mapsignature>
      <maptype>ElevationColorMap</maptype>
      <hostcategory>DontCare</hostcategory>
      <showlabels>false</showlabels>
      <usecache>false</usecache>
    </datasource>
    <visible>true</visible>
    <property key="labels:fetchdata" value="false" />
    <property key="elevation:analysisMode" value="slope" />
    <property key="elevation:paletteId" value="slope" />
  </layer>

Elevation data layers

Templates can also be used to define a set of elevation data layers used for analysis purposes, such as elevation profiles etc.

These elevation layers are processed in the order they appear in the template file, in such a manner that the first layer that returns a valid result is used. This means that you typically want to place datasets with higher resolution and smaller area first in the file. If your query falls within the high resolution subdataset, you will get result from these data, and if not, it will fall through to the next layer which may for example be a global base elevation grid.

These templates are typically set programmatically through the IElevationData interface.

In the following example, we have a 10m resolution elevation data set that covers Norway first in the template, and a global SRTM dataset as fallback.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<compositemaptemplate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="FBE924BD-3D90-4E0C-AA62-C6346DAB6829" name="World Panorama v1.5" version="0.0.1">
  <layer type="ElevationLayer" name="Norge 10m">
    <compression>Any</compression>
    <datasource>
      <mapsignature>elevation10m</mapsignature>
      <maptype>ElevationData</maptype>
      <usecache>false</usecache>
    </datasource>
    <visible>true</visible>
  </layer>
  <layer type="ElevationLayer" name="SRTM30">
    <compression>Any</compression>
    <datasource>
      <mapsignature>globe_elevation</mapsignature>
      <maptype>ElevationData</maptype>
      <usecache>false</usecache>
    </datasource>
    <visible>true</visible>
  </layer>
</compositemaptemplate>

Dynamic layers in templates

Available since Maria GDK 3.1.+.

It is possible to dynamically build up templates using overlay-templates and corresponding tags. This is done by creating a (basemap) template containing references to (overlay) templates. (Overlay-templates use the same syntax as regular templates, but are NOT regarded as "normal" templates by Maria GDK). The purpose is to ease the process of replacing and adding maps to a basemap without continously having to update the template.xml.

First you need to add templatefilters (with tags for referencing) in overlay-templates.

<compositemaptemplate name="testOverlay" id="0CB9BB2B-3C4E-4922-889B-7442E683C2AB" type="overlay">
  <templatefilter tags="groundraster" pri="500"/> <!-- tag this overlay -->
  <layer type="OverlayLayer" name="OpenstreetMap">
    <opacity>1</opacity>
    <brightness>0</brightness>
    <gamma>1</gamma>
    <contrast>0</contrast>
    <grayscale>false</grayscale>
    <compression>Any</compression>
    <minscalevisible>100</minscalevisible>
    <maxscalevisible>128000000</maxscalevisible>
    <datasource>
      <mapsignature>wms</mapsignature>
      <maptype>WmsMap</maptype>
      <hostcategory>DontCare</hostcategory>
      <showlabels>false</showlabels>
      <usecache>false</usecache>
    </datasource>
    <visible>true</visible>
    <property key="serviceType" value="OpenstreetMap" />
    <property key="osMapStyle" value="Standard" />
  </layer>
  </compositemaptemplate>

Then add templatefilters in basemap-templates to reference maplayers or datasources in overlay-templates.

Either example 1:

<compositemaptemplate name="testTemplateRef" id="5497D2A9-25C6-429B-AA9A-0ADAB98721C0">
  <!-- reference all layers in overlays tagged with groundraster and seaoverlay-->
  <templatefilter refs="groundraster, seaoverlay"/> 
</compositemaptemplate>

or example 2 (only available since Maria GDK 3.1.1(?)):

<compositemaptemplate name="TestDatasourceRef" id="5497D2A9-25C6-429B-AA9A-0ADAB98721C0">
  <layer type="MapLayer" name="Groundrasters"> 
    <.../>
    <datasource>
      <!-- reference all overlays tagged with groundraster but include only datasource information -->
      <templatefilter refs="groundraster"/> 
    </datasource>
    <visible>true</visible> 
  </layer>
</compositemaptemplate>


When Maria GDK is loading the basemaptemplate - all available overlay-templates with a referenced tag will be included. Templatefilters located outside the layer-block(s) (example 1) will include all maplayers from the referenced overlays. Templatefilters located inside the datasource-block (example 2) will include only the datasouce-blocks (from the referenced overlays).

Overlay-templates will also provide a prioritynumber used for sorting the overlay-templates when including them in the basemap. Lower number equals higher priority. Default value is 100.

Map layers specified directly in the basemap-template will always be placed first in the completed maptemplate and thus drawn first (lowest priority layers). The ordering of map layers internally in an overlay-template will not be disturbed when included into a basemap via tag references.