MCPcopy Create free account
hub / github.com/MapServer/MapServer / intersectLabelPolygons

Function intersectLabelPolygons

maplabel.c:986–1021  ·  view source on GitHub ↗

static int intersectLabelPolygons(shapeObj *p1, shapeObj *p2) { */

Source from the content-addressed store, hash-verified

984
985/* static int intersectLabelPolygons(shapeObj *p1, shapeObj *p2) { */
986int intersectLabelPolygons(shapeObj *p1, shapeObj *p2) {
987 int c1,v1,c2,v2;
988 pointObj *point;
989
990 /* STEP 0: check bounding boxes */
991 if(!msRectOverlap(&p1->bounds, &p2->bounds)) /* from alans@wunderground.com */
992 return(MS_FALSE);
993
994 /* STEP 1: look for intersecting line segments */
995 for(c1=0; c1<p1->numlines; c1++)
996 for(v1=1; v1<p1->line[c1].numpoints; v1++)
997 for(c2=0; c2<p2->numlines; c2++)
998 for(v2=1; v2<p2->line[c2].numpoints; v2++)
999 if(msIntersectSegments(&(p1->line[c1].point[v1-1]), &(p1->line[c1].point[v1]), &(p2->line[c2].point[v2-1]), &(p2->line[c2].point[v2])) == MS_TRUE)
1000 return(MS_TRUE);
1001
1002 /* STEP 2: polygon one completely contains two (only need to check one point from each part) */
1003 for(c2=0; c2<p2->numlines; c2++) {
1004 point = &(p2->line[c2].point[0]);
1005 for(c1=0; c1<p1->numlines; c1++) {
1006 if(msPointInPolygon(point, &p1->line[c1]) == MS_TRUE) /* ok, the point is in a polygon */
1007 return(MS_TRUE);
1008 }
1009 }
1010
1011 /* STEP 3: polygon two completely contains one (only need to check one point from each part) */
1012 for(c1=0; c1<p1->numlines; c1++) {
1013 point = &(p1->line[c1].point[0]);
1014 for(c2=0; c2<p2->numlines; c2++) {
1015 if(msPointInPolygon(point, &p2->line[c2]) == MS_TRUE) /* ok, the point is in a polygon */
1016 return(MS_TRUE);
1017 }
1018 }
1019
1020 return(MS_FALSE);
1021}
1022
1023/* For MapScript, exactly the same the msInsertStyle */
1024int msInsertLabelStyle(labelObj *label, styleObj *style, int nStyleIndex) {

Callers 1

Calls 3

msRectOverlapFunction · 0.85
msIntersectSegmentsFunction · 0.85
msPointInPolygonFunction · 0.85

Tested by

no test coverage detected