osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/kml/KMZArchive

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 #ifndef OSGEARTH_DRIVER_KML_KMZ_ARCHIVE
00020 #define OSGEARTH_DRIVER_KML_KMZ_ARCHIVE 1
00021 
00022 #ifdef OSGEARTH_HAVE_MINIZIP
00023 #    define SUPPORT_KMZ 1
00024 #endif
00025 
00026 #ifdef SUPPORT_KMZ
00027 
00028 #include <osgDB/Archive>
00029 #include <osgEarth/URI>
00030 #include "unzip.h"  // minizip
00031 
00032 using namespace osgEarth;
00033 
00034 
00035 struct KMZArchive : public osgDB::Archive
00036 {
00037     KMZArchive( const URI& archiveURI );
00038 
00039     virtual ~KMZArchive();
00040 
00042     void close();
00043 
00045     std::string getArchiveFileName() const;
00046 
00048     std::string getMasterFileName() const ;
00049 
00051     bool fileExists(const std::string& filename) const;
00052 
00054     osgDB::FileType getFileType(const std::string& filename) const;
00055 
00056     typedef osgDB::DirectoryContents FileNameList;
00057 
00059     bool getFileNames(FileNameList& fileNames) const;
00060 
00063     osgDB::DirectoryContents getDirectoryContents(const std::string& dirName) const;
00064 
00066     bool readToBuffer( const std::string& fileInZip, std::ostream& iobuf ) const;
00067 
00068     ReadResult readImage(const std::string& filename, const Options* options =NULL) const;
00069 
00070     ReadResult readNode(const std::string& filename, const Options* options =NULL) const;
00071 
00072     ReadResult readObject(const std::string& filename, const Options* options =NULL) const;
00073 
00074     // stubs
00075     ReadResult readShader(const std::string&, const Options* =NULL) const { return ReadResult::NOT_IMPLEMENTED; }
00076     ReadResult readHeightField(const std::string&, const Options* =NULL) const { return ReadResult::NOT_IMPLEMENTED; }
00077     WriteResult writeObject(const osg::Object&, const std::string&,const Options* =NULL) const { return WriteResult::NOT_IMPLEMENTED; }
00078     WriteResult writeImage(const osg::Image&, const std::string&,const Options* =NULL) const { return WriteResult::NOT_IMPLEMENTED; }
00079     WriteResult writeHeightField(const osg::HeightField&,const std::string&,const Options* =NULL) const { return WriteResult::NOT_IMPLEMENTED; }
00080     WriteResult writeNode(const osg::Node&, const std::string&,const Options* =NULL) const { return WriteResult::NOT_IMPLEMENTED; }
00081     WriteResult writeShader(const osg::Shader&, const std::string&, const Options* =NULL) const { return WriteResult::NOT_IMPLEMENTED; }
00082 
00083 private:
00084     URI            _archiveURI;
00085     unzFile        _uf;
00086     void*          _buf;
00087     unsigned       _bufsize;
00088 };
00089 
00090 
00091 #endif // SUPPORT_KMZ
00092 
00093 #endif // OSGEARTH_DRIVER_KML_KMZ_ARCHIVE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines