<!--
osgEarth Sample

This one demonstrates how to read feature data from a shapefile and "drape" it
on the map using a stenciling technique. This technique is more compute-intensive
than the overlay technique, but it is much more flexible and it works in a 
whole-earth environment.

This demo loads a shapefile of the world, and colors each country based
on its population count using feature style classes.

Note the use of the XML CDATA tag in the expressions. This is only required if
you use XML special characters in the expression (in this case, the less-than
and greater-than symbols). CDATA "escapes out" of XML parsing within the CDATA
block.
-->

<map name="Feature Stencil Demo" type="geocentric" version="2">
    
    <options lighting="false"/>

    <image name="world" driver="gdal">
        <url>../data/world.tif</url>
    </image>
    
    <model name="countries" driver="feature_stencil">

        <!-- Configure the OGR feature driver to read the shapefile.
             Applying a slight negative buffer will "erode" the
             shapes, highlighting the borders between countries. -->
                          
        <features name="states" driver="ogr">
            <url>../data/world.shp</url>
            <ogr_driver>ESRI Shapefile</ogr_driver>
            <buffer distance="-0.05"/>
        </features>
        
        <!-- Since some countries span large areas on the globe, we need to
             use a larger-than-normal extrusion distance on the stencil
             volumes. (300000 is the default for a geocentric map.) -->
             
        <extrusion_distance>400000</extrusion_distance>
        
        <!-- Define a feature style class for each category: -->
        
        <styles>
        
            <style type="text/css">
                p1 {
                   fill: #ffff80;
                   fill-opacity: 0.4;
                }       
                p2 {
                   fill: #fad155;
                   fill-opacity: 0.4;
                }   
                p3 {
                   fill: #f2a82f;
                   fill-opacity: 0.4;
                }       
                p4 {
                   fill: #b3520d;
                   fill-opacity: 0.4;
                }     
                p5 {
                   fill: #6a0000;
                   fill-opacity: 0.4;
                }                                      
            </style>
        
            <selector name="p1">
                <query>
                    <expr><![CDATA[ POP_CNTRY <= 14045470 ]]></expr>
                </query>
            </selector>
        
            <selector name="p2">
                <query>
                    <expr><![CDATA[ POP_CNTRY > 14045470 and POP_CNTRY <= 43410900 ]]></expr>
                </query>
            </selector>
            
            <selector name="p3">
                <query>
                    <expr><![CDATA[ POP_CNTRY > 43410900 and POP_CNTRY <= 97228750 ]]></expr>
                </query>
            </selector>
            
            <selector name="p4">
                <query>
                    <expr><![CDATA[ POP_CNTRY > 97228750 and POP_CNTRY <= 258833000 ]]></expr>
                </query>
            </selector>
            
            <selector name="p5">
                <query>
                    <expr><![CDATA[ POP_CNTRY > 258833000 ]]></expr>
                </query>
            </selector>
            
        </styles>
        
    </model>
</map>
