Skip to content

Commit 2564e6a

Browse files
committed
[API] add sip bindings for QgsCsException
1 parent 3c45355 commit 2564e6a

File tree

6 files changed

+43
-15
lines changed

6 files changed

+43
-15
lines changed

cmake/SIPMacros.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
102102
OUTPUT ${_sip_output_files}
103103
COMMAND ${CMAKE_COMMAND} -E echo ${message}
104104
COMMAND ${CMAKE_COMMAND} -E touch ${_sip_output_files}
105-
COMMAND ${SIP_BINARY_PATH} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} ${_sip_includes} ${_abs_module_sip}
105+
COMMAND ${SIP_BINARY_PATH} ${_sip_tags} -e ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} ${_sip_includes} ${_abs_module_sip}
106106
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
107107
)
108108
# not sure if type MODULE could be uses anywhere, limit to cygwin for now

python/core/core.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
%Import QtNetwork/QtNetworkmod.sip
77

88
%Include conversions.sip
9+
%Include qgsexception.sip
910

1011
// TODO: more files to wrap
1112

python/core/qgscoordinatetransform.sip

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class QgsCoordinateTransform : QObject
9191
* @param direction TransformDirection (defaults to ForwardTransform)
9292
* @return QgsPoint in Destination Coordinate System
9393
*/
94-
QgsPoint transform(const QgsPoint p,TransformDirection direction=ForwardTransform);
94+
QgsPoint transform(const QgsPoint p,TransformDirection direction=ForwardTransform) throw (QgsCsException);
9595

9696
/*! Transform the point specified by x,y from Source Coordinate System to Destination Coordinate System
9797
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
@@ -101,7 +101,7 @@ class QgsCoordinateTransform : QObject
101101
* @param direction TransformDirection (defaults to ForwardTransform)
102102
* @return QgsPoint in Destination Coordinate System
103103
*/
104-
QgsPoint transform(const double x, const double y,TransformDirection direction=ForwardTransform);
104+
QgsPoint transform(const double x, const double y,TransformDirection direction=ForwardTransform) throw (QgsCsException);
105105

106106
/*! Transform a QgsRectangle to the dest Coordinate system
107107
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
@@ -113,12 +113,12 @@ class QgsCoordinateTransform : QObject
113113
* @param direction TransformDirection (defaults to ForwardTransform)
114114
* @return QgsRectangle in Destination Coordinate System
115115
*/
116-
QgsRectangle transformBoundingBox(const QgsRectangle theRect,TransformDirection direction=ForwardTransform);
116+
QgsRectangle transformBoundingBox(const QgsRectangle theRect,TransformDirection direction=ForwardTransform) throw (QgsCsException);
117117

118118
// Same as for the other transform() functions, but alters the x
119119
// and y variables in place. The second one works with good old-fashioned
120120
// C style arrays.
121-
void transformInPlace(double& x, double& y, double &z, TransformDirection direction = ForwardTransform);
121+
void transformInPlace(double& x, double& y, double &z, TransformDirection direction = ForwardTransform) throw (QgsCsException);
122122

123123
// TODO: argument not supported
124124
//void transformInPlace(std::vector<double>& x, std::vector<double>& y, std::vector<double>& z,
@@ -131,7 +131,7 @@ class QgsCoordinateTransform : QObject
131131
* @param direction TransformDirection (defaults to ForwardTransform)
132132
* @return QgsRectangle in Destination Coordinate System
133133
*/
134-
QgsRectangle transform(const QgsRectangle theRect,TransformDirection direction=ForwardTransform);
134+
QgsRectangle transform(const QgsRectangle theRect,TransformDirection direction=ForwardTransform) throw (QgsCsException);
135135

136136
/*! Transform an array of coordinates to a different Coordinate System
137137
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
@@ -141,7 +141,7 @@ class QgsCoordinateTransform : QObject
141141
* @param direction TransformDirection (defaults to ForwardTransform)
142142
* @return QgsRectangle in Destination Coordinate System
143143
*/
144-
void transformCoords( const int &numPoint, double *x, double *y, double *z,TransformDirection direction=ForwardTransform);
144+
void transformCoords( const int &numPoint, double *x, double *y, double *z,TransformDirection direction=ForwardTransform) throw (QgsCsException);
145145

