Esempio n. 1
0
        /*** Statics ********************************************************/
        static bool getTerrainData(Terrain terrain,
            out osg.Node out_terrain_node,
            out SpatialReference out_terrain_srs,
            out GeoExtent out_terrain_extent)
        {
            if (terrain != null)
            {
                if (!string.IsNullOrEmpty(terrain.getURI()))
                {
                    out_terrain_node = osgDB.readNodeFile(terrain.getAbsoluteURI());
                }

                // first check for an explicity defined SRS:
                out_terrain_srs = terrain.getExplicitSRS();
                if (out_terrain_srs != null && out_terrain_srs.isGeographic())
                {
                    // and make it geocentric if necessary..
                    out_terrain_srs = Registry.SRSFactory().createGeocentricSRS(out_terrain_srs.get());
                }

                if (out_terrain_node != null)
                {
                    // if the SRS wasn't explicit, try to read it from the scene graph:
                    if (out_terrain_srs == null)
                    {
                        out_terrain_srs = Registry.SRSFactory().createSRSfromTerrain(out_terrain_node.get());
                    }

                    //osgGIS.notice()
                    //    << "Loaded TERRAIN from \"" << terrain.getAbsoluteURI() << "\", SRS = "
                    //    << (out_terrain_srs != null? out_terrain_srs.getName() : "unknown")
                    //    << std.endl;
                }

                else if (!string.IsNullOrEmpty(terrain.getURI()))
                {
                    //osgGIS.warn()
                    //    << "Unable to load data for terrain \""
                    //    << terrain.getName() << "\"."
                    //    << std.endl;

                    return false;
                }
            }

            out_terrain_extent = new GeoExtent(-180, -90, 180, 90,
                                    Registry.instance().getSRSFactory().createWGS84());

            return true;
        }