Skip to content

Commit

Permalink
better test for 0 objects when using pal diagram placement
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12267 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Nov 27, 2009
1 parent edd3237 commit e09330b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/core/qgspalobjectpositionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ) );
}

Expand Down

0 comments on commit e09330b

Please sign in to comment.