osgEarth 2.1.1

/home/cube/sources/osgearth/src/applications/osgearth_earthfile/osgearth_earthfile.cpp

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003 * Copyright 2008-2010 Pelican Mapping
00004 * http://osgearth.org
00005 *
00006 * osgEarth is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU Lesser General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU Lesser General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU Lesser General Public License
00017 * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018 */
00019 
00020 #include <osg/ArgumentParser>
00021 #include <osgDB/ReadFile>
00022 #include <osgDB/WriteFile>
00023 
00024 #include <osgEarth/EarthFile>
00025 
00026 #include <iostream>
00027 
00028 using namespace osgEarth;
00029 
00033 int main(int argc, char** argv)
00034 {
00035     if ( argc != 3 ) {
00036         OE_NOTICE << "Usage: osgearth_earthfile <inputfile> <outputfile>" << std::endl;
00037         return -1;
00038     }
00039 
00040     std::string infile( argv[1] );
00041     std::string outfile( argv[2] );
00042 
00043     // read in the earth file:
00044     EarthFile earthReader;
00045     if ( earthReader.readXML( infile ) )
00046     {
00047         osg::ref_ptr<Map> map = earthReader.getMap();
00048         MapNodeOptions mapOptions = earthReader.getMapNodeOptions();
00049 
00050         // now write it back out
00051         EarthFile earthWriter;
00052         earthWriter.setMap( map.get() );
00053         earthWriter.setMapNodeOptions( mapOptions );
00054 
00055         if ( !earthWriter.writeXML( outfile ) ) {
00056             OE_NOTICE 
00057                 << "ERROR: unable to write earth file to " << outfile << std::endl;
00058             return -1;
00059         }
00060     }
00061     else
00062     {
00063         OE_NOTICE
00064             << "ERROR: unable to read earth file from " << infile << std::endl;
00065         return -1;
00066     }
00067 
00068     return 0;
00069 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines