osgEarth 2.1.1
|
Public Member Functions | |
ArcGISSource (const TileSourceOptions &options) | |
void | initialize (const std::string &referenceURI, const Profile *overrideProfile) |
int | getPixelsPerTile () const |
osg::Image * | createImage (const TileKey &key, ProgressCallback *progress) |
osg::HeightField * | createHeightField (const TileKey &key, ProgressCallback *progress) |
virtual std::string | getExtension () const |
Private Attributes | |
const ArcGISOptions | _options |
optional< ProfileOptions > | _profileConf |
std::string | _map |
std::string | _layer |
std::string | _format |
MapService | _map_service |
Definition at line 42 of file ReaderWriterArcGIS.cpp.
ArcGISSource::ArcGISSource | ( | const TileSourceOptions & | options | ) | [inline] |
Definition at line 45 of file ReaderWriterArcGIS.cpp.
: TileSource( options ), _options( options ), _profileConf( ProfileOptions() ) { //if ( options ) //{ // const Config& conf = options->config(); // // this is the ArcGIS REST services URL for the map service, // // e.g. http://server/ArcGIS/rest/services/Layer/MapServer // _url = conf.value( PROPERTY_URL ); // // force a profile type // // TODO? do we need this anymore? doesn't this happen with overrideprofile now? // if ( conf.hasChild( PROPERTY_PROFILE ) ) // _profileConf = ProfileOptions( conf.child( PROPERTY_PROFILE ) ); //} //TODO: allow single layers vs. "fused view" if ( _layer.empty() ) _layer = "_alllayers"; // default to the AGS "fused view" //TODO: detect the format if ( _format.empty() ) _format = "png"; URI url = _options.url().value(); //Add the token if necessary if (_options.token().isSet()) { std::string token = _options.token().value(); if (!token.empty()) { std::string sep = url.full().find( "?" ) == std::string::npos ? "?" : "&"; url = url.append( sep + "token=" + token ); } } // read metadata from the server if ( !_map_service.init( url.full() ) ) //, getOptions()) ) { OE_WARN << "[osgearth] [ArcGIS] map service initialization failed: " << _map_service.getError() << std::endl; } }
osg::HeightField* ArcGISSource::createHeightField | ( | const TileKey & | key, |
ProgressCallback * | progress | ||
) | [inline, virtual] |
Creates a heightfield for the given TileKey The returned object is new and is the responsibility of the caller.
Reimplemented from osgEarth::TileSource.
Definition at line 214 of file ReaderWriterArcGIS.cpp.
{ //TODO return NULL; }
osg::Image* ArcGISSource::createImage | ( | const TileKey & | key, |
ProgressCallback * | progress | ||
) | [inline, virtual] |
Creates an image for the given TileKey. The returned object is new and is the responsibility of the caller.
Implements osgEarth::TileSource.
Definition at line 155 of file ReaderWriterArcGIS.cpp.
{ std::stringstream buf; int level = key.getLevelOfDetail(); unsigned int tile_x, tile_y; key.getTileXY( tile_x, tile_y ); std::string f = _map_service.getTileInfo().getFormat(); std::transform( f.begin(), f.end(), f.begin(), tolower ); if ( f.length() > 3 && f.substr( 0, 3 ) == "png" ) f = "png"; if ( _map_service.isTiled() ) { buf << _options.url()->full() << "/tile" << "/" << level << "/" << tile_y << "/" << tile_x << "." << f; } else { const GeoExtent& ex = key.getExtent(); buf << std::setprecision(16) << _options.url()->full() << "/export" << "?bbox=" << ex.xMin() << "," << ex.yMin() << "," << ex.xMax() << "," << ex.yMax() << "&format=" << f << "&size=256,256" << "&transparent=true" << "&f=image" << "&" << "." << f; } //Add the token if necessary if (_options.token().isSet()) { std::string token = _options.token().value(); if (!token.empty()) { std::string sep = buf.str().find( "?" ) == std::string::npos ? "?" : "&"; buf << sep << "token=" << token; } } //OE_NOTICE << "Key = " << key->str() << ", URL = " << buf.str() << std::endl; //return osgDB::readImageFile( buf.str(), getOptions() ); //return HTTPClient::readImageFile( buf.str(), getOptions(), progress ); osg::ref_ptr<osg::Image> image; std::string bufStr; bufStr = buf.str(); HTTPClient::readImageFile( bufStr, image, 0L, progress ); //getOptions(), progress ); return image.release(); }
virtual std::string ArcGISSource::getExtension | ( | ) | const [inline, virtual] |
Gets the preferred extension for this TileSource
Reimplemented from osgEarth::TileSource.
Definition at line 222 of file ReaderWriterArcGIS.cpp.
{ return _format; }
int ArcGISSource::getPixelsPerTile | ( | ) | const [inline, virtual] |
Gets the number of pixels per tile for this TileSource.
Reimplemented from osgEarth::TileSource.
Definition at line 149 of file ReaderWriterArcGIS.cpp.
{ return _map_service.getTileInfo().getTileSize(); }
void ArcGISSource::initialize | ( | const std::string & | referenceURI, |
const Profile * | overrideProfile | ||
) | [inline, virtual] |
Initialize the TileSource. The profile should be computed and set here using setProfile()
Implements osgEarth::TileSource.
Definition at line 93 of file ReaderWriterArcGIS.cpp.
{ const Profile* profile = NULL; if ( _profileConf.isSet() ) { profile = Profile::create( _profileConf.get() ); } else if (overrideProfile) { profile = overrideProfile; } //if ( !_profile_str.empty() ) //{ // profile = Profile::create( _profile_str ); //} else if ( _map_service.getProfile() ) { profile = _map_service.getProfile(); /* if ( !_map_service.isTiled() ) { // expand the profile's extents so they form a square. // AGS will return an image of a different extent than requested if the pixel aspect // ratio is not the same at the geoextent aspect ratio. By forcing a square full extent, // we can always request square tiles. const GeoExtent& oldEx = profile->getExtent(); if ( oldEx.width() > oldEx.height() ) { double d = oldEx.width() - oldEx.height(); unsigned int tilesX, tilesY; profile->getNumTiles( 0, tilesX, tilesY ); profile = Profile::create( profile->getSRS(), oldEx.xMin(), oldEx.yMin()-d/2, oldEx.xMax(), oldEx.yMax()+d/2, 0L, tilesX, tilesY ); } else if ( oldEx.width() < oldEx.height() ) { double d = oldEx.height() - oldEx.width(); unsigned int tilesX, tilesY; profile->getNumTiles( 0, tilesX, tilesY ); profile = Profile::create( profile->getSRS(), oldEx.xMin()-d/2, oldEx.yMin(), oldEx.xMax()+d/2, oldEx.yMax(), 0L, tilesX, tilesY ); } } */ } else { profile = osgEarth::Registry::instance()->getGlobalGeodeticProfile(); } //Set the profile setProfile( profile ); }
std::string ArcGISSource::_format [private] |
Definition at line 232 of file ReaderWriterArcGIS.cpp.
std::string ArcGISSource::_layer [private] |
Definition at line 231 of file ReaderWriterArcGIS.cpp.
std::string ArcGISSource::_map [private] |
Definition at line 230 of file ReaderWriterArcGIS.cpp.
MapService ArcGISSource::_map_service [private] |
Definition at line 233 of file ReaderWriterArcGIS.cpp.
const ArcGISOptions ArcGISSource::_options [private] |
Reimplemented from osgEarth::TileSource.
Definition at line 228 of file ReaderWriterArcGIS.cpp.
optional<ProfileOptions> ArcGISSource::_profileConf [private] |
Definition at line 229 of file ReaderWriterArcGIS.cpp.