Skip to content

Commit

Permalink
wms provider:
Browse files Browse the repository at this point in the history
* support JSON for feature info
* implement feature info for WMTS
* cleanup metadata display
  • Loading branch information
jef-n committed Mar 2, 2014
1 parent 6691332 commit d6495ab
Show file tree
Hide file tree
Showing 9 changed files with 772 additions and 434 deletions.
10 changes: 5 additions & 5 deletions python/core/raster/qgsraster.sip
Expand Up @@ -33,11 +33,11 @@ class QgsRaster


enum IdentifyFormat enum IdentifyFormat
{ {
IdentifyFormatUndefined = 0, IdentifyFormatUndefined,
IdentifyFormatValue = 1, // numerical pixel value IdentifyFormatValue,
IdentifyFormatText = 0x2, // WMS text IdentifyFormatText,
IdentifyFormatHtml = 0x4, // WMS HTML IdentifyFormatHtml,
IdentifyFormatFeature = 0x8 // WMS GML -> feature IdentifyFormatFeature,
}; };


// Progress types // Progress types
Expand Down
3 changes: 2 additions & 1 deletion python/core/raster/qgsrasterinterface.sip
Expand Up @@ -41,6 +41,7 @@ class QgsRasterInterface
%End %End


public: public:
//! If you add to this, please also add to capabilitiesString()
enum Capability enum Capability
{ {
NoCapabilities, NoCapabilities,
Expand All @@ -52,7 +53,7 @@ class QgsRasterInterface
IdentifyValue, IdentifyValue,
IdentifyText, IdentifyText,
IdentifyHtml, IdentifyHtml,
IdentifyFeature IdentifyFeature,
}; };


QgsRasterInterface( QgsRasterInterface * input = 0 ); QgsRasterInterface( QgsRasterInterface * input = 0 );
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsproviderregistry.cpp
Expand Up @@ -208,6 +208,7 @@ QgsProviderRegistry::~QgsProviderRegistry()


