Skip to content
Permalink
Browse files

Use invalid CRS as default in map settings

I have got caught by the default set to WGS 84 when I loaded a layer
in projected CRS, set extent to layer's extent and... nothing got rendered
because map renderer was reprojecting to WGS 84.

This default is closer to the default in 2.x where reprojection is turned off.
  • Loading branch information
wonder-sk committed Jun 6, 2017
1 parent 362d4f0 commit 9cd3ef02acc68c55871fd6cdd050d4b74c80abe8
Showing with 9 additions and 1 deletion.
  1. +1 −0 doc/api_break.dox
  2. +1 −1 src/core/qgsmapsettings.cpp
  3. +7 −0 tests/src/core/testqgsmapsettings.cpp
@@ -1598,6 +1598,7 @@ be returned instead of a null pointer if no transformation is required.
- destinationCrs() now returns a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
plugins calling this method will need to be updated.
- setCrsTransformEnabled() and hasCrsTransformEnabled() were removed. CRS transformation is now always enabled.
- the default destination CRS has changed from WGS 84 to invalid CRS (i.e. undefined, no reprojection will be done).
- setMapUnits() was removed. The map units are dictated by the units for the destination CRS.


@@ -37,7 +37,7 @@ QgsMapSettings::QgsMapSettings()
, mExtent()
, mRotation( 0.0 )
, mMagnificationFactor( 1.0 )
, mDestCRS( QgsCoordinateReferenceSystem::fromSrsId( GEOCRS_ID ) ) // WGS 84
, mDestCRS()
, mDatumTransformStore( mDestCRS )
, mBackgroundColor( Qt::white )
, mSelectionColor( Qt::yellow )
@@ -34,6 +34,7 @@ class TestQgsMapSettings: public QObject
private slots:
void initTestCase();
void cleanupTestCase();
void testDefaults();
void visibleExtent();
void mapUnitsPerPixel();
void visiblePolygon();
@@ -73,6 +74,12 @@ QString TestQgsMapSettings::toString( const QPolygonF &p, int dec ) const
return s;
}

void TestQgsMapSettings::testDefaults()
{
QgsMapSettings ms;
QCOMPARE( ms.destinationCrs(), QgsCoordinateReferenceSystem() );
}

void TestQgsMapSettings::visibleExtent()
{
QgsMapSettings ms;

0 comments on commit 9cd3ef0

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