<!--
osgEarth Sample

This one demonstrates how to generate inline styles using JavaScript 
and a custom selector. 
-->

<map name="Demo: inline scripted styling">

    <GDALImage name="world">
        <url>../data/world.tif</url>
    </GDALImage>
    
    <OGRFeatures name="country-data">
        <url>../data/world.shp</url>
        <filters>
            <buffer distance="-0.05"/>
        </filters>
    </OGRFeatures>
    
    <TiledFeatureModel name="countries" features="country-data">
        <styles>            
            <script language="javascript">
            <![CDATA[       
                // generated by Color::createRandomColorRamp()
                var g_colors = [
                    '#3d9085ff','#ad3f9bff','#62af07ff','#2a59e7ff',
                    '#c8251dff','#27ca5dff','#8750a7ff','#dcd36cff',
                    '#1f88a3ff','#a90a59ff','#2bcd00ff','#2b2193ff',
                    '#fc8b47ff','#0ebc82ff','#e24be8ff','#668212ff' ];
                
                var g_styles = [ ];                
                
                function init() {                
                    for(var i=0; i<g_colors.length; ++i) {
                        g_styles.push( "{fill:" + g_colors[i] + "; render-depth-test: false; render-clip-plane: 0;}"); //altitude-clamping:terrain-drape;}");
                    }
                }
                init();
            ]]>
            </script>
            
            <selector style_expr="g_styles[feature.id % g_colors.length]"/>
        </styles>        
    </TiledFeatureModel>
    
</map>
