osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/wms/TileService

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/Referenced>
00021 #include <osg/Vec2d>
00022 
00023 #include <osgEarth/Profile>
00024 
00025 #include <string>
00026 #include <vector>
00027 
00028 
00041 class TilePattern
00042 {
00043 public:
00044     TilePattern(const std::string &pattern);
00045 
00046     const std::string& getPattern() const {return _pattern;}
00047 
00048     const double& getTileWidth() const { return _tileWidth; }
00049     const double& getTileHeight() const { return _tileHeight; }
00050 
00051     void getTileBounds(const int &x, const int &y, double &minX, double &minY, double &maxX, double &maxY);
00052     std::string getRequestString(const int &x, const int &y);
00053 
00054     const std::string& getLayers() {return _layers;}
00055     const std::string& getFormat() {return _format;}
00056     const std::string& getStyles() {return _styles;}
00057     const std::string& getSRS() {return _srs;}
00058 
00059     const osg::Vec2d& getTopLeftMin() {return _topLeftMin;}
00060     const osg::Vec2d& getTopLeftMax() {return _topLeftMax;}
00061 
00062     
00063     const int& getImageWidth() {return _imageWidth;}
00064     const int& getImageHeight() {return _imageHeight;}
00065 
00066     const std::string& getPrototype() {return _prototype;}
00067 
00068     const osg::Vec2d &getDataMin() {return _dataMin;}
00069     void setDataMin(const osg::Vec2d &min) {_dataMin = min;}
00070 
00071     const osg::Vec2d &getDataMax() {return _dataMax;}
00072     void setDataMax(const osg::Vec2d &max) {_dataMax = max;}
00073 
00074 private:
00075     friend class TileServiceReader;
00076 
00077     void init();
00078 
00079     std::string _layers;
00080     std::string _format;
00081     std::string _styles;
00082     std::string _srs;
00083     int _imageWidth;
00084     int _imageHeight;
00085 
00086     osg::Vec2d _topLeftMin;
00087     osg::Vec2d _topLeftMax;
00088 
00089     double _tileWidth;
00090     double _tileHeight;
00091 
00092     std::string _prototype;
00093     std::string _pattern;
00094 
00095     osg::Vec2d _dataMin;
00096     osg::Vec2d _dataMax;
00097 };
00098 
00099 class TileService : public osg::Referenced
00100 {
00101 public:
00102     TileService();
00103 
00105     typedef std::vector<TilePattern> TilePatternList;
00106 
00108     TilePatternList& getPatterns() {return _patterns;}
00109 
00113     const std::string& getName() {return _name;}
00114 
00118     void setName(const std::string& name) {_name = name;}
00119 
00123     const std::string& getTitle() {return _title;}
00124 
00128     void setTitle(const std::string& title) {_title = title;}
00129 
00133     const std::string& getAbstract() {return _abstract;}
00134 
00138     void setAbstract(const std::string& value) {_abstract = value;}
00139 
00143     const std::string& getVersion() {return _version;}
00144 
00148     void setVersion(const std::string& version) {_version = version;}
00149 
00153     const std::string& getAccessConstraints() {return _accessConstraints;}
00154 
00158     void setAccessConstraints(const std::string& accessConstraints) {_accessConstraints = accessConstraints;}
00159 
00163     const osg::Vec2d &getDataMin() {return _dataMin;}
00164 
00168     void setDataMin(const osg::Vec2d &min) {_dataMin = min;}
00169 
00173     const osg::Vec2d &getDataMax() {return _dataMax;}
00174 
00178     void setDataMax(const osg::Vec2d &max) {_dataMax = max;}
00179 
00180 
00198     void getMatchingPatterns(const std::string &layers, const std::string &format,
00199                              const std::string &styles, const std::string &srs,
00200                              unsigned int imageWidth, unsigned int imageHeight,
00201                              TilePatternList &out_patterns);
00202 
00206     const osgEarth::Profile* createProfile(TilePatternList &patterns);
00207 
00208 private:
00209     std::string _name;
00210     std::string _title;
00211     std::string _abstract;
00212     std::string _version;
00213     std::string _accessConstraints;
00214 
00215     osg::Vec2d _dataMin;
00216     osg::Vec2d _dataMax;
00217 
00218     std::vector<TilePattern> _patterns;
00219 };
00220 
00221 
00222 /*
00223  * Reads a TileService from a URL or file
00224  */
00225 class TileServiceReader
00226 {
00227 public:
00228     static TileService* read( const std::string &location, const osgDB::ReaderWriter::Options* options);
00229     static TileService* read( std::istream &in );
00230 private:
00231     TileServiceReader(){}
00232     TileServiceReader(const TileServiceReader &tsr){}
00233 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines