Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add argument to QgsCoordinateTransform::transformBoundingBox to flag …
…that handling of a bounding box which crosses the 180 degree longitude line is required. Fix composer map reprojected grids which cross 180 degree line.
- Loading branch information
1 parent
d66e4dc
commit a2d5acb
Showing
6 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*************************************************************************** | ||
testqgscoordinatetransform.cpp | ||
----------------------- | ||
begin : October 2014 | ||
copyright : (C) 2014 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#include "qgscoordinatetransform.h" | ||
#include "qgsapplication.h" | ||
#include <QObject> | ||
#include <QtTest> | ||
|
||
class TestQgsCoordinateTransform: public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
private slots: | ||
void initTestCase(); | ||
void transformBoundingBox(); | ||
|
||
private: | ||
|
||
}; | ||
|
||
|
||
void TestQgsCoordinateTransform::initTestCase() | ||
{ | ||
QgsApplication::init(); | ||
QgsApplication::initQgis(); | ||
|
||
} | ||
|
||
void TestQgsCoordinateTransform::transformBoundingBox() | ||
{ | ||
//test transforming a bounding box which crosses the 180 degree longitude line | ||
QgsCoordinateReferenceSystem sourceSrs; | ||
sourceSrs.createFromSrid( 3994 ); | ||
QgsCoordinateReferenceSystem destSrs; | ||
destSrs.createFromSrid( 4326 ); | ||
|
||
QgsCoordinateTransform tr( sourceSrs, destSrs ); | ||
QgsRectangle crossingRect( 6374985, -3626584, 7021195, -3272435 ); | ||
QgsRectangle resultRect = tr.transformBoundingBox( crossingRect, QgsCoordinateTransform::ForwardTransform, true ); | ||
QgsRectangle expectedRect; | ||
expectedRect.setXMinimum( 175.771 ); | ||
expectedRect.setYMinimum( -39.7222 ); | ||
expectedRect.setXMaximum( -176.549 ); | ||
expectedRect.setYMaximum( -36.3951 ); | ||
QVERIFY( qgsDoubleNear( resultRect.xMinimum(), expectedRect.xMinimum(), 0.001 ) ); | ||
QVERIFY( qgsDoubleNear( resultRect.yMinimum(), expectedRect.yMinimum(), 0.001 ) ); | ||
QVERIFY( qgsDoubleNear( resultRect.xMaximum(), expectedRect.xMaximum(), 0.001 ) ); | ||
QVERIFY( qgsDoubleNear( resultRect.yMaximum(), expectedRect.yMaximum(), 0.001 ) ); | ||
} | ||
|
||
QTEST_MAIN( TestQgsCoordinateTransform ) | ||
#include "moc_testqgscoordinatetransform.cxx" |