Skip to content

Commit

Permalink
[API] add sip bindings for QgsCsException
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 28, 2012
1 parent 3c45355 commit 2564e6a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmake/SIPMacros.cmake
Expand Up @@ -102,7 +102,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
OUTPUT ${_sip_output_files}
COMMAND ${CMAKE_COMMAND} -E echo ${message}
COMMAND ${CMAKE_COMMAND} -E touch ${_sip_output_files}
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}
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}
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
)
# not sure if type MODULE could be uses anywhere, limit to cygwin for now
Expand Down
1 change: 1 addition & 0 deletions python/core/core.sip
Expand Up @@ -6,6 +6,7 @@
%Import QtNetwork/QtNetworkmod.sip

%Include conversions.sip
%Include qgsexception.sip

// TODO: more files to wrap

Expand Down
12 changes: 6 additions & 6 deletions python/core/qgscoordinatetransform.sip
Expand Up @@ -91,7 +91,7 @@ class QgsCoordinateTransform : QObject
* @param direction TransformDirection (defaults to ForwardTransform)
* @return QgsPoint in Destination Coordinate System
*/
QgsPoint transform(const QgsPoint p,TransformDirection direction=ForwardTransform);
QgsPoint transform(const QgsPoint p,TransformDirection direction=ForwardTransform) throw (QgsCsException);

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

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

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

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

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

/*!
* Flag to indicate whether the coordinate systems have been initialised
Expand Down
17 changes: 17 additions & 0 deletions python/core/qgsexception.sip
@@ -0,0 +1,17 @@
%Exception QgsCsException(SIP_Exception) /PyName=QgsCsException/
{
%RaiseCode
SIP_BLOCK_THREADS
PyErr_SetString(sipException_QgsCsException, sipExceptionRef.what().toUtf8().constData() );
SIP_UNBLOCK_THREADS
%End
};

%Exception QgsException(SIP_Exception) /PyName=QgsException/
{
%RaiseCode
SIP_BLOCK_THREADS
PyErr_SetString(sipException_QgsException, sipExceptionRef.what().toUtf8().constData() );
SIP_UNBLOCK_THREADS
%End
};
12 changes: 11 additions & 1 deletion src/app/qgsmaptoolidentify.cpp
Expand Up @@ -324,7 +324,17 @@ bool QgsMapToolIdentify::identifyRasterLayer( QgsRasterLayer *layer, int x, int

QMap< QString, QString > attributes, derivedAttributes;
QgsPoint idPoint = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y );
idPoint = toLayerCoordinates( layer, idPoint );
try
{
idPoint = toLayerCoordinates( layer, idPoint );
}
catch( QgsCsException &cse )
{
Q_UNUSED( cse );
QgsDebugMsg( QString( "coordinate not reprojectable: %1" ).arg( cse.what() ) );
return false;
}

QString type;

if ( layer->providerType() == "wms" )
Expand Down
14 changes: 7 additions & 7 deletions src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -1885,13 +1885,13 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int theBandNo )
myRasterBandStats.statsGathered = true;

#ifdef QGISDEBUG
QgsLogger::debug( "************ STATS **************", 1, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "VALID NODATA", mValidNoDataValue, 1, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "MIN", myRasterBandStats.minimumValue, 1, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "MAX", myRasterBandStats.maximumValue, 1, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "RANGE", myRasterBandStats.range, 1, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "MEAN", myRasterBandStats.mean, 1, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "STDDEV", myRasterBandStats.stdDev, 1, __FILE__, __FUNCTION__, __LINE__ );
QgsDebugMsg( "************ STATS **************" );
QgsDebugMsg( QString( "VALID NODATA %1" ).arg( mValidNoDataValue ) );
QgsDebugMsg( QString( "MIN %1" ).arg( myRasterBandStats.minimumValue ) );
QgsDebugMsg( QString( "MAX %1" ).arg( myRasterBandStats.maximumValue ) );
QgsDebugMsg( QString( "RANGE %1" ).arg( myRasterBandStats.range ) );
QgsDebugMsg( QString( "MEAN %1" ).arg( myRasterBandStats.mean ) );
QgsDebugMsg( QString( "STDDEV %1" ).arg( myRasterBandStats.stdDev ) );
#endif

myRasterBandStats.statsGathered = true;
Expand Down

0 comments on commit 2564e6a

Please sign in to comment.