Skip to content
Permalink
Browse files

fix #3590 and crs warnings

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15448 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Mar 12, 2011
1 parent b8a8192 commit 85e23094bf0a6935b07947aee3fc14cbdb8f0c3f
@@ -483,7 +483,7 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in

if ( radRecenterMap->isChecked() || radRecenterWhenNeeded->isChecked() )
{
QgsCoordinateReferenceSystem mypSRS = mpCanvas->mapRenderer( )->destinationSrs();
QgsCoordinateReferenceSystem mypSRS = mpCanvas->mapRenderer()->destinationCrs();
QgsCoordinateReferenceSystem myLatLongRefSys = QgsCoordinateReferenceSystem( 4326 );
QgsCoordinateTransform myTransform( myLatLongRefSys, mypSRS );

@@ -539,7 +539,7 @@ void QgsGPSInformationWidget::addVertex( )
QgsPoint myPoint;
if ( mpCanvas && mpCanvas->mapRenderer() )
{
QgsCoordinateTransform t( mWgs84CRS, mpCanvas->mapRenderer()->destinationSrs() );
QgsCoordinateTransform t( mWgs84CRS, mpCanvas->mapRenderer()->destinationCrs() );
myPoint = t.transform( mLastGpsPosition );
}
else
@@ -850,7 +850,7 @@ QPointF QgsGPSInformationWidget::gpsToPixelPosition( const QgsPoint& point )
QgsPoint myCenter;
if ( mpCanvas && mpCanvas->mapRenderer() )
{
QgsCoordinateTransform t( mWgs84CRS, mpCanvas->mapRenderer()->destinationSrs() );
QgsCoordinateTransform t( mWgs84CRS, mpCanvas->mapRenderer()->destinationCrs() );
myCenter = t.transform( point );
}
else
@@ -40,7 +40,7 @@ void QgsGpsMarker::setCenter( const QgsPoint& point )
//transform to map crs
if ( mMapCanvas && mMapCanvas->mapRenderer() )
{
QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapRenderer()->destinationSrs() );
QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapRenderer()->destinationCrs() );
try
{
mCenter = t.transform( point );
@@ -1259,8 +1259,6 @@ void QgisApp::createStatusBar()
mOnTheFlyProjectionStatusLabel->setAlignment( Qt::AlignCenter );
mOnTheFlyProjectionStatusLabel->setFrameStyle( QFrame::NoFrame );
QString myCrs = mMapCanvas->mapRenderer()->destinationCrs().authid();
mOnTheFlyProjectionStatusLabel->setText( myCrs );
mOnTheFlyProjectionStatusLabel->setToolTip( tr( "Current CRS" ) );
statusBar()->addPermanentWidget( mOnTheFlyProjectionStatusLabel, 0 );
// On the fly projection status bar icon
// Changed this to a tool button since a QPushButton is
@@ -2504,7 +2502,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag )
QString defCrs = settings.value( "/Projections/projectDefaultCrs", GEO_EPSG_CRS_AUTHID ).toString();
QgsCoordinateReferenceSystem srs;
srs.createFromOgcWmsCrs( defCrs );
myRenderer->setDestinationSrs( srs );
myRenderer->setDestinationCrs( srs );
// write the projections _proj string_ to project settings
prj->writeEntry( "SpatialRefSys", "/ProjectCrs", defCrs );
prj->dirty( false );
@@ -2514,18 +2512,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag )
}

// enable OTF CRS transformation if necessary
if ( settings.value( "/Projections/otfTransformEnabled", 0 ).toBool() )
{
QString myCrs = mMapCanvas->mapRenderer()->destinationCrs().authid();
mOnTheFlyProjectionStatusLabel->setText( myCrs );
myRenderer->setProjectionsEnabled( true );
mOnTheFlyProjectionStatusButton->setIcon( getThemeIcon( "mIconProjectionEnabled.png" ) );
}
else
{
mOnTheFlyProjectionStatusLabel->setText( "---" );
myRenderer->setProjectionsEnabled( false );
}
myRenderer->setProjectionsEnabled( settings.value( "/Projections/otfTransformEnabled", 0 ).toBool() );