while ( it != mProviders.end() ) while ( it != mProviders.end() )
{ {
QgsDebugMsg( QString( "cleanup:%1" ).arg( it->first ) );
QString lib = it->second->library(); QString lib = it->second->library();
QLibrary myLib( lib ); QLibrary myLib( lib );
if ( myLib.isLoaded() ) if ( myLib.isLoaded() )
Expand Down
6 changes: 3 additions & 3 deletions src/core/raster/qgsraster.h
Expand Up @@ -53,11 +53,11 @@ class CORE_EXPORT QgsRaster


enum IdentifyFormat enum IdentifyFormat
{ {
IdentifyFormatUndefined = 0, IdentifyFormatUndefined = 0,
IdentifyFormatValue = 1, // numerical pixel value IdentifyFormatValue = 1, // numerical pixel value
IdentifyFormatText = 1 << 1, // WMS text IdentifyFormatText = 1 << 1, // WMS text
IdentifyFormatHtml = 1 << 2, // WMS HTML IdentifyFormatHtml = 1 << 2, // WMS HTML
IdentifyFormatFeature = 1 << 3 // WMS GML -> feature IdentifyFormatFeature = 1 << 3, // WMS GML/JSON -> feature
}; };


// Progress types // Progress types
Expand Down
20 changes: 10 additions & 10 deletions src/core/raster/qgsrasterinterface.h
Expand Up @@ -40,16 +40,16 @@ class CORE_EXPORT QgsRasterInterface
//! If you add to this, please also add to capabilitiesString() //! If you add to this, please also add to capabilitiesString()
enum Capability enum Capability
{ {
NoCapabilities = 0, NoCapabilities = 0,
Size = 1 << 1, // original data source size (and thus resolution) is known, it is not always available, for example for WMS Size = 1 << 1, // original data source size (and thus resolution) is known, it is not always available, for example for WMS
Create = 1 << 2, // create new datasets Create = 1 << 2, // create new datasets
Remove = 1 << 3, // delete datasets Remove = 1 << 3, // delete datasets
BuildPyramids = 1 << 4, // supports building of pyramids (overviews) BuildPyramids = 1 << 4, // supports building of pyramids (overviews)
Identify = 1 << 5, // at least one identify format supported Identify = 1 << 5, // at least one identify format supported
IdentifyValue = 1 << 6, // numerical values IdentifyValue = 1 << 6, // numerical values
IdentifyText = 1 << 7, // WMS text IdentifyText = 1 << 7, // WMS text
IdentifyHtml = 1 << 8, // WMS HTML IdentifyHtml = 1 << 8, // WMS HTML
IdentifyFeature = 1 << 9 // WMS GML -> feature IdentifyFeature = 1 << 9, // WMS GML -> feature
}; };


QgsRasterInterface( QgsRasterInterface * input = 0 ); QgsRasterInterface( QgsRasterInterface * input = 0 );
Expand Down
7 changes: 2 additions & 5 deletions src/gui/qgsmaptoolidentify.cpp
Expand Up @@ -418,14 +418,13 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, QgsPoint point, QgsRectangle viewExtent, double mapUnitsPerPixel ) bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, QgsPoint point, QgsRectangle viewExtent, double mapUnitsPerPixel )
{ {
QgsDebugMsg( "point = " + point.toString() ); QgsDebugMsg( "point = " + point.toString() );
if ( !layer ) return false; if ( !layer )
return false;


QgsRasterDataProvider *dprovider = layer->dataProvider(); QgsRasterDataProvider *dprovider = layer->dataProvider();
int capabilities = dprovider->capabilities(); int capabilities = dprovider->capabilities();
if ( !dprovider || !( capabilities & QgsRasterDataProvider::Identify ) ) if ( !dprovider || !( capabilities & QgsRasterDataProvider::Identify ) )
{
return false; return false;
}


QgsPoint pointInCanvasCrs = point; QgsPoint pointInCanvasCrs = point;
try try
Expand Down Expand Up @@ -571,8 +570,6 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
if ( featureType.compare( sublayer, Qt::CaseInsensitive ) != 0 || labels.isEmpty() ) if ( featureType.compare( sublayer, Qt::CaseInsensitive ) != 0 || labels.isEmpty() )
{ {
labels << featureType; labels << featureType;


} }


QMap< QString, QString > derAttributes = derivedAttributes; QMap< QString, QString > derAttributes = derivedAttributes;
Expand Down
6 changes: 4 additions & 2 deletions src/providers/wms/CMakeLists.txt
@@ -1,4 +1,3 @@

SET (WMS_SRCS SET (WMS_SRCS
qgswmscapabilities.cpp qgswmscapabilities.cpp
qgswmsprovider.cpp qgswmsprovider.cpp
Expand All @@ -22,15 +21,18 @@ QT4_WRAP_CPP (WMS_MOC_SRCS ${WMS_MOC_HDRS})


INCLUDE_DIRECTORIES( . ../../core ../../core/raster ../../gui INCLUDE_DIRECTORIES( . ../../core ../../core/raster ../../gui
${CMAKE_CURRENT_BINARY_DIR}/../../ui ${CMAKE_CURRENT_BINARY_DIR}/../../ui
${GDAL_INCLUDE_DIR} # temporary solution until gdal get removed completely form QgsRasterLayer ${GDAL_INCLUDE_DIR}
${GEOS_INCLUDE_DIR} ${GEOS_INCLUDE_DIR}
${QT_QTSCRIPT_INCLUDE_DIR}
) )


ADD_LIBRARY(wmsprovider MODULE ${WMS_SRCS} ${WMS_MOC_SRCS}) ADD_LIBRARY(wmsprovider MODULE ${WMS_SRCS} ${WMS_MOC_SRCS})


TARGET_LINK_LIBRARIES(wmsprovider TARGET_LINK_LIBRARIES(wmsprovider
qgis_core qgis_core
qgis_gui qgis_gui
${QT_QTSCRIPT_LIBRARY}
${GDAL_LIBRARY} # for OGR_G_CreateGeometryFromJson()
) )


INSTALL (TARGETS wmsprovider INSTALL (TARGETS wmsprovider
Expand Down
60 changes: 59 additions & 1 deletion src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -171,6 +171,8 @@ bool QgsWmsCapabilities::parseResponse( const QByteArray& response, const QgsWms
format = QgsRaster::IdentifyFormatFeature; // 1.0 format = QgsRaster::IdentifyFormatFeature; // 1.0
else if ( f == "application/vnd.ogc.gml" ) else if ( f == "application/vnd.ogc.gml" )
format = QgsRaster::IdentifyFormatFeature; format = QgsRaster::IdentifyFormatFeature;
else if ( f == "application/json" )
format = QgsRaster::IdentifyFormatFeature;
else if ( f.contains( "gml", Qt::CaseInsensitive ) ) else if ( f.contains( "gml", Qt::CaseInsensitive ) )
format = QgsRaster::IdentifyFormatFeature; format = QgsRaster::IdentifyFormatFeature;


Expand Down Expand Up @@ -349,7 +351,7 @@ void QgsWmsCapabilities::parseOnlineResource( QDomElement const & e, QgsWmsOnlin
{ {
QgsDebugMsg( "entering." ); QgsDebugMsg( "entering." );


onlineResourceAttribute.xlinkHref = e.attribute( "xlink:href" ); onlineResourceAttribute.xlinkHref = QUrl::fromEncoded( e.attribute( "xlink:href" ).toUtf8() ).toString();


QgsDebugMsg( "exiting." ); QgsDebugMsg( "exiting." );
} }
Expand Down Expand Up @@ -1470,7 +1472,36 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )


for ( QDomElement e1 = e0.firstChildElement( "InfoFormat" ); !e1.isNull(); e1 = e1.nextSiblingElement( "InfoFormat" ) ) for ( QDomElement e1 = e0.firstChildElement( "InfoFormat" ); !e1.isNull(); e1 = e1.nextSiblingElement( "InfoFormat" ) )
{ {
QString format = e1.text();

l.infoFormats << e1.text(); l.infoFormats << e1.text();

QgsRaster::IdentifyFormat fmt = QgsRaster::IdentifyFormatUndefined;

QgsDebugMsg( QString( "format=%1" ).arg( format ) );

if ( format == "MIME" )
fmt = QgsRaster::IdentifyFormatText; // 1.0
else if ( format == "text/plain" )
fmt = QgsRaster::IdentifyFormatText;
else if ( format == "text/html" )
fmt = QgsRaster::IdentifyFormatHtml;
else if ( format.startsWith( "GML." ) )
fmt = QgsRaster::IdentifyFormatFeature; // 1.0
else if ( format == "application/vnd.ogc.gml" )
fmt = QgsRaster::IdentifyFormatFeature;
else if ( format.contains( "gml", Qt::CaseInsensitive ) )
fmt = QgsRaster::IdentifyFormatFeature;
else if ( format == "application/json" )
fmt = QgsRaster::IdentifyFormatFeature;
else
{
QgsDebugMsg( QString( "Unsupported featureInfoUrl format: %1" ).arg( format ) );
continue;
}

QgsDebugMsg( QString( "fmt=%1" ).arg( fmt ) );
mIdentifyFormats.insert( fmt, format );
} }


for ( QDomElement e1 = e0.firstChildElement( "Dimension" ); !e1.isNull(); e1 = e1.nextSiblingElement( "Dimension" ) ) for ( QDomElement e1 = e0.firstChildElement( "Dimension" ); !e1.isNull(); e1 = e1.nextSiblingElement( "Dimension" ) )
Expand Down Expand Up @@ -1595,6 +1626,33 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
else if ( resourceType == "FeatureInfo" ) else if ( resourceType == "FeatureInfo" )
{ {
l.getFeatureInfoURLs.insert( format, tmpl ); l.getFeatureInfoURLs.insert( format, tmpl );

QgsRaster::IdentifyFormat fmt = QgsRaster::IdentifyFormatUndefined;

QgsDebugMsg( QString( "format=%1" ).arg( format ) );

if ( format == "MIME" )
fmt = QgsRaster::IdentifyFormatText; // 1.0
else if ( format == "text/plain" )
fmt = QgsRaster::IdentifyFormatText;
else if ( format == "text/html" )
fmt = QgsRaster::IdentifyFormatHtml;
else if ( format.startsWith( "GML." ) )
fmt = QgsRaster::IdentifyFormatFeature; // 1.0
else if ( format == "application/vnd.ogc.gml" )
fmt = QgsRaster::IdentifyFormatFeature;
else if ( format.contains( "gml", Qt::CaseInsensitive ) )
fmt = QgsRaster::IdentifyFormatFeature;
else if ( format == "application/json" )
fmt = QgsRaster::IdentifyFormatFeature;
else
{
QgsDebugMsg( QString( "Unsupported featureInfoUrl format: %1" ).arg( format ) );
continue;
}

QgsDebugMsg( QString( "fmt=%1" ).arg( fmt ) );
mIdentifyFormats.insert( fmt, format );
} }
else else
{ {
Expand Down

0 comments on commit d6495ab

Please sign in to comment.