<!--
osgEarth Sample.

Demonstrates the use of a Resource Library in order to apply "typical" textures
to extruded buildings.
WIP - using data from https://overturemaps.org/
overturemaps download --bbox=-71.10592,42.319368,-71.004468,42.37386 -f geojson --type=building -o boston_buildings.geojson
overturemaps download --bbox=-71.10592,42.319368,-71.004468,42.37386 -f geojson --type=land -o boston_land.geojson
overturemaps download --bbox=-71.10592,42.319368,-71.004468,42.37386 -f geojson --type=infrastructure -o boston_infrastructure.geojson

-->

<map name="Boston Demo">
    
    <TMSImage name="Imagery">
        <url>https://readymap.org/readymap/tiles/1.0.0/22/</url>
    </TMSImage>
    
    <xi:include href="readymap_elevation.xml"/>
      
    <FeatureModel name="Buildings" max_range="20000" pickable="true">
         
        <OGRFeatures name="buildings">
            <url>../data/boston_buildings.geojson</url>
        </OGRFeatures>
        
        <!--
         ! The "layout" element activates tiling and paging of the feature set. If you
         ! omit the layout element, the entire feature set will render as one pre-loaded
         ! model (no tiling or paging).
         !  
         ! Each "level" is a level of detail for features, and should select a style
         ! to use for that level. It also can specify min and max camera ranges, in meters.
         -->
        
        <layout tile_size="500">
            <level name="default" max_range="20000" style="buildings"/>
        </layout>
        
        <styles>
            <library name="us_resources">
                <url>../data/resources/textures_us/catalog.xml</url>
            </library>
            
            <style type="text/css">
                buildings {
                    extrusion-height:        Math.max(feature.properties.height, 3);
                    extrusion-flatten:       true;
                    extrusion-wall-style:    building-wall;
                    extrusion-wall-gradient: 0.5;
                    extrusion-roof-style:    building-rooftop;
                    altitude-clamping:       terrain;
                    altitude-technique:      map;
                    altitude-binding:        vertex;
                }            
                building-wall {
                    skin-library:     us_resources;
                    skin-tags:        building;
                    skin-random-seed: 1;
                }
                building-rooftop {
                    skin-library:     us_resources;
                    skin-tags:        rooftop;
                    skin-tiled:       true;
                    skin-random-seed: 1;
                }
            </style>
        </styles>   
    </FeatureModel>
    
    
    <FeatureModel name="Streets" features="streets-data">
        <layout crop_features="true" tile_size="1000">
            <level max_range="5000"/>
        </layout>        
        <styles>
            <style type="text/css">
                default {
                    stroke:                       #131313;
                    stroke-width:                 7.5m;
                    stroke-linejoin:              round;
                    stroke-linecap:               round;
                    altitude-clamping:            terrain;
                    render-depth-offset-min-bias: 3.6;
                    render-transparent:           true;
                }
            </style>
        </styles>        
    </FeatureModel>
	    
    <OGRFeatures name="land_points">
        <url>../data/boston_land.geojson</url>
    </OGRFeatures>
               
    <FeatureModel name="land_points" features="land_points">                
        <styles>
            <style type="text/css">
                land_points {
                   select: feature.properties.class === 'tree';				
                   model: "../data/loopix/tree4.osgb";
				   model-scale:            0.15 + 0.1*Math.random();				   
                   altitude-clamping:      terrain;
                   render-transparent:     true;
				   render-min-alpha:       0.15;
                }                                            
            </style>
        </styles>        
    </FeatureModel>
	
    <OGRFeatures name="infra_points">
        <url>../data/boston_infrastructure.geojson</url>
    </OGRFeatures>	

    <FeatureModel name="infra_points" features="infra_points">        
        <layout tile_size="1000">
            <level max_range="500"/>
        </layout>	
        <styles>
            <style type="text/css">
                infra_points {
				   model-scale:            1;				   
                   altitude-clamping:      terrain;
				}
                bench : infra_points {
                   select: feature.properties.class === 'bench';				
                   model: "../data/bench.osgb";
                }			
                post_box : infra_points {
                   select: feature.properties.class === 'post_box';				
                   model: "../data/post_box.osgb";
                }	
                recycling : infra_points {
                   select: feature.properties.class === 'recycling';				
                   model: "../data/recycling.osgb";
                }		
                street_lamp : infra_points {
                   select: feature.properties.class === 'street_lamp';				
                   model: "../data/street_lamp.osgb";
                }	
                waste_basket : infra_points {
                   select: feature.properties.class === 'waste_basket';				
                   model: "../data/waste_basket.osgb";
                }	
                traffic_signals : infra_points {
                   select: feature.properties.class === 'traffic_signals';	
				   model-heading:          40;				   
                   model: "../data/traffic_signals.osgb";
                }					
            </style>
        </styles>        
    </FeatureModel>
    
    <viewpoints time="1.0" home="0">
        <viewpoint name="Boston Overview" heading="24.261" height="0" lat="42.34425" long="-71.076262" pitch="-21.6" range="3450"/>
        <viewpoint name="Boston Downtown 0" heading="26.3875" range="240m" lat="42.35727" long="-71.064521" pitch="-13.5" height="0"/>
        <viewpoint name="Boston Downtown 1" heading="117" lat="42.3568" long="-71.0585" height="0" pitch="-20.4" range="1500" />
        <viewpoint name="Boston Downtown 2" heading="-128.5" lat="42.3582" long="-71.0546" height="0" pitch="-19" range="1620" />
        <viewpoint name="Boston Street Level" heading="-145.64081" lat="42.364015" long="-71.054149" pitch="-9.701" range="144.95"/>
    </viewpoints>
  
    
    <OGRFeatures name="streets-data">
        <url>../data/boston-scl-utm19n-meters.shp</url>
        <filters>
            <resample min_length="25" max_length="25"/>
        </filters>
    </OGRFeatures>
    
</map>