// set the initial map tool
mMapCanvas->setMapTool( mMapTools.mPan );
@@ -3370,7 +3357,7 @@ void QgisApp::saveAsVectorFileGeneral( bool saveOnlySelection )
// Find out if we have projections enabled or not
if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
destCRS = mMapCanvas->mapRenderer()->destinationSrs();
destCRS = mMapCanvas->mapRenderer()->destinationCrs();
}
else
{
@@ -4542,12 +4529,12 @@ void QgisApp::setProjectCRSFromLayer()

QgsCoordinateReferenceSystem crs = mMapLegend->currentLayer()->crs();
QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer();
myRenderer->setDestinationSrs( crs );
myRenderer->setDestinationCrs( crs );
if ( crs.mapUnits() != QGis::UnknownUnit )
{
myRenderer->setMapUnits( crs.mapUnits() );
}
mMapCanvas->refresh();
mMapCanvas->refresh();
}

void QgisApp::showGpsTool()
@@ -5363,33 +5350,40 @@ void QgisApp::removePluginToolBarIcon( QAction *qAction )
mPluginToolBar->removeAction( qAction );
}

void QgisApp::updateCRSStatusBar()
{
mOnTheFlyProjectionStatusLabel->setText( mMapCanvas->mapRenderer()->destinationCrs().authid() );

if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
{
mOnTheFlyProjectionStatusLabel->setEnabled( true );
mOnTheFlyProjectionStatusLabel->setToolTip(
tr( "Current CRS: %1" ).arg( mMapCanvas->mapRenderer()->destinationCrs().description() ) );
mOnTheFlyProjectionStatusButton->setIcon( getThemeIcon( "mIconProjectionEnabled.png" ) );
}
else
{
mOnTheFlyProjectionStatusLabel->setEnabled( false );
mOnTheFlyProjectionStatusLabel->setToolTip( tr( "On the fly reprojection not active" ) );
mOnTheFlyProjectionStatusLabel->setToolTip(
tr( "Inactive project CRS: %1" ).arg( mMapCanvas->mapRenderer()->destinationCrs().description() ) );
mOnTheFlyProjectionStatusButton->setIcon( getThemeIcon( "mIconProjectionDisabled.png" ) );
}
}

void QgisApp::destinationSrsChanged()
{
// save this information to project
long srsid = mMapCanvas->mapRenderer()->destinationSrs().srsid();
long srsid = mMapCanvas->mapRenderer()->destinationCrs().srsid();
QgsProject::instance()->writeEntry( "SpatialRefSys", "/ProjectCRSID", ( int )srsid );

updateCRSStatusBar();
}

void QgisApp::hasCrsTransformEnabled( bool theFlag )
{
// save this information to project
QgsProject::instance()->writeEntry( "SpatialRefSys", "/ProjectionsEnabled", ( theFlag ? 1 : 0 ) );

// update icon
if ( theFlag )
{
QString myCrs = mMapCanvas->mapRenderer()->destinationCrs().authid();
mOnTheFlyProjectionStatusLabel->setText( myCrs );
mOnTheFlyProjectionStatusButton->setIcon(
getThemeIcon( "mIconProjectionEnabled.png" ) );
}
else
{
mOnTheFlyProjectionStatusLabel->setText( "---" );
mOnTheFlyProjectionStatusButton->setIcon(
getThemeIcon( "mIconProjectionDisabled.png" ) );
}
updateCRSStatusBar();
}
// slot to update the progress bar in the status bar
void QgisApp::showProgress( int theProgress, int theTotalSteps )
@@ -5591,12 +5585,12 @@ void QgisApp::projectProperties()

QgsMapRenderer* myRender = mMapCanvas->mapRenderer();
bool wasProjected = myRender->hasCrsTransformEnabled();
long oldCRSID = myRender->destinationSrs().srsid();
long oldCRSID = myRender->destinationCrs().srsid();

// Display the modal dialog box.
pp->exec();

