Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add some more geometry relationship methods to LabelPosition
- Loading branch information
Showing
with
60 additions
and
0 deletions.
-
+50
−0
src/core/pal/labelposition.cpp
-
+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 ? |
|
|
* |
|
|