mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
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:
parent
4844a023a5
commit
4305431366
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
std::cout << "Transformed extent" << ml->coordinateTransform()->transform(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 =
|
||||
ml->coordinateTransform()->inverseTransform(
|
||||
mCanvasProperties->currentExtent);
|
||||
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,
|
||||
@ -1016,15 +1032,15 @@ void QgsMapCanvas::zoomPreviousExtent()
|
||||
|
||||
bool QgsMapCanvas::projectionsEnabled()
|
||||
{
|
||||
if (QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0)!=0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectionsEnabled",0)!=0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMapCanvas::zoomToSelected()
|
||||
{
|
||||
@ -1038,11 +1054,18 @@ void QgsMapCanvas::zoomToSelected()
|
||||
QgsRect rect ;
|
||||
if (projectionsEnabled())
|
||||
{
|
||||
rect = lyr->coordinateTransform()->transform(lyr->bBoxOfSelected());
|
||||
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();
|
||||
rect = lyr->bBoxOfSelected();
|
||||
}
|
||||
|
||||
// no selected features
|
||||
@ -1404,13 +1427,14 @@ void QgsMapCanvas::mouseReleaseEvent(QMouseEvent * e)
|
||||
if(mCaptureList.size()>1)
|
||||
{
|
||||
QPainter paint(this);
|
||||
QColor digitcolor(QgsProject::instance()->readNumEntry("Digitizing","/LineColorRedPart",255),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorGreenPart",0),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorBluePart",0));
|
||||
QColor digitcolor(QgsProject::instance()->readNumEntry("Digitizing","/LineColorRedPart",255),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorGreenPart",0),
|
||||
QgsProject::instance()->readNumEntry("Digitizing","/LineColorBluePart",0));
|
||||
paint.setPen(QPen(digitcolor,QgsProject::instance()->readNumEntry("Digitizing","/LineWidth",1),Qt::SolidLine));
|
||||
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,14 +2027,28 @@ void QgsMapCanvas::recalculateExtents()
|
||||
#ifdef QGISDEBUG
|
||||
std::cout << "Updating extent using " << lyr->name() << std::endl;
|
||||
std::cout << "Input extent: " << lyr->extent().stringRep() << std::endl;
|
||||
std::cout << "Transformed extent" << lyr->coordinateTransform()->transform(lyr->extent()) << 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())
|
||||
{
|
||||
updateFullExtent(lyr->coordinateTransform()->transform(lyr->extent()));
|
||||
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
|
||||
{
|
||||
|
@ -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?
|
||||
}
|
||||
|
@ -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
|
||||
myProjectedPoint=mCoordinateTransform->transform(pt);
|
||||
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
|
||||
myProjectedPoint=mCoordinateTransform->transform(pt);
|
||||
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
|
||||
myProjectedPoint=mCoordinateTransform->transform(pt);
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user