@@ -320,7 +320,7 @@ QPointF InputUtils::geometryCenterToScreenCoordinates( const QgsGeometry &geom,
320320 *
321321 * Nota Bene: Assume geometry and map canvas CRS are the same
322322 */
323- bool InputUtils::canExtentContainGeometry ( const QgsGeometry &geom, InputMapSettings *mapSettings )
323+ bool InputUtils::extentContainGeometry ( const QgsGeometry &geom, InputMapSettings *mapSettings )
324324{
325325 QPointF screenPoint;
326326
@@ -329,54 +329,32 @@ bool InputUtils::canExtentContainGeometry( const QgsGeometry &geom, InputMapSett
329329
330330 QgsRectangle currentExtent = mapSettings->mapSettings ().visibleExtent ();
331331 QgsRectangle geomBbox = geom.boundingBox ();
332- qDebug () << " canExtentContainGeometry:geomBbox: " << QgsGeometry::fromRect (geomBbox).asWkt ();
333- QgsRectangle currentExtent = mapSettings->mapSettings ().extent ();
334- qDebug () << " canExtentContainGeometry:currentExtent: " << QgsGeometry::fromRect (currentExtent).asWkt ();
335332
336333 return currentExtent.contains (geomBbox);
337334}
338335
339336
340337/* *
341- * Returns true if the geometry \a geom is fully contain within the current map extent
338+ * Returns the center point of the \a geom currently display on screen
342339 *
343340 * Nota Bene: Assume geometry and map canvas CRS are the same
344341 */
345- QPointF InputUtils::centerOnScreenHighligtedGeom ( const QgsGeometry &geom, InputMapSettings *mapSettings )
342+ QPointF InputUtils::onScreenGeometryCenterToScreenCoordinates ( const QgsGeometry &geom, InputMapSettings *mapSettings )
346343{
347-
348344 QPointF screenPoint;
349345 if ( !mapSettings || geom.isNull () || !geom.constGet () )
350- // return screenPoint;
351346 return screenPoint;
352- // return false;
353-
354347
355348 QgsRectangle currentExtent = mapSettings->mapSettings ().visibleExtent ();
356349 QgsGeometry currentExtentAsGeom = QgsGeometry::fromRect (currentExtent);
357350
358- qDebug () << " geomExtend: " << currentExtentAsGeom.asWkt ();
359-
360- QgsGeometry intersected_geom = currentExtentAsGeom.intersection (geom);
361-
362- qDebug () << " inter sected_geom: " << intersected_geom.asWkt ();
363-
364-
365-
366- // QgsPoint centroid = QgsPoint( intersected_geom.centroid().asPoint() );
367-
368-
369- QgsRectangle bbox = intersected_geom.boundingBox ();
370-
351+ QgsGeometry intersectedGeom = currentExtentAsGeom.intersection (geom);
371352
353+ QgsRectangle bbox = intersectedGeom.boundingBox ();
372354 QgsPoint target = QgsPoint (bbox.center ().x (), bbox.center ().y ());
373355
374- QPoint pt = QPoint (bbox.center ().x (), bbox.yMaximum ());
375-
376356 screenPoint = mapSettings->coordinateToScreen ( target );
377357
378-
379- // return screenPoint.y();
380358 return screenPoint;
381359}
382360
0 commit comments