@@ -648,6 +648,10 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, QString version )
648
648
return 2 ;
649
649
}
650
650
651
+ QgsDebugMsg ( " mMapRenderer->extent(): " + mMapRenderer ->extent ().toString () );
652
+ QgsDebugMsg ( QString ( " mMapRenderer width = %1 height = %2" ).arg ( mMapRenderer ->outputSize ().width () ).arg ( mMapRenderer ->outputSize ().height () ) );
653
+ QgsDebugMsg ( QString ( " mMapRenderer->mapUnitsPerPixel() = %1" ).arg ( mMapRenderer ->mapUnitsPerPixel () ) );
654
+
651
655
// find out the current scale denominater and set it to the SLD parser
652
656
QgsScaleCalculator scaleCalc (( outputImage->logicalDpiX () + outputImage->logicalDpiY () ) / 2 , mMapRenderer ->destinationCrs ().mapUnits () );
653
657
QgsRectangle mapExtent = mMapRenderer ->extent ();
@@ -1127,9 +1131,28 @@ int QgsWMSServer::infoPointToLayerCoordinates( int i, int j, QgsPoint* layerCoor
1127
1131
}
1128
1132
1129
1133
// first transform i,j to map output coordinates
1130
- QgsPoint mapPoint = mapRender->coordinateTransform ()->toMapCoordinates ( i, j );
1134
+ // toMapCoordinates() is currently (Oct 18 2012) using average resolution
1135
+ // to calc point but GetFeatureInfo request may be sent with different
1136
+ // resolutions in each axis
1137
+ // QgsPoint mapPoint = mapRender->coordinateTransform()->toMapCoordinates( i, j );
1138
+ double xRes = mapRender->extent ().width () / mapRender->width ();
1139
+ double yRes = mapRender->extent ().height () / mapRender->height ();
1140
+ QgsPoint mapPoint ( mapRender->extent ().xMinimum () + i * xRes,
1141
+ mapRender->extent ().yMaximum () - j * yRes );
1142
+
1143
+ QgsDebugMsg ( QString ( " mapPoint (corner): %1 %2" ).arg ( mapPoint.x () ).arg ( mapPoint.y () ) );
1144
+ // use pixel center instead of corner
1145
+ // Unfortunately going through pixel (integer) we cannot reconstruct precisely
1146
+ // the coordinate clicked on client and thus result may differ from
1147
+ // the same raster loaded and queried localy on client
1148
+ mapPoint.setX ( mapPoint.x () + xRes / 2 );
1149
+ mapPoint.setY ( mapPoint.y () - yRes / 2 );
1150
+
1151
+ QgsDebugMsg ( QString ( " mapPoint (pixel center): %1 %2" ).arg ( mapPoint.x () ).arg ( mapPoint.y () ) );
1152
+
1131
1153
// and then to layer coordinates
1132
1154
*layerCoords = mapRender->mapToLayerCoordinates ( layer, mapPoint );
1155
+ QgsDebugMsg ( QString ( " mapPoint: %1 %2" ).arg ( mapPoint.x () ).arg ( mapPoint.y () ) );
1133
1156
return 0 ;
1134
1157
}
1135
1158
@@ -1303,9 +1326,11 @@ int QgsWMSServer::featureInfoFromRasterLayer( QgsRasterLayer* layer,
1303
1326
return 1 ;
1304
1327
}
1305
1328
1329
+ QgsDebugMsg ( QString ( " infoPoint: %1 %2" ).arg ( infoPoint->x () ).arg ( infoPoint->y () ) );
1330
+
1306
1331
QMap<QString, QString> attributes;
1307
- // TODO: use context extent, width height (comes with request) to use WCS cache
1308
- attributes = layer->dataProvider ()->identify ( *infoPoint );
1332
+ // use context extent, width height (comes with request) to use WCS cache
1333
+ attributes = layer->dataProvider ()->identify ( *infoPoint, mMapRenderer -> extent (), mMapRenderer -> outputSize (). width (), mMapRenderer -> outputSize (). height () );
1309
1334
1310
1335
for ( QMap<QString, QString>::const_iterator it = attributes.constBegin (); it != attributes.constEnd (); ++it )
1311
1336
{
0 commit comments