146146
/*!
147147
* Flag to indicate whether the coordinate systems have been initialised

python/core/qgsexception.sip

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
%Exception QgsCsException(SIP_Exception) /PyName=QgsCsException/
2+
{
3+
%RaiseCode
4+
SIP_BLOCK_THREADS
5+
PyErr_SetString(sipException_QgsCsException, sipExceptionRef.what().toUtf8().constData() );
6+
SIP_UNBLOCK_THREADS
7+
%End
8+
};
9+
10+
%Exception QgsException(SIP_Exception) /PyName=QgsException/
11+
{
12+
%RaiseCode
13+
SIP_BLOCK_THREADS
14+
PyErr_SetString(sipException_QgsException, sipExceptionRef.what().toUtf8().constData() );
15+
SIP_UNBLOCK_THREADS
16+
%End
17+
};

src/app/qgsmaptoolidentify.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,17 @@ bool QgsMapToolIdentify::identifyRasterLayer( QgsRasterLayer *layer, int x, int
324324

325325
QMap< QString, QString > attributes, derivedAttributes;
326326
QgsPoint idPoint = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y );
327-
idPoint = toLayerCoordinates( layer, idPoint );
327+
try
328+
{
329+
idPoint = toLayerCoordinates( layer, idPoint );
330+
}
331+
catch( QgsCsException &cse )
332+
{
333+
Q_UNUSED( cse );
334+
QgsDebugMsg( QString( "coordinate not reprojectable: %1" ).arg( cse.what() ) );
335+
return false;
336+
}
337+
328338
QString type;
329339

330340
if ( layer->providerType() == "wms" )

src/providers/gdal/qgsgdalprovider.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,13 +1885,13 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int theBandNo )
18851885
myRasterBandStats.statsGathered = true;
18861886

18871887
#ifdef QGISDEBUG
1888-
QgsLogger::debug( "************ STATS **************", 1, __FILE__, __FUNCTION__, __LINE__ );
1889-
QgsLogger::debug( "VALID NODATA", mValidNoDataValue, 1, __FILE__, __FUNCTION__, __LINE__ );
1890-
QgsLogger::debug( "MIN", myRasterBandStats.minimumValue, 1, __FILE__, __FUNCTION__, __LINE__ );
1891-
QgsLogger::debug( "MAX", myRasterBandStats.maximumValue, 1, __FILE__, __FUNCTION__, __LINE__ );
1892-
QgsLogger::debug( "RANGE", myRasterBandStats.range, 1, __FILE__, __FUNCTION__, __LINE__ );
1893-
QgsLogger::debug( "MEAN", myRasterBandStats.mean, 1, __FILE__, __FUNCTION__, __LINE__ );
1894-
QgsLogger::debug( "STDDEV", myRasterBandStats.stdDev, 1, __FILE__, __FUNCTION__, __LINE__ );
1888+
QgsDebugMsg( "************ STATS **************" );
1889+
QgsDebugMsg( QString( "VALID NODATA %1" ).arg( mValidNoDataValue ) );
1890+
QgsDebugMsg( QString( "MIN %1" ).arg( myRasterBandStats.minimumValue ) );
1891+
QgsDebugMsg( QString( "MAX %1" ).arg( myRasterBandStats.maximumValue ) );
1892+
QgsDebugMsg( QString( "RANGE %1" ).arg( myRasterBandStats.range ) );
1893+
QgsDebugMsg( QString( "MEAN %1" ).arg( myRasterBandStats.mean ) );
1894+
QgsDebugMsg( QString( "STDDEV %1" ).arg( myRasterBandStats.stdDev ) );
18951895
#endif
18961896

18971897
myRasterBandStats.statsGathered = true;

0 commit comments

Comments
 (0)