osgEarth 2.1.1
|
Static Public Member Functions | |
static WFSCapabilities * | read (const std::string &location, const osgDB::ReaderWriter::Options *options) |
static WFSCapabilities * | read (std::istream &in) |
Private Member Functions | |
WFSCapabilitiesReader () | |
WFSCapabilitiesReader (const WFSCapabilitiesReader &cr) |
osgEarth::Util::WFSCapabilitiesReader::WFSCapabilitiesReader | ( | ) | [inline, private] |
osgEarth::Util::WFSCapabilitiesReader::WFSCapabilitiesReader | ( | const WFSCapabilitiesReader & | cr | ) | [inline, private] |
WFSCapabilities * WFSCapabilitiesReader::read | ( | const std::string & | location, |
const osgDB::ReaderWriter::Options * | options | ||
) | [static] |
Definition at line 76 of file WFS.cpp.
{ WFSCapabilities *caps = NULL; if ( osgDB::containsServerAddress( location ) ) { HTTPResponse response = HTTPClient::get( location, options ); if ( response.isOK() && response.getNumParts() > 0 ) { caps = read( response.getPartStream( 0 ) ); } } else { if ((osgDB::fileExists(location)) && (osgDB::fileType(location) == osgDB::REGULAR_FILE)) { std::ifstream in( location.c_str() ); caps = read( in ); } } return caps; }
WFSCapabilities * WFSCapabilitiesReader::read | ( | std::istream & | in | ) | [static] |
Definition at line 99 of file WFS.cpp.
{ osg::ref_ptr<WFSCapabilities> capabilities = new WFSCapabilities; osg::ref_ptr<XmlDocument> doc = XmlDocument::load( in ); if (!doc.valid() || doc->getChildren().empty()) { OE_NOTICE << "Failed to load Capabilities " << std::endl; return 0; } //Get the Capabilities version osg::ref_ptr<XmlElement> e_root = static_cast<XmlElement*>(doc->getChildren()[0].get()); capabilities->setVersion( e_root->getAttr(ATTR_VERSION ) ); osg::ref_ptr<XmlElement> e_service = e_root->getSubElement( ELEM_SERVICE ); if (!e_service.valid()) { OE_NOTICE << "Could not find Service element" << std::endl; return 0; } //Read the parameters from the Service block capabilities->setName( e_service->getSubElementText(ELEM_NAME ) ); capabilities->setAbstract( e_service->getSubElementText( ELEM_ABSTRACT ) ); capabilities->setTitle( e_service->getSubElementText( ELEM_TITLE ) ); //Read all the feature types osg::ref_ptr<XmlElement> e_feature_types = e_root->getSubElement( ELEM_FEATURETYPELIST ); if (e_feature_types.valid()) { XmlNodeList featureTypes = e_feature_types->getSubElements( ELEM_FEATURETYPE ); for( XmlNodeList::const_iterator itr = featureTypes.begin(); itr != featureTypes.end(); itr++ ) { XmlElement* e_featureType = static_cast<XmlElement*>( itr->get() ); WFSFeatureType* featureType = new WFSFeatureType(); featureType->setName( e_featureType->getSubElementText( ELEM_NAME ) ); featureType->setTitle( e_featureType->getSubElementText( ELEM_TITLE ) ); featureType->setAbstract( e_featureType->getSubElementText( ELEM_ABSTRACT ) ); //NOTE: TILED and MAXLEVEL aren't part of the WFS spec, these are enhancements to our server for tiled WFS access std::string tiledStr = e_featureType->getSubElementText(ELEM_TILED); if (tiledStr.compare("") != 0) { featureType->setTiled( as<bool>(tiledStr, false) ); } std::string maxLevelStr = e_featureType->getSubElementText(ELEM_MAXLEVEL); if (maxLevelStr.compare("") != 0) { featureType->setMaxLevel( as<int>(maxLevelStr, -1)); } std::string firstLevelStr = e_featureType->getSubElementText(ELEM_FIRSTLEVEL); if (firstLevelStr.compare("") != 0) { featureType->setFirstLevel( as<int>(firstLevelStr, 0)); } osg::ref_ptr<XmlElement> e_bb = e_featureType->getSubElement( ELEM_LATLONGBOUNDINGBOX ); if (e_bb.valid()) { double minX, minY, maxX, maxY; minX = as<double>(e_bb->getAttr( ATTR_MINX ), 0); minY = as<double>(e_bb->getAttr( ATTR_MINY ), 0); maxX = as<double>(e_bb->getAttr( ATTR_MAXX ), 0); maxY = as<double>(e_bb->getAttr( ATTR_MAXY ), 0); featureType->setExtent( GeoExtent(SpatialReference::create( "epsg:4326"), minX, minY, maxX, maxY)); } capabilities->getFeatureTypes().push_back( featureType ); } } return capabilities.release(); }