long newCRSID = myRender->destinationSrs().srsid();
long newCRSID = myRender->destinationCrs().srsid();
bool isProjected = myRender->hasCrsTransformEnabled();

// projections have been turned on/off or dest CRS has changed while projections are on
@@ -864,6 +864,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void createCanvasTools();
bool createDB();
void createMapTips();
void updateCRSStatusBar();

// actions for menus and toolbars -----------------

@@ -963,7 +964,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QToolButton * mToggleExtentsViewButton;
//! Button used to stop rendering
QToolButton* mStopRenderButton;
//! Widget in status bar used to show current project CRS
//! Widget in status bar used to show current project CRS
QLabel * mOnTheFlyProjectionStatusLabel;
//! Widget in status bar used to show status of on the fly projection
QToolButton * mOnTheFlyProjectionStatusButton;
@@ -181,7 +181,7 @@ void QgsMapToolMeasureAngle::configureDistanceArea( QgsDistanceArea& da )
{
QSettings settings;
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
da.setSourceCrs( mCanvas->mapRenderer()->destinationSrs().srsid() );
da.setSourceCrs( mCanvas->mapRenderer()->destinationCrs().srsid() );
da.setEllipsoid( ellipsoidId );
da.setProjectionsEnabled( mResultDisplay->projectionEnabled() );
}
@@ -108,7 +108,7 @@ void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
{
try
{
QgsCoordinateTransform ct( canvas->mapRenderer()->destinationSrs(), vlayer->crs() );
QgsCoordinateTransform ct( canvas->mapRenderer()->destinationCrs(), vlayer->crs() );
selectGeomTrans.transform( ct );
}
catch ( QgsCsException &cse )
@@ -372,7 +372,7 @@ void QgsMeasureDialog::configureDistanceArea( QgsDistanceArea& da )
{
QSettings settings;
QString ellipsoidId = settings.value( "/qgis/measure/ellipsoid", "WGS84" ).toString();
da.setSourceCrs( mTool->canvas()->mapRenderer()->destinationSrs().srsid() );
da.setSourceCrs( mTool->canvas()->mapRenderer()->destinationCrs().srsid() );
da.setEllipsoid( ellipsoidId );
da.setProjectionsEnabled( mcbProjectionEnabled->isChecked() );
}
@@ -64,7 +64,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
cbxProjectionEnabled->setChecked( myProjectionEnabled );
btnGrpMapUnits->setEnabled( !myProjectionEnabled );

long myCRSID = myRenderer->destinationSrs().srsid();
long myCRSID = myRenderer->destinationCrs().srsid();
QgsDebugMsg( "Read project CRSID: " + QString::number( myCRSID ) );
projectionSelector->setSelectedCrsId( myCRSID );

@@ -306,7 +306,7 @@ void QgsProjectProperties::apply()
if ( myCRSID )
{
QgsCoordinateReferenceSystem srs( myCRSID, QgsCoordinateReferenceSystem::InternalCrsId );
myRenderer->setDestinationSrs( srs );
myRenderer->setDestinationCrs( srs );
QgsDebugMsg( QString( "Selected CRS " ) + srs.description() );
// write the currently selected projections _proj string_ to project settings
QgsDebugMsg( QString( "SpatialRefSys/ProjectCRSProj4String: %1" ).arg( projectionSelector->selectedProj4String() ) );
@@ -145,7 +145,7 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
theMapRenderer.setLayerSet( mMapRenderer->layerSet() );
}
theMapRenderer.setProjectionsEnabled( mMapRenderer->hasCrsTransformEnabled() );
theMapRenderer.setDestinationSrs( mMapRenderer->destinationSrs() );
theMapRenderer.setDestinationCrs( mMapRenderer->destinationCrs() );

//set antialiasing if enabled in options
QSettings settings;
@@ -1009,7 +1009,7 @@ bool QgsMapRenderer::readXML( QDomNode & theNode )
QgsCoordinateReferenceSystem srs;
QDomNode srsNode = theNode.namedItem( "destinationsrs" );
srs.readXML( srsNode );
setDestinationSrs( srs );
setDestinationCrs( srs );

return true;
}
@@ -1078,7 +1078,7 @@ bool QgsMapRenderer::writeXML( QDomNode & theNode, QDomDocument & theDoc )
// destination CRS
QDomElement srsNode = theDoc.createElement( "destinationsrs" );
theNode.appendChild( srsNode );
destinationSrs().writeXML( srsNode, theDoc );
destinationCrs().writeXML( srsNode, theDoc );

