/usr/share/osgearth/maps/feature_scripting.earth is in osgearth-data 2.4.0+dfsg-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | <!--
osgEarth Sample - Feature Scripting
This example demonstrates the use of scripting to style features.
-->
<map name="Feature Geometry Demo" type="geocentric" version="2">
<options lighting="false"/>
<image name="world" driver="gdal">
<url>/usr/share/osgearth/data/world.tif</url>
</image>
<model name="cities" driver="feature_geom">
<features name="cities" driver="ogr">
<url>/usr/share/osgearth/data/world.shp</url>
</features>
<styles>
<script language="javascript">
/* A global variable within this script block */
var prefix = "";
function initialize()
{
prefix = "This is ";
}
function getName()
{
/* Two objects, feature and context, are globally available in a script.
* feature is the current osgEarth::Features::Feature being styled and
* context is the osgEarth::Features::FilterContext.
*
* See the osgEarth wiki for full documentation.
*/
if (feature.attributes["code"] == "US")
{
var extent = new GeoExtent(context.profile.srs, feature.geometry.bounds);
if (extent != undefined)
{
/* Check if the extent contains the city of Hilo */
if (extent.contains(-155.07, 19.72))
return prefix + "Hawaii";
/* Two extents representing Alaska's bounds to deal with hemisphere crossover */
var alaskaExtent1 = new GeoExtent(context.profile.srs, -180.0, 49.7, -128.3, 72.5);
var alaskaExtent2 = new GeoExtent(context.profile.srs, 171.0, 49.7, 180.0, 72.5);
if (extent.intersects(alaskaExtent1) || extent.intersects(alaskaExtent2))
return prefix + "Alaska";
}
}
return prefix + feature.attributes["cntry_name"];
}
/* This call to initialize will execute when the script is initially processed */
initialize();
</script>
<style type="text/css">
cities {
text-content: getName() + " (" + [code] + ")";
text-priority: [pop_cntry];
text-halo: #3f3f7f;
text-font: arial.ttf;
text-size: 16;
text-remove-duplicate-labels: true;
altitude-clamping: terrain;
}
</style>
</styles>
</model>
</map>
|