@@ -2637,24 +2637,27 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
2637
2637
if ( result.property ( " type" ).toString () != " FeatureCollection" )
2638
2638
throw QString ( " type FeatureCollection expected: %1" ).arg ( result.property ( " type" ).toString () );
2639
2639
2640
- QString crsType = result.property ( " crs" ).property ( " type" ).toString ();
2641
- QString crsText;
2642
- if ( crsType == " name" )
2643
- crsText = result.property ( " crs" ).property ( " name" ).toString ();
2644
- else if ( crsType == " EPSG" )
2645
- crsText = QString ( " %1:%2" ).arg ( crsType ).arg ( result.property ( " crs" ).property ( " properties" ).property ( " code" ).toString () );
2646
- else
2647
- QgsDebugMsg ( QString ( " crs not supported:%1" ).arg ( result.property ( " crs" ).toString () ) );
2648
-
2649
- QgsCoordinateReferenceSystem featuresCrs;
2650
- featuresCrs.createFromOgcWmsCrs ( crsText );
2651
-
2652
- if ( !featuresCrs.isValid () )
2653
- throw QString ( " CRS %1 invalid" ).arg ( crsText );
2654
-
2655
- if ( featuresCrs.isValid () && featuresCrs != crs () )
2640
+ if ( result.property ( " crs" ).isValid () )
2656
2641
{
2657
- coordinateTransform = new QgsCoordinateTransform ( featuresCrs, crs () );
2642
+ QString crsType = result.property ( " crs" ).property ( " type" ).toString ();
2643
+ QString crsText;
2644
+ if ( crsType == " name" )
2645
+ crsText = result.property ( " crs" ).property ( " name" ).toString ();
2646
+ else if ( crsType == " EPSG" )
2647
+ crsText = QString ( " %1:%2" ).arg ( crsType ).arg ( result.property ( " crs" ).property ( " properties" ).property ( " code" ).toString () );
2648
+ else
2649
+ QgsDebugMsg ( QString ( " crs not supported:%1" ).arg ( result.property ( " crs" ).toString () ) );
2650
+
2651
+ QgsCoordinateReferenceSystem featuresCrs;
2652
+ featuresCrs.createFromOgcWmsCrs ( crsText );
2653
+
2654
+ if ( !featuresCrs.isValid () )
2655
+ throw QString ( " CRS %1 invalid" ).arg ( crsText );
2656
+
2657
+ if ( featuresCrs.isValid () && featuresCrs != crs () )
2658
+ {
2659
+ coordinateTransform = new QgsCoordinateTransform ( featuresCrs, crs () );
2660
+ }
2658
2661
}
2659
2662
2660
2663
QScriptValue fc = result.property ( " features" );
@@ -2683,22 +2686,25 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint & thePoint, Qgs
2683
2686
2684
2687
QgsFeature feature ( fields );
2685
2688
2686
- QScriptValue geom = json_stringify.call ( QScriptValue (), QScriptValueList () << f.property ( " geometry" ) );
2687
- if ( geom.isString () )
2689
+ if ( !f.property ( " geometry" ).isNull () )
2688
2690
{
2689
- OGRGeometryH ogrGeom = OGR_G_CreateGeometryFromJson ( geom. toString (). toUtf8 ( ) );
2690
- if ( ogrGeom )
2691
+ QScriptValue geom = json_stringify. call ( QScriptValue (), QScriptValueList () << f. property ( " geometry " ) );
2692
+ if ( geom. isString () )
2691
2693
{
2692
- size_t wkbSize = OGR_G_WkbSize ( ogrGeom );
2693
- unsigned char *wkb = new unsigned char [ wkbSize ];
2694
- OGR_G_ExportToWkb ( ogrGeom, ( OGRwkbByteOrder ) QgsApplication::endian (), wkb );
2695
- OGR_G_DestroyGeometry ( ogrGeom );
2694
+ OGRGeometryH ogrGeom = OGR_G_CreateGeometryFromJson ( geom.toString ().toUtf8 () );
2695
+ if ( ogrGeom )
2696
+ {
2697
+ size_t wkbSize = OGR_G_WkbSize ( ogrGeom );
2698
+ unsigned char *wkb = new unsigned char [ wkbSize ];
2699
+ OGR_G_ExportToWkb ( ogrGeom, ( OGRwkbByteOrder ) QgsApplication::endian (), wkb );
2700
+ OGR_G_DestroyGeometry ( ogrGeom );
2696
2701
2697
- feature.setGeometryAndOwnership ( wkb, wkbSize );
2702
+ feature.setGeometryAndOwnership ( wkb, wkbSize );
2698
2703
2699
- if ( coordinateTransform && feature.geometry () )
2700
- {
2701
- feature.geometry ()->transform ( *coordinateTransform );
2704
+ if ( coordinateTransform && feature.geometry () )
2705
+ {
2706
+ feature.geometry ()->transform ( *coordinateTransform );
2707
+ }
2702
2708
}
2703
2709
}
2704
2710
}
0 commit comments