/usr/include/osgEarthSplat/LandUseTileSource is in libosgearth-dev 2.9.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_SPLAT_LAND_USE_TILE_SOURCE
#define OSGEARTH_SPLAT_LAND_USE_TILE_SOURCE 1
#include <osgEarth/TileSource>
#include <osgEarth/ImageLayer>
#include <osgEarth/SimplexNoise>
#include <osgDB/FileNameUtils>
#include "Export"
namespace osgEarth { namespace Splat
{
/**
* Configuration options for the land use tile source
*/
class OSGEARTHSPLAT_EXPORT LandUseOptions : public osgEarth::TileSourceOptions
{
public:
LandUseOptions(const osgEarth::TileSourceOptions& options)
: osgEarth::TileSourceOptions(options)
{
setDriver("landuse");
baseLOD().init( 12u );
warpFactor().init( 0.01f );
fromConfig( _conf );
}
public:
/**
* Images layer from which to read source coverage data.
*/
std::vector<ImageLayerOptions>& imageLayerOptionsVector() { return _imageLayerOptionsVec; }
const std::vector<ImageLayerOptions>& imageLayerOptionsVector() const { return _imageLayerOptionsVec; }
/**
* Amount by which to warp texture coordinates of coverage data.
* Try 0.01 as a starting point.
*/
optional<float>& warpFactor() { return _warp; }
const optional<float>& warpFactor() const { return _warp; }
/**
* LOD at which to calculate the noise function for warping.
*/
optional<unsigned>& baseLOD() { return _baseLOD; }
const optional<unsigned>& baseLOD() const { return _baseLOD; }
/**
* Bit size of the encoded data. The default is 32 (for a 32-bit signed
* floating point value) but you can set it to 16 if you know your data
* values are all within the range of a signed 16-bit float.
*/
optional<unsigned>& bits() { return _bits; }
const optional<unsigned>& bits() const { return _bits; }
public:
Config getConfig() const
{
Config conf;
conf.addIfSet("warp", _warp);
conf.addIfSet("base_lod", _baseLOD);
conf.addIfSet("bits", _bits);
// multiple
if ( _imageLayerOptionsVec.size() > 0 )
{
Config images("images");
for(std::vector<ImageLayerOptions>::const_iterator i = _imageLayerOptionsVec.begin();
i != _imageLayerOptionsVec.end();
++i)
{
images.add( "image", i->getConfig() );
}
conf.add( images );
}
return conf;
}
protected:
void mergeConfig( const Config& conf ) {
TileSourceOptions::mergeConfig( conf );
fromConfig( conf );
}
private:
void fromConfig( const Config& conf )
{
conf.getIfSet("warp", _warp);
conf.getIfSet("base_lod", _baseLOD);
conf.getIfSet("bits", _bits);
ConfigSet layerConfs = conf.child("images").children("image");
for(ConfigSet::const_iterator i = layerConfs.begin(); i != layerConfs.end(); ++i)
{
_imageLayerOptionsVec.push_back( ImageLayerOptions(*i) );
}
}
private:
optional<float> _warp;
optional<unsigned> _baseLOD;
optional<unsigned> _bits;
std::vector<ImageLayerOptions> _imageLayerOptionsVec;
};
/**
* Tile source that will read from ANOTHER tile source and perform
* various pre-processing syntheses operations like warping and detailing.
*/
class OSGEARTHSPLAT_EXPORT LandUseTileSource : public osgEarth::TileSource
{
public:
LandUseTileSource(const LandUseOptions& options);
public: // TileSource
// Initialize the tile source.
Status initialize(const osgDB::Options* options);
// Create an image.
osg::Image* createImage(const osgEarth::TileKey& key, osgEarth::ProgressCallback* progress);
CachePolicy getCachePolicyHint() const;
protected:
virtual ~LandUseTileSource() { }
osg::ref_ptr<osgDB::Options> _dbOptions;
LandUseOptions _options;
osg::ref_ptr<ImageLayer> _imageLayer;
ImageLayerVector _imageLayers;
std::vector<float> _warps;
osgEarth::SimplexNoise _noiseGen;
};
/**
* Driver plugin used to load a land use tile source.
*/
class OSGEARTHSPLAT_EXPORT LandUseDriver : public osgEarth::TileSourceDriver
{
public:
LandUseDriver()
{
supportsExtension( "osgearth_landuse", "Land Use Driver" );
}
virtual const char* className() const
{
return "Land Use Driver";
}
virtual ReadResult readObject(const std::string& file_name, const Options* options) const
{
if ( !acceptsExtension(osgDB::getLowerCaseFileExtension( file_name )))
return ReadResult::FILE_NOT_HANDLED;
return new LandUseTileSource( getTileSourceOptions(options) );
}
};
REGISTER_OSGPLUGIN(osgearth_landuse, LandUseDriver);
} } // namespace osgEarth::Splat
#endif // OSGEARTH_SPLAT_LAND_USE_TILE_SOURCE
|