[QGIS Commit] r9006 - trunk/qgis/src/plugins/coordinate_capture

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Aug 6 09:36:32 EDT 2008


Author: timlinux
Date: 2008-08-06 09:36:32 -0400 (Wed, 06 Aug 2008)
New Revision: 9006

Modified:
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp
   trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h
Log:
Display coordinates in geographic and canvas CRS


Modified: trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp	2008-08-06 13:16:18 UTC (rev 9005)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.cpp	2008-08-06 13:36:32 UTC (rev 9006)
@@ -24,6 +24,10 @@
 #include <qgisgui.h>
 #include <qgspoint.h>
 #include <qgsmapcanvas.h>
+#include <qgsmaprenderer.h>
+#include <qgis.h>
+#include <qgsspatialrefsys.h>
+#include <qgscoordinatetransform.h>
 
 #include "coordinatecapture.h"
 #include "coordinatecapturegui.h"
@@ -100,16 +104,16 @@
   mypGeoLabel->setPixmap(QPixmap(":/coordinatecapture/geographic.png"));
   QLabel * mypCRSLabel = new QLabel(mypWidget);
   mypCRSLabel->setPixmap(QPixmap(":/coordinatecapture/transformed.png"));
-  mpXEdit = new QLineEdit(mypWidget);
-  mpYEdit = new QLineEdit(mypWidget);
+  mpGeoEdit = new QLineEdit(mypWidget);
+  mpTransformedEdit = new QLineEdit(mypWidget);
   QPushButton * mypCopyButton = new QPushButton(mypWidget);
   mypCopyButton->setText(tr("Copy to clipboard"));
   connect(mypCopyButton, SIGNAL(clicked()), this, SLOT(copy()));
 
   mypLayout->addWidget(mypGeoLabel, 0,0);
-  mypLayout->addWidget(mpXEdit, 0,1);
+  mypLayout->addWidget(mpGeoEdit, 0,1);
   mypLayout->addWidget(mypCRSLabel, 1,0);
-  mypLayout->addWidget(mpYEdit, 1,1);
+  mypLayout->addWidget(mpTransformedEdit, 1,1);
   mypLayout->addWidget(mypCopyButton, 2,1);
 
   
@@ -132,8 +136,16 @@
 
 void CoordinateCapture::update(QgsPoint thePoint)
 {
-  mpXEdit->setText(QString::number( thePoint.x(),'f'));
-  mpYEdit->setText(QString::number( thePoint.y(),'f'));
+  //this is the coordinate resolved back to lat / lon
+  QgsSpatialRefSys mySrs;
+  mySrs.createFromEpsg(GEOEPSG_ID); //geo lat lon
+  QgsCoordinateTransform myTransform(mQGisIface->getMapCanvas()->mapRenderer()->destinationSrs(),mySrs);
+  QgsPoint myGeoPoint = myTransform.transform(thePoint);
+  mpGeoEdit->setText(QString::number( myGeoPoint.x(),'f',3) + "," +
+      QString::number( myGeoPoint.y(),'f',3));
+  // This is the coordinate space of the map canvas
+  mpTransformedEdit->setText(QString::number( thePoint.x(),'f',3) + "," +
+      QString::number( thePoint.y(),'f',3));
 }
 void CoordinateCapture::copy()
 {
@@ -141,14 +153,14 @@
   //if we are on x11 system put text into selection ready for middle button pasting 
   if (myClipboard->supportsSelection()) 
   { 
-    myClipboard->setText(mpXEdit->text() + "," + mpYEdit->text(),QClipboard::Selection); 
+    myClipboard->setText(mpGeoEdit->text() + "," + mpTransformedEdit->text(),QClipboard::Selection); 
     //QString myMessage = tr("Clipboard contents set to: "); 
     //statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Selection)); 
   } 
   else 
   { 
     //user has an inferior operating system.... 
-    myClipboard->setText(mpXEdit->text() + "," + mpYEdit->text(),QClipboard::Clipboard ); 
+    myClipboard->setText(mpGeoEdit->text() + "," + mpTransformedEdit->text(),QClipboard::Clipboard ); 
     //QString myMessage = tr("Clipboard contents set to: "); 
     //statusBar()->showMessage(myMessage + myClipboard->text(QClipboard::Clipboard)); 
   } 

Modified: trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h
===================================================================
--- trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h	2008-08-06 13:16:18 UTC (rev 9005)
+++ trunk/qgis/src/plugins/coordinate_capture/coordinatecapture.h	2008-08-06 13:36:32 UTC (rev 9006)
@@ -97,11 +97,11 @@
   //! Container for the coordinate info
   QPointer<QDockWidget> mpDockWidget;
 
-  //!output display for x coord
-  QPointer<QLineEdit> mpXEdit;
+  //!output display for geographic lat/long coords
+  QPointer<QLineEdit> mpGeoEdit;
 
-  //!output display for y coord
-  QPointer<QLineEdit> mpYEdit;
+  //!output display for CRS  coord
+  QPointer<QLineEdit> mpTransformedEdit;
 
   //!Our custom map tool to capture clicks
   CoordinateCaptureMapTool * mpMapTool;



More information about the QGIS-commit mailing list