Wrapped some project debug statements in QGISDEBUG defs.

Implemented try...catch error handlers for all calls to QgsCoordinateTransform


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2619 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2005-01-12 01:15:41 +00:00
parent 4844a023a5
commit 4305431366
4 changed files with 104 additions and 30 deletions

View File

@ -157,7 +157,7 @@ inline QgsPoint QgsCoordinateTransform::transform(QgsPoint thePoint)
if ( ! mSourceToDestXForm->Transform( 1, &x, &y ) )
{
//something bad happened....
//throw QgsCsException(QString("Coordinate transform failed"));
throw QgsCsException(QString("Coordinate transform failed"));
}
else
{
@ -182,7 +182,7 @@ inline QgsRect QgsCoordinateTransform::transform(QgsRect theRect)
if ( ! mSourceToDestXForm->Transform( 1, &x1, &y1 ) || ! mSourceToDestXForm->Transform( 1, &x2, &y2 ) )
{
//something bad happened....
//throw QgsCsException(QString("Coordinate transform failed"));
throw QgsCsException(QString("Coordinate transform failed"));
}
else
{
@ -220,7 +220,7 @@ inline QgsRect QgsCoordinateTransform::transform(QgsRect * theRect)
if ( ! mSourceToDestXForm->Transform( 1, &x1, &y1 ) || ! mSourceToDestXForm->Transform( 1, &x2, &y2 ) )
{
//something bad happened....
//throw QgsCsException(QString("Coordinate transform failed"));
throw QgsCsException(QString("Coordinate transform failed"));
}
else
{
@ -254,7 +254,7 @@ inline QgsPoint QgsCoordinateTransform::transform(double theX, double theY)
if ( ! mSourceToDestXForm->Transform( 1, &x, &y ) )
{
//something bad happened....
//throw QgsCsException(QString("Coordinate transform failed"));
throw QgsCsException(QString("Coordinate transform failed"));
}
else
{
@ -326,7 +326,7 @@ inline QgsRect QgsCoordinateTransform::inverseTransform(QgsRect theRect)
if ( ! myResult1 || ! myResult2 )
{
//something bad happened....
// throw QgsCsException(QString("Coordinate inverse transform failed"));
throw QgsCsException(QString("Coordinate inverse transform failed"));
}
else
{
@ -363,7 +363,7 @@ inline QgsRect QgsCoordinateTransform::inverseTransform(QgsRect * theRect)
if ( ! mDestToSourceXForm->Transform( 1, &x1, &y1 ) || ! mDestToSourceXForm->Transform( 1, &x2, &y2 ) )
{
//something bad happened....
//throw QgsCsException(QString("Inverse Coordinate transform failed"));
throw QgsCsException(QString("Inverse Coordinate transform failed"));
}
else
{
@ -396,7 +396,7 @@ inline QgsPoint QgsCoordinateTransform::inverseTransform(double theX, double the
if ( ! mDestToSourceXForm->Transform( 1, &x, &y ) )
{
//something bad happened....
//throw QgsCsException(QString("Coordinate inverseTransform failed"));
throw QgsCsException(QString("Coordinate inverseTransform failed"));
}
else
{

View File

@ -750,7 +750,14 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
std::cout << "Rendering " << ml->name() << std::endl;
std::cout << "Layer minscale " << ml->minScale() << ", maxscale " << ml->maxScale() << ". Scale dep. visibility enabled? " << ml->scaleBasedVisibility() << std::endl;
std::cout << "Input extent: " << ml->extent().stringRep() << std::endl;
try
{
std::cout << "Transformed extent" << ml->coordinateTransform()->transform(ml->extent()).stringRep() << std::endl;
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
#endif
if (ml->visible())
@ -761,9 +768,18 @@ void QgsMapCanvas::render(QPaintDevice * theQPaintDevice)
//we need to find out the extent of the canvas in the layer's
//native coordinate system :. inverseProjection of the extent
//must be done....
QgsRect myProjectedRect =
QgsRect myProjectedRect;
try
{
myProjectedRect =
ml->coordinateTransform()->inverseTransform(
mCanvasProperties->currentExtent);
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
ml->draw(paint,
&myProjectedRect,
mCanvasProperties->coordXForm,
@ -1037,9 +1053,16 @@ void QgsMapCanvas::zoomToSelected()
QgsRect rect ;
if (projectionsEnabled())
{
try
{
rect = lyr->coordinateTransform()->transform(lyr->bBoxOfSelected());
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
}
else
{
rect = lyr->bBoxOfSelected();
@ -1411,6 +1434,7 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
std::list<QgsPoint>::iterator it=mCaptureList.end();
--it;
--it;
QgsPoint lastpoint = mCanvasProperties->coordXForm->transform(it->x(),it->y());
QgsPoint endpoint = mCanvasProperties->coordXForm->transform(digitisedpoint.x(),digitisedpoint.y());
paint.drawLine(static_cast<int>(lastpoint.x()),static_cast<int>(lastpoint.y()),
@ -2003,15 +2027,29 @@ void QgsMapCanvas::recalculateExtents()
#ifdef QGISDEBUG
std::cout << "Updating extent using " << lyr->name() << std::endl;
std::cout << "Input extent: " << lyr->extent().stringRep() << std::endl;
try
{
std::cout << "Transformed extent" << lyr->coordinateTransform()->transform(lyr->extent()) << std::endl;
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
#endif
// Layer extents are stored in the coordinate system (CS) of the
// layer. The extent must be projected to the canvas CS prior to passing
// on to the updateFullExtent function
if (projectionsEnabled())
{
try
{
updateFullExtent(lyr->coordinateTransform()->transform(lyr->extent()));
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
}
else
{
updateFullExtent(lyr->extent());

View File

@ -158,7 +158,9 @@ public:
// if keyName isn't empty, then something went wrong in the recursion
if ( ! keyName.empty() )
{
#ifdef QGISDEBUG
qDebug( "%s:%d PropertyValue given a non-empty keyName", __FILE__, __LINE__ );
#endif
}
// we ignore keyName since we're a leaf node and don't have one
@ -181,14 +183,18 @@ public:
if ( ! value_.isValid() )
{
#ifdef QGISDEBUG
qDebug( "%s:%d PropertyValue given an invaild value", __FILE__, __LINE__ );
#endif
return false;
}
if ( value_.isNull() )
{
#ifdef QGISDEBUG
qDebug( "%s:%d PropertyValue given a null value", __FILE__, __LINE__ );
#endif
// XXX return false; I guess this might be ok?
}

View File

@ -2010,7 +2010,13 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
if (projectionsEnabledFlag)
{
//reproject the point to the map coordinate system
try {
myProjectedPoint=mCoordinateTransform->transform(pt);
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
//transform from projected coordinate system to pixel position on map canvas
theMapToPixelTransform->transform(&myProjectedPoint);
}
@ -2050,7 +2056,13 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
if (projectionsEnabledFlag)
{
//reproject the point to the map coordinate system
try {
myProjectedPoint=mCoordinateTransform->transform(pt);
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
//transform from projected coordinate system to pixel position on map canvas
theMapToPixelTransform->transform(&myProjectedPoint);
}
@ -2093,7 +2105,13 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
if (projectionsEnabledFlag)
{
//reproject the point to the map coordinate system
try {
myProjectedPoint=mCoordinateTransform->transform(pt);
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
//transform from projected coordinate system to pixel position on map canvas
theMapToPixelTransform->transform(&myProjectedPoint);
}
@ -2163,7 +2181,13 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
if (projectionsEnabledFlag)
{
//reproject the point to the map coordinate system
try {
myProjectedPoint=mCoordinateTransform->transform(pt);
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
//transform from projected coordinate system to pixel position on map canvas
theMapToPixelTransform->transform(&myProjectedPoint);
}
@ -2242,7 +2266,13 @@ void QgsVectorLayer::drawFeature(QPainter* p, QgsFeature* fet, QgsMapToPixel * t
if (projectionsEnabledFlag)
{
//reproject the point to the map coordinate system
try {
myProjectedPoint=mCoordinateTransform->transform(pt);
}
catch (QgsCsException &e)
{
qDebug( "%s:%d Transform error caught in %s line %d:\n%s", __FILE__, __LINE__, e.what());
}
//transform from projected coordinate system to pixel position on map canvas
theMapToPixelTransform->transform(&myProjectedPoint);
}