File tree 3 files changed +31
-6
lines changed
3 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ namespace pal
52
52
case GEOS_LINESTRING:
53
53
54
54
// Is one of label's borders crossing the line ?
55
- n = ( lp->isBorderCrossingLine ( obstacle ) ? 1 : 0 );
55
+ n = ( lp->crossesLine ( obstacle ) ? 1 : 0 );
56
56
break ;
57
57
58
58
case GEOS_POLYGON:
@@ -65,7 +65,7 @@ namespace pal
65
65
break ;
66
66
case PolygonBoundary:
67
67
// penalty may need tweaking, given that interior mode ranges up to 12
68
- n = ( lp->isBorderCrossingLine ( obstacle ) ? 6 : 0 );
68
+ n = ( lp->crossesBoundary ( obstacle ) ? 6 : 0 );
69
69
break ;
70
70
}
71
71
Original file line number Diff line number Diff line change @@ -500,7 +500,7 @@ namespace pal
500
500
return distance;
501
501
}
502
502
503
- bool LabelPosition::isBorderCrossingLine ( PointSet* line ) const
503
+ bool LabelPosition::crossesLine ( PointSet* line ) const
504
504
{
505
505
if ( !mGeos )
506
506
createGeosGeom ();
@@ -509,13 +509,35 @@ namespace pal
509
509
line->createGeosGeom ();
510
510
511
511
GEOSContextHandle_t geosctxt = geosContext ();
512
- if ( GEOSPreparedIntersects_r ( geosctxt, preparedGeom (), line-> mGeos ) == 1 )
512
+ if ( GEOSPreparedIntersects_r ( geosctxt, line-> preparedGeom (), mGeos ) == 1 )
513
513
{
514
514
return true ;
515
515
}
516
516
else if ( nextPart )
517
517
{
518
- return nextPart->isBorderCrossingLine ( line );
518
+ return nextPart->crossesLine ( line );
519
+ }
520
+
521
+ return false ;
522
+ }
523
+
524
+ bool LabelPosition::crossesBoundary ( PointSet *polygon ) const
525
+ {
526
+ if ( !mGeos )
527
+ createGeosGeom ();
528
+
529
+ if ( !polygon->mGeos )
530
+ polygon->createGeosGeom ();
531
+
532
+ GEOSContextHandle_t geosctxt = geosContext ();
533
+ if ( GEOSPreparedOverlaps_r ( geosctxt, polygon->preparedGeom (), mGeos ) == 1
534
+ || GEOSPreparedTouches_r ( geosctxt, polygon->preparedGeom (), mGeos ) == 1 )
535
+ {
536
+ return true ;
537
+ }
538
+ else if ( nextPart )
539
+ {
540
+ return nextPart->crossesBoundary ( polygon );
519
541
}
520
542
521
543
return false ;
Original file line number Diff line number Diff line change @@ -128,7 +128,10 @@ namespace pal
128
128
double getDistanceToPoint ( double xp, double yp ) const ;
129
129
130
130
/* * Returns true if this label crosses the specified line */
131
- bool isBorderCrossingLine ( PointSet* line ) const ;
131
+ bool crossesLine ( PointSet* line ) const ;
132
+
133
+ /* * Returns true if this label crosses the boundary of the specified polygon */
134
+ bool crossesBoundary ( PointSet* polygon ) const ;
132
135
133
136
/* * Returns number of intersections with polygon (testing border and center) */
134
137
int getNumPointsInPolygon ( PointSet* polygon ) const ;
You can’t perform that action at this time.
0 commit comments