<loading_policy> Element

This element controls how the osgEarth engine loads tile data.

Preemptive Mode

By default, osgEarth loads tiles in a traditional manner. That is, it simply uses the OSG database pager to load tiles when they come into view, and then it will subdivide and queue up the subtiles as you zoom in. This works fine for some applications, and for very fast data sources.

osgEarth has a "preemptive" loading scheme that you can enable by using the loading_policy directive. In preemptive mode, osgEarth will prioritize the loading of tile data based on the LOD the scene camera is looking at now. Instead of loading each LOD in sequence until it gets to the highest, it will jump directly to the appropriate LOD and load (and display) those tiles first. This can give the effect of better performance since you don't need to wait for all lower LODs to come in.

In preemptive mode, osgEarth also employs a thread pool to efficiently load-balance the fetching of tile data across all your layers. For example, you can prioritize imagery over elevation data, or one imagery layer over another. Do this by using the loading_weight attribute at the layer level (see examples below).

Attributes

mode Tile loading mode to use: "standard" (the default), "sequential", or "preemptive". optional
loading_threads_per_core Total of tile-loading threads to use per CPU core. Default = 2. This attribute and loading_threads are mutually exclusive. optional
loading_threads Total number of tile-loading threads to use (across all layers). This attribute and the one above are mutually exclusive. optional
compile_threads Number of threads to allocate for building tiles in the background. Once data is loaded (in a loading thread), it is dispatched to a tile generation thread in order to avoid frame drops. Default = 4. optional

Examples

The following loads Blue Marble imagery atop SRTM elevation data, using preemptive mode. We instruct the engine to use 3 background tile-loading threads for each core in the machine.

<map name="srtm sample" type="globe">

  <loading_policy mode="sequential" loading_threads_per_cpu="3" compile_threads="2"/>

  <image name="pelican nasa blue marble" driver="tms">
      <url>http://demo.pelicanmapping.com/rmweb/data/bluemarble-tms/tms.xml</url>
  </image>
  
  <heightfield name="pelican srtm" driver="tms">
      <url>http://demo.pelicanmapping.com/rmweb/data/srtm30_plus_tms/tms.xml</url>
  </heightfield>
  
</map>

Here's an example of tweaking the load-balancing across multiple layers. Here we are telling the engine to apply 5 times the tile-loading resources to the roads overlay as to the base map imagery. (This sample is in the repo: arc_preemptive.earth) This also demonstrates setting an explicit thread pool size.

<map name="ESRI Imagery and Roads" type="geocentric">        

    <loading_policy mode="preemptive" loading_threads="18"/>

    <image name="arcgisonline esri imagery" driver="arcgis" loading_weight="1">
        <url>http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer</url>
        <nodata_image>http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/100/0/0.jpeg</nodata_image>
    </image>
      
    <image name="arcgisonline transportation" driver="arcgis" loading_weight="5">
        <url>http://server.arcgisonline.com/ArcGIS/rest/services/Reference/ESRI_Transportation_World_2D/MapServer</url>
    </image>

</map>

back to element reference