File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,56 @@ bool LabelPosition::isIntersect( double *bbox )
196
196
return false ;
197
197
}
198
198
199
+ bool LabelPosition::intersects ( const GEOSPreparedGeometry *geometry )
200
+ {
201
+ if ( !mGeos )
202
+ createGeosGeom ();
203
+
204
+ try
205
+ {
206
+ if ( GEOSPreparedIntersects_r ( geosContext (), geometry, mGeos ) == 1 )
207
+ {
208
+ return true ;
209
+ }
210
+ else if ( nextPart )
211
+ {
212
+ return nextPart->intersects ( geometry );
213
+ }
214
+ }
215
+ catch ( GEOSException &e )
216
+ {
217
+ QgsMessageLog::logMessage ( QObject::tr ( " Exception: %1" ).arg ( e.what () ), QObject::tr ( " GEOS" ) );
218
+ return false ;
219
+ }
220
+
221
+ return false ;
222
+ }
223
+
224
+ bool LabelPosition::within ( const GEOSPreparedGeometry *geometry )
225
+ {
226
+ if ( !mGeos )
227
+ createGeosGeom ();
228
+
229
+ try
230
+ {
231
+ if ( GEOSPreparedContains_r ( geosContext (), geometry, mGeos ) != 1 )
232
+ {
233
+ return false ;
234
+ }
235
+ else if ( nextPart )
236
+ {
237
+ return nextPart->within ( geometry );
238
+ }
239
+ }
240
+ catch ( GEOSException &e )
241
+ {
242
+ QgsMessageLog::logMessage ( QObject::tr ( " Exception: %1" ).arg ( e.what () ), QObject::tr ( " GEOS" ) );
243
+ return false ;
244
+ }
245
+
246
+ return true ;
247
+ }
248
+
199
249
bool LabelPosition::isInside ( double *bbox )
200
250
{
201
251
for ( int i = 0 ; i < 4 ; i++ )
Original file line number Diff line number Diff line change @@ -113,6 +113,16 @@ namespace pal
113
113
*/
114
114
bool isIntersect ( double *bbox );
115
115
116
+ /* *
117
+ * Returns true if the label position intersects a \a geometry.
118
+ */
119
+ bool intersects ( const GEOSPreparedGeometry *geometry );
120
+
121
+ /* *
122
+ * Returns true if the label position is within a \a geometry.
123
+ */
124
+ bool within ( const GEOSPreparedGeometry *geometry );
125
+
116
126
/* *
117
127
* \brief Is the labelposition inside the bounding-box ?
118
128
*
You can’t perform that action at this time.
0 commit comments