Skip to content
Permalink
Browse files

better test for 0 objects when using pal diagram placement

git-svn-id: http://svn.osgeo.org/qgis/trunk@12267 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Nov 27, 2009
1 parent edd3237 commit e09330bb56b4b33f043afc13745d8e3d7207081f
Showing with 14 additions and 3 deletions.
  1. +14 −3 src/core/qgspalobjectpositionmanager.cpp
@@ -142,11 +142,22 @@ void QgsPALObjectPositionManager::findObjectPositions( const QgsRenderContext& r
//pal geometry that the current label object refers to
QgsPALGeometry* referredGeometry = 0;
QgsOverlayObject* referredOverlayObject = 0;
pal::FeaturePart* referredPart = 0;

std::list<pal::LabelPosition*>::iterator labelIt = resultLabelList->begin();
for ( ; labelIt != resultLabelList->end(); ++labelIt )
{
referredGeometry = dynamic_cast<QgsPALGeometry*>(( *labelIt )->getFeaturePart()->getUserGeometry() );
if ( !*labelIt )
{
continue;
}

referredPart = ( *labelIt )->getFeaturePart();
if ( !referredPart )
{
continue;
}
referredGeometry = dynamic_cast<QgsPALGeometry*>( referredPart->getUserGeometry() );
if ( !referredGeometry )
{
continue;
@@ -160,8 +171,8 @@ void QgsPALObjectPositionManager::findObjectPositions( const QgsRenderContext& r
pal::LabelPosition* lp = *labelIt;

//QGIS takes the coordinates of the middle points
double x = (lp->getX( 0 ) + lp->getX( 1 ) + lp->getX( 2 ) + lp->getX( 3 ) ) / 4;
double y = (lp->getY( 0 ) + lp->getY( 1 ) + lp->getY( 2 ) + lp->getY( 3 ) ) / 4;
double x = ( lp->getX( 0 ) + lp->getX( 1 ) + lp->getX( 2 ) + lp->getX( 3 ) ) / 4;
double y = ( lp->getY( 0 ) + lp->getY( 1 ) + lp->getY( 2 ) + lp->getY( 3 ) ) / 4;
referredOverlayObject->addPosition( QgsPoint( x, y ) );
}

0 comments on commit e09330b

Please sign in to comment.