Skip to content
Permalink
Browse files

wms provider:

* 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 d6495abee42931f2afbb487e921f4230c87b19d9
@@ -33,11 +33,11 @@ class QgsRaster

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

// Progress types
@@ -41,6 +41,7 @@ class QgsRasterInterface
%End

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

QgsRasterInterface( QgsRasterInterface * input = 0 );
@@ -208,6 +208,7 @@ QgsProviderRegistry::~QgsProviderRegistry()

while ( it != mProviders.end() )
{
QgsDebugMsg( QString( "cleanup:%1" ).arg( it->first ) );
QString lib = it->second->library();
QLibrary myLib( lib );
if ( myLib.isLoaded() )
@@ -53,11 +53,11 @@ class CORE_EXPORT QgsRaster

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

// Progress types
@@ -40,16 +40,16 @@ class CORE_EXPORT QgsRasterInterface
//! If you add to this, please also add to capabilitiesString()
enum Capability
{
NoCapabilities = 0,
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
Remove = 1 << 3, // delete datasets
BuildPyramids = 1 << 4, // supports building of pyramids (overviews)
Identify = 1 << 5, // at least one identify format supported
IdentifyValue = 1 << 6, // numerical values
IdentifyText = 1 << 7, // WMS text
IdentifyHtml = 1 << 8, // WMS HTML
IdentifyFeature = 1 << 9 // WMS GML -> feature
NoCapabilities = 0,
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
Remove = 1 << 3, // delete datasets
BuildPyramids = 1 << 4, // supports building of pyramids (overviews)
Identify = 1 << 5, // at least one identify format supported
IdentifyValue = 1 << 6, // numerical values
IdentifyText = 1 << 7, // WMS text
IdentifyHtml = 1 << 8, // WMS HTML
IdentifyFeature = 1 << 9, // WMS GML -> feature
};

QgsRasterInterface( QgsRasterInterface * input = 0 );
@@ -418,14 +418,13 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, QgsPoint point, QgsRectangle viewExtent, double mapUnitsPerPixel )
{
QgsDebugMsg( "point = " + point.toString() );
if ( !layer ) return false;
if ( !layer )
return false;

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

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


}

QMap< QString, QString > derAttributes = derivedAttributes;
@@ -1,4 +1,3 @@

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

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

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

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

INSTALL (TARGETS wmsprovider
@@ -171,6 +171,8 @@ bool QgsWmsCapabilities::parseResponse( const QByteArray& response, const QgsWms
format = QgsRaster::IdentifyFormatFeature; // 1.0
else if ( f == "application/vnd.ogc.gml" )
format = QgsRaster::IdentifyFormatFeature;
else if ( f == "application/json" )
format = QgsRaster::IdentifyFormatFeature;
else if ( f.contains( "gml", Qt::CaseInsensitive ) )
format = QgsRaster::IdentifyFormatFeature;

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

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

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

for ( QDomElement e1 = e0.firstChildElement( "InfoFormat" ); !e1.isNull(); e1 = e1.nextSiblingElement( "InfoFormat" ) )
{
QString format = 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" ) )
@@ -1595,6 +1626,33 @@ void QgsWmsCapabilities::parseWMTSContents( QDomElement const &e )
else if ( resourceType == "FeatureInfo" )
{
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
{

0 comments on commit d6495ab

Please sign in to comment.
You can’t perform that action at this time.