|
OGR_SpatialReferenceFactory::createSRSfromTerrain( osg::Node* node )
{
SpatialReference* result = NULL;
struct CSNodeVisitor : public osg::NodeVisitor {
osg::CoordinateSystemNode* result;
CSNodeVisitor() : osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ), result(NULL) { }
void apply( osg::CoordinateSystemNode& csnode ) {
result = &csnode;
//no traverse; end when found
}
};
if ( node )
{
CSNodeVisitor v;
node->accept( v );
if ( v.result )
{
if ( v.result->getFormat() == "WKT" )
result = createSRSfromWKT( v.result->getCoordinateSystem() );
else if ( v.result->getFormat() == "PROJ4" )
result = createSRSfromPROJ4( v.result->getCoordinateSystem() );
else if ( v.result->getFormat() == "ESRI" )
result = createSRSfromESRI( v.result->getCoordinateSystem() );
// OSG-hack:
// if the CS node has a lat/lon SRS, AND the terrain has a non-null
// ellipsoid model set, it's really a geocentric model based on that SRS.
if ( result->isGeographic() && v.result->getEllipsoidModel() != NULL )
{
result = createGeocentricSRS( result );
}
}
}
return result;
}
用的是 boston-sample 的project
具体的内容:
<?xml version="1.0" ?>
<project name="boston-sample">
<terrain name="default">
<uri>D:/OSGRun/OSGGIS/boston-sample/terrain/out.ive</uri>
</terrain>
<source name="roads">
<uri>D:/OSGRun/OSGGIS/boston-sample/source/boston-scl-utm19n-meters.shp</uri>
</source>
<graph name="roads">
<filter type="Crop"/>
<filter type="Transform">
<property name="use_terrain_srs" value="true"/>
<property name="localize" value="true"/>
</filter>
<filter type="Clamp"/>
<filter type="BuildGeom">
<property name="color" value="vec4(1,1,1,1)"/>
</filter>
<filter type="Collect"/>
<filter type="BuildNodes">
<property name="disable_lighting" value="true"/>
</filter>
</graph>
<layer name="roads" type="simple" source="roads" terrain="default" target="D:/OSGRun/OSGGIS/boston-sample/terrain/out.ive">
<slice min_range="0" max_range="1e10" graph="roads"/>
</layer>
<source name="buildings">
<uri>D:/OSGRun/OSGGIS/boston-sample/source/boston-buildings-downtown-utm19n-meters.shp</uri>
</source>
<script language="lua">
function color_by_height(f)
stories = f:getAttribute("story_ht_"):asDouble()
stories = math.max( 1.0, stories )
f = math.min( stories/45.0, 1.0 )
return vec4( 1, 1.0-f, f, 1.0 )
end
function select_by_centroid(f,env)
return env:getExtent():contains(f:getExtent():getCentroid())
end
function get_stories(f)
h = f:getAttribute("story_ht_"):asDouble()
return math.max( 1.0, h )
end
</script>
<resource name="tif" type="raster">
<uri>D:/OSGRun/OSGGIS/boston-sample/source/boston-10m-utm19n-meters.tif</uri>
</resource>
<graph name="buildings">
<filter type="Select">
<property name="select" value="select_by_centroid(feature,env)"/>
</filter>
<filter type="RecalculateExtent"/>
<filter type="Transform">
<property name="use_terrain_srs" value="true"/>
<property name="localize" value="true"/>
</filter>
<filter type="Clamp"/>
<filter type="ExtrudeGeom">
<property name="color" value="color_by_height(feature)"/>
<property name="height" value="get_stories(feature)*3.2"/>
</filter>
<filter type="Collect"/>
<filter type="BuildNodes"/>
</graph>
<layer name="buildings" type="gridded" source="buildings" terrain="default" target="D:/OSGRun/OSGGIS/boston-sample/out/out.ive">
<property name="row-size" value="1000"/>
<property name="col-size" value="1000"/>
<property name="inline-textures" value="false"/>
<property name="localize-resources" value="true"/>
<property name="compress-textures" value="true"/>
<property name="paged" value="true"/>
<slice min_range="0" max_range="1e5" graph="buildings"/>
</layer>
<!-- Map for osggis_mapper -->
<map name="default" terrain="default">
<maplayer layer="roads"/>
<maplayer layer="buildings" searchable="true"/>
</map>
</project>
|
-
|