Skip to content

Commit

Permalink
wms: improve xsd/gml detection on getfeatureinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 10, 2013
1 parent a98ed43 commit d8952d3
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4081,25 +4081,37 @@ QMap<int, QVariant> QgsWmsProvider::identify( const QgsPoint & thePoint, Identif

int gmlPart = -1;
int xsdPart = -1;
if ( mIdentifyResultBodies.size() == 1 )
for ( int i = 0; i < mIdentifyResultHeaders.size(); i++ )
{
QgsDebugMsg( "Simple GML" );
gmlPart = 0;
}
else if ( mIdentifyResultBodies.size() == 2 ) // GML+XSD
{
QgsDebugMsg( "Multipart with 2 parts - expected GML + XSD" );
// How to find which part is GML and which XSD? Both have
// Content-Type: application/binary
// different are Content-Disposition but it is not reliable.
// We could analyze beginning of bodies...
gmlPart = 0;
xsdPart = 1;
if ( xsdPart == -1 && mIdentifyResultHeaders[i].value( "Content-Disposition" ).contains( ".xsd" ) )
{
xsdPart = i;
}
else if ( gmlPart == -1 && mIdentifyResultHeaders[i].value( "Content-Disposition" ).contains( ".dat" ) )
{
gmlPart = i;
}

if ( gmlPart != -1 && xsdPart != -1 )
break;
}
else

if ( xsdPart == -1 && gmlPart == -1 )
{
QgsDebugMsg( QString( "%1 parts in multipart response not supported" ).arg( mIdentifyResultBodies.size() ) );
continue;
if ( mIdentifyResultBodies.size() == 1 ) // GML
{
gmlPart = 0;
}
if ( mIdentifyResultBodies.size() == 2 ) // GML+XSD
{
QgsDebugMsg( "Multipart with 2 parts - expected GML + XSD" );
// How to find which part is GML and which XSD? Both have
// Content-Type: application/binary
// different are Content-Disposition but it is not reliable.
// We could analyze beginning of bodies...
gmlPart = 0;
xsdPart = 1;
}
}

QgsDebugMsg( "GML (first 2000 bytes):\n" + QString::fromUtf8( mIdentifyResultBodies.value( gmlPart ).left( 2000 ) ) );
Expand Down

0 comments on commit d8952d3

Please sign in to comment.