Skip to content
Permalink
Browse files

Add some more geometry relationship methods to LabelPosition

  • Loading branch information
nyalldawson committed Jan 17, 2018
1 parent dded4ab commit 2d71309ef8b29b5c894d26c9c81f58d5674b7207
Showing with 60 additions and 0 deletions.
  1. +50 −0 src/core/pal/labelposition.cpp
  2. +10 −0 src/core/pal/labelposition.h
@@ -196,6 +196,56 @@ bool LabelPosition::isIntersect( double *bbox )
return false;
}

bool LabelPosition::intersects( const GEOSPreparedGeometry *geometry )
{
if ( !mGeos )
createGeosGeom();

try
{
if ( GEOSPreparedIntersects_r( geosContext(), geometry, mGeos ) == 1 )
{
return true;
}
else if ( nextPart )
{
return nextPart->intersects( geometry );
}
}
catch ( GEOSException &e )
{
QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
return false;
}

return false;
}

bool LabelPosition::within( const GEOSPreparedGeometry *geometry )
{
if ( !mGeos )
createGeosGeom();

try
{
if ( GEOSPreparedContains_r( geosContext(), geometry, mGeos ) != 1 )
{
return false;
}
else if ( nextPart )
{
return nextPart->within( geometry );
}
}
catch ( GEOSException &e )
{
QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
return false;
}

return true;
}

bool LabelPosition::isInside( double *bbox )
{
for ( int i = 0; i < 4; i++ )
@@ -113,6 +113,16 @@ namespace pal
*/
bool isIntersect( double *bbox );

/**
* Returns true if the label position intersects a \a geometry.
*/
bool intersects( const GEOSPreparedGeometry *geometry );

/**
* Returns true if the label position is within a \a geometry.
*/
bool within( const GEOSPreparedGeometry *geometry );

/**
* \brief Is the labelposition inside the bounding-box ?
*

0 comments on commit 2d71309

Please sign in to comment.
You can’t perform that action at this time.