return true;
}
@@ -733,7 +733,7 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,

lyr.xform = mMapRenderer->coordinateTransform();
if ( mMapRenderer->hasCrsTransformEnabled() )
lyr.ct = new QgsCoordinateTransform( layer->crs(), mMapRenderer->destinationSrs() );
lyr.ct = new QgsCoordinateTransform( layer->crs(), mMapRenderer->destinationCrs() );
else
lyr.ct = NULL;
lyr.ptZero = lyr.xform->toMapCoordinates( 0, 0 );
@@ -300,8 +300,8 @@ void QgsMapOverviewCanvas::hasCrsTransformEnabled( bool flag )

void QgsMapOverviewCanvas::destinationSrsChanged()
{
const QgsCoordinateReferenceSystem& srs = mMapCanvas->mapRenderer()->destinationSrs();
mMapRenderer->setDestinationSrs( srs );
const QgsCoordinateReferenceSystem& srs = mMapCanvas->mapRenderer()->destinationCrs();
mMapRenderer->setDestinationCrs( srs );
}

QStringList& QgsMapOverviewCanvas::layerSet()
@@ -79,7 +79,7 @@ void QgsConfigParser::appendExGeographicBoundingBox( QDomElement& layerElem,
}

QgsCoordinateReferenceSystem wgs84;
wgs84.createFromOgcWmsCrs( "EPSG:4326" );
wgs84.createFromOgcWmsCrs( GEO_EPSG_CRS_AUTHID );

//Ex_GeographicBoundingBox
//transform the layers native CRS into WGS84
@@ -324,7 +324,7 @@ QgsComposition* QgsConfigParser::createPrintComposition( const QString& composer
QMap<QString, QString>::const_iterator versionIt = parameterMap.find( "VERSION" );
if ( versionIt != parameterMap.end() )
{
if ( mapRenderer && versionIt.value() == "1.3.0" && mapRenderer->destinationSrs().geographicFlag() )
if ( mapRenderer && versionIt.value() == "1.3.0" && mapRenderer->destinationCrs().geographicFlag() )
{
//switch coordinates of extent
double tmp;
@@ -184,7 +184,7 @@ void QgsProjectParser::addLayers( QDomDocument &doc,

appendCRSElementsToLayer( layerElem, doc, combinedCRSSet.toList() );

const QgsCoordinateReferenceSystem& groupCRS = QgsEPSGCache::instance()->searchCRS( 4326 );
const QgsCoordinateReferenceSystem& groupCRS = QgsEPSGCache::instance()->searchCRS( GEO_EPSG_CRS_ID );
appendExGeographicBoundingBox( layerElem, doc, combinedGeographicBBox, groupCRS );
}
else if ( currentChildElem.tagName() == "legendlayer" )
@@ -522,7 +522,7 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result )
}

//find out the current scale denominater and set it to the SLD parser
QgsScaleCalculator scaleCalc(( outputImage->logicalDpiX() + outputImage->logicalDpiY() ) / 2 , mMapRenderer->destinationSrs().mapUnits() );
QgsScaleCalculator scaleCalc(( outputImage->logicalDpiX() + outputImage->logicalDpiY() ) / 2 , mMapRenderer->destinationCrs().mapUnits() );
QgsRectangle mapExtent = mMapRenderer->extent();
mConfigParser->setScaleDenominator( scaleCalc.calculate( mapExtent, outputImage->width() ) );
delete outputImage; //no longer needed for feature info
@@ -727,12 +727,12 @@ QImage* QgsWMSServer::initializeRendering( QStringList& layersList, QStringList&
mMapRenderer->setLabelingEngine( new QgsPalLabeling() );

//find out the current scale denominater and set it to the SLD parser
QgsScaleCalculator scaleCalc(( theImage->logicalDpiX() + theImage->logicalDpiY() ) / 2 , mMapRenderer->destinationSrs().mapUnits() );
QgsScaleCalculator scaleCalc(( theImage->logicalDpiX() + theImage->logicalDpiY() ) / 2 , mMapRenderer->destinationCrs().mapUnits() );
QgsRectangle mapExtent = mMapRenderer->extent();
mConfigParser->setScaleDenominator( scaleCalc.calculate( mapExtent, theImage->width() ) );

//create objects for qgis rendering
QStringList theLayers = layerSet( layersList, stylesList, mMapRenderer->destinationSrs() );
QStringList theLayers = layerSet( layersList, stylesList, mMapRenderer->destinationCrs() );
mMapRenderer->setLayerSet( theLayers );
return theImage;
}
@@ -916,7 +916,7 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
throw QgsMapServiceException( "InvalidCRS", "Could not create output CRS" );
return 5;
}
mMapRenderer->setDestinationSrs( outputCRS );
mMapRenderer->setDestinationCrs( outputCRS );
mMapRenderer->setProjectionsEnabled( true );
mapUnits = outputCRS.mapUnits();
}
@@ -188,8 +188,8 @@ void CoordinateCapture::setCRS()

