|
61 | 61 | #include <QSettings>
|
62 | 62 | #include <QEventLoop>
|
63 | 63 | #include <QCoreApplication>
|
| 64 | +#include <QTextCodec> |
64 | 65 | #include <QTime>
|
65 | 66 |
|
66 | 67 | #ifdef QGISDEBUG
|
@@ -4376,7 +4377,18 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
|
4376 | 4377 | }
|
4377 | 4378 | }
|
4378 | 4379 |
|
4379 |
| - QgsDebugMsg( "GML (first 2000 bytes):\n" + QString::fromUtf8( mIdentifyResultBodies.value( gmlPart ).left( 2000 ) ) ); |
| 4380 | + QByteArray gmlByteArray = mIdentifyResultBodies.value( gmlPart ); |
| 4381 | + QgsDebugMsg( "GML (first 2000 bytes):\n" + gmlByteArray.left( 2000 ) ); |
| 4382 | + |
| 4383 | + // QgsGmlSchema.guessSchema() and QgsGml::getFeatures() are using Expat |
| 4384 | + // which only accepts UTF-8, UTF-16, ISO-8859-1 |
| 4385 | + // http://sourceforge.net/p/expat/bugs/498/ |
| 4386 | + QDomDocument dom; |
| 4387 | + dom.setContent( gmlByteArray ); // gets XML encoding |
| 4388 | + QTextStream stream( &gmlByteArray ); |
| 4389 | + stream.setCodec( QTextCodec::codecForName( "UTF-8" ) ); |
| 4390 | + dom.save( stream, 4, QDomNode::EncodingFromTextStream ); |
| 4391 | + |
4380 | 4392 | QGis::WkbType wkbType;
|
4381 | 4393 | QgsGmlSchema gmlSchema;
|
4382 | 4394 |
|
@@ -4418,7 +4430,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
|
4418 | 4430 | else
|
4419 | 4431 | {
|
4420 | 4432 | // guess from GML
|
4421 |
| - bool ok = gmlSchema.guessSchema( mIdentifyResultBodies.value( gmlPart ) ); |
| 4433 | + bool ok = gmlSchema.guessSchema( gmlByteArray ); |
4422 | 4434 | if ( ! ok )
|
4423 | 4435 | {
|
4424 | 4436 | QgsError err = gmlSchema.error();
|
@@ -4454,7 +4466,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
|
4454 | 4466 | }
|
4455 | 4467 | QgsGml gml( featureTypeName, geometryAttribute, fields );
|
4456 | 4468 | // TODO: avoid converting to string and back
|
4457 |
| - int ret = gml.getFeatures( mIdentifyResultBodies.value( gmlPart ), &wkbType ); |
| 4469 | + int ret = gml.getFeatures( gmlByteArray, &wkbType ); |
4458 | 4470 | #ifdef QGISDEBUG
|
4459 | 4471 | QgsDebugMsg( QString( "parsing result = %1" ).arg( ret ) );
|
4460 | 4472 | #else
|
|
0 commit comments