void CoordinateCapture::setSourceCrs()
{
mTransform.setSourceCrs( mQGisIface->mapCanvas()->mapRenderer()->destinationSrs() );
mCanvasDisplayPrecision = ( mQGisIface->mapCanvas()->mapRenderer()->destinationSrs().mapUnits() == QGis::Degrees ) ? 5 : 3; // for the map canvas coordinate display
mTransform.setSourceCrs( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs() );
mCanvasDisplayPrecision = ( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs().mapUnits() == QGis::Degrees ) ? 5 : 3; // for the map canvas coordinate display
}

void CoordinateCapture::mouseClicked( QgsPoint thePoint )
@@ -302,7 +302,7 @@ bool QgsNorthArrowPlugin::calculateNorthDirection()

if ( mapCanvas.layerCount() > 0 )
{
QgsCoordinateReferenceSystem outputCRS = mapCanvas.mapRenderer()->destinationSrs();
QgsCoordinateReferenceSystem outputCRS = mapCanvas.mapRenderer()->destinationCrs();

if ( outputCRS.isValid() && !outputCRS.geographicFlag() )
{
@@ -305,7 +305,7 @@ void RoadGraphPlugin::render( QPainter *painter )
if ( graphDirector == NULL )
return;

RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationSrs() );
RgSimpleGraphBuilder builder( mQGisIface->mapCanvas()->mapRenderer()->destinationCrs() );
QVector< QgsPoint > null;
graphDirector->makeGraph( &builder , null, null );
AdjacencyMatrix m = builder.adjacencyMatrix();
@@ -227,7 +227,7 @@ bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPo
return false;
}

RgSimpleGraphBuilder builder( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs(),
RgSimpleGraphBuilder builder( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
mPlugin->topologyToleranceFactor() );
{
const RgGraphDirector *director = mPlugin->director();
@@ -340,7 +340,7 @@ void RgShortestPathWidget::exportPath()
if ( vl == NULL )
return;

QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs(),
QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationCrs(),
vl->crs() );

QVector< QgsPoint > points;
@@ -669,7 +669,7 @@ void QgsSpatialQueryDialog::zoomFeature( QgsVectorLayer* lyr, int fid )
}
// Set system reference
QgsCoordinateReferenceSystem srsSource = lyr->dataProvider()->crs();
QgsCoordinateReferenceSystem srcMapcanvas = mIface->mapCanvas()->mapRenderer()->destinationSrs();
QgsCoordinateReferenceSystem srcMapcanvas = mIface->mapCanvas()->mapRenderer()->destinationCrs();
if ( ! srsSource.isValid() )
{
if ( hasMsg )

0 comments on commit 85e2309

Please sign in to comment.
You can’t perform that action at this time.