[mapserver-commits] r12812 - sandbox/sdlime/rfc-77

svn at osgeo.org svn at osgeo.org
Sun Nov 27 16:30:27 EST 2011


Author: sdlime
Date: 2011-11-27 13:30:27 -0800 (Sun, 27 Nov 2011)
New Revision: 12812

Modified:
   sandbox/sdlime/rfc-77/maputil.c
Log:
Updated layer binding to consider multiple labels within a class.

Modified: sandbox/sdlime/rfc-77/maputil.c
===================================================================
--- sandbox/sdlime/rfc-77/maputil.c	2011-11-27 09:49:08 UTC (rev 12811)
+++ sandbox/sdlime/rfc-77/maputil.c	2011-11-27 21:30:27 UTC (rev 12812)
@@ -163,102 +163,107 @@
   }
 }
 
+static void bindLabel(layerObj *layer, shapeObj *shape, labelObj *label, int querymapMode) {
+  int i;
+
+  /* check the label styleObj's (TODO: do we need to use querymapMode here? */
+  for(i=0; i<label->numstyles; i++) {
+    bindStyle(layer, shape, label->styles[i], querymapMode);
+  }
+
+  if(label->numbindings > 0) {
+    if(label->bindings[MS_LABEL_BINDING_ANGLE].index != -1) {
+      label->angle = 0.0;
+      bindDoubleAttribute(&label->angle, shape->values[label->bindings[MS_LABEL_BINDING_ANGLE].index]);
+    }
+
+    if(label->bindings[MS_LABEL_BINDING_SIZE].index != -1) {
+      label->size = 1;
+      bindDoubleAttribute(&label->size, shape->values[label->bindings[MS_LABEL_BINDING_SIZE].index]);
+    }
+
+    if(label->bindings[MS_LABEL_BINDING_COLOR].index != -1) {
+      MS_INIT_COLOR(label->color, -1,-1,-1,255);
+      bindColorAttribute(&label->color, shape->values[label->bindings[MS_LABEL_BINDING_COLOR].index]);
+    }
+
+    if(label->bindings[MS_LABEL_BINDING_OUTLINECOLOR].index != -1) {
+      MS_INIT_COLOR(label->outlinecolor, -1,-1,-1,255);
+      bindColorAttribute(&label->outlinecolor, shape->values[label->bindings[MS_LABEL_BINDING_OUTLINECOLOR].index]);
+    }
+
+    if(label->bindings[MS_LABEL_BINDING_FONT].index != -1) {
+      msFree(label->font);
+      label->font = msStrdup(shape->values[label->bindings[MS_LABEL_BINDING_FONT].index]);
+    }
+
+    if(label->bindings[MS_LABEL_BINDING_PRIORITY].index != -1) {
+      label->priority = MS_DEFAULT_LABEL_PRIORITY;
+      bindIntegerAttribute(&label->priority, shape->values[label->bindings[MS_LABEL_BINDING_PRIORITY].index]);
+    }
+
+    if(label->bindings[MS_LABEL_BINDING_SHADOWSIZEX].index != -1) { 
+      label->shadowsizex = 1; 
+      bindIntegerAttribute(&label->shadowsizex, shape->values[label->bindings[MS_LABEL_BINDING_SHADOWSIZEX].index]); 
+    } 
+    if(label->bindings[MS_LABEL_BINDING_SHADOWSIZEY].index != -1) { 
+      label->shadowsizey = 1; 
+      bindIntegerAttribute(&label->shadowsizey, shape->values[label->bindings[MS_LABEL_BINDING_SHADOWSIZEY].index]); 
+    } 
+
+    if(label->bindings[MS_LABEL_BINDING_POSITION].index != -1) {
+      int tmpPosition;
+      bindIntegerAttribute(&tmpPosition, shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index]);
+      if(tmpPosition != 0) { /* is this test sufficient? */
+        label->position = tmpPosition;
+      } else { /* Integer binding failed, look for strings like cc, ul, lr, etc... */
+        if(strlen(shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index]) == 2) {
+          char *vp = shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index];
+          if(!strncasecmp(vp,"ul",2))
+            label->position = MS_UL;
+          else if(!strncasecmp(vp,"lr",2))
+            label->position = MS_LR;     
+          else if(!strncasecmp(vp,"ur",2))
+            label->position = MS_UR;     
+          else if(!strncasecmp(vp,"ll",2))
+            label->position = MS_LL;     
+          else if(!strncasecmp(vp,"cr",2))
+            label->position = MS_CR;     
+          else if(!strncasecmp(vp,"cl",2))
+            label->position = MS_CL;     
+          else if(!strncasecmp(vp,"uc",2))
+            label->position = MS_UC;     
+          else if(!strncasecmp(vp,"lc",2))
+            label->position = MS_LC;     
+          else if(!strncasecmp(vp,"cc",2))
+            label->position = MS_CC;     
+        }       
+      }
+    }
+  }
+}
+
 /*
 ** Function to bind various layer properties to shape attributes.
 */
 int msBindLayerToShape(layerObj *layer, shapeObj *shape, int querymapMode)
 {
   int i, j;
-  labelObj *label; /* for brevity */
 
   if(!layer || !shape) return MS_FAILURE;
 
+  /* check the classObj's */
   for(i=0; i<layer->numclasses; i++) {
-
     /* check the styleObj's */
     for(j=0; j<layer->class[i]->numstyles; j++) {
       bindStyle(layer, shape, layer->class[i]->styles[j], querymapMode);
-    } /* next styleObj */
-
-    /* check the labelObj */
-    label = &(layer->class[i]->label);
-
-    /* check the label styleObj's */
-    for(j=0; j<label->numstyles; j++) {
-      bindStyle(layer, shape, label->styles[j], querymapMode);
     }
 
-    if(label->numbindings > 0) {
-      if(label->bindings[MS_LABEL_BINDING_ANGLE].index != -1) {
-        label->angle = 0.0;
-        bindDoubleAttribute(&label->angle, shape->values[label->bindings[MS_LABEL_BINDING_ANGLE].index]);
-      }
-
-      if(label->bindings[MS_LABEL_BINDING_SIZE].index != -1) {
-        label->size = 1;
-        bindDoubleAttribute(&label->size, shape->values[label->bindings[MS_LABEL_BINDING_SIZE].index]);
-      }
-
-      if(label->bindings[MS_LABEL_BINDING_COLOR].index != -1) {
-        MS_INIT_COLOR(label->color, -1,-1,-1,255);
-        bindColorAttribute(&label->color, shape->values[label->bindings[MS_LABEL_BINDING_COLOR].index]);
-      }
-
-      if(label->bindings[MS_LABEL_BINDING_OUTLINECOLOR].index != -1) {
-        MS_INIT_COLOR(label->outlinecolor, -1,-1,-1,255);
-        bindColorAttribute(&label->outlinecolor, shape->values[label->bindings[MS_LABEL_BINDING_OUTLINECOLOR].index]);
-      }
-
-      if(label->bindings[MS_LABEL_BINDING_FONT].index != -1) {
-        msFree(label->font);
-        label->font = msStrdup(shape->values[label->bindings[MS_LABEL_BINDING_FONT].index]);
-      }
-
-      if(label->bindings[MS_LABEL_BINDING_PRIORITY].index != -1) {
-        label->priority = MS_DEFAULT_LABEL_PRIORITY;
-        bindIntegerAttribute(&label->priority, shape->values[label->bindings[MS_LABEL_BINDING_PRIORITY].index]);
-      }
-
-      if(label->bindings[MS_LABEL_BINDING_SHADOWSIZEX].index != -1) { 
-        label->shadowsizex = 1; 
-        bindIntegerAttribute(&label->shadowsizex, shape->values[label->bindings[MS_LABEL_BINDING_SHADOWSIZEX].index]); 
-      } 
-      if(label->bindings[MS_LABEL_BINDING_SHADOWSIZEY].index != -1) { 
-        label->shadowsizey = 1; 
-        bindIntegerAttribute(&label->shadowsizey, shape->values[label->bindings[MS_LABEL_BINDING_SHADOWSIZEY].index]); 
-      } 
-
-      if(label->bindings[MS_LABEL_BINDING_POSITION].index != -1) {
-        int tmpPosition;
-        bindIntegerAttribute(&tmpPosition, shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index]);
-        if(tmpPosition != 0) { /* is this test sufficient */
-          label->position = tmpPosition;
-        } else { /* Integer binding failed, look for strings like cc,ul,lr etc */
-          if(strlen(shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index]) == 2) {
-            char *vp = shape->values[label->bindings[MS_LABEL_BINDING_POSITION].index];
-            if(!strncasecmp(vp,"ul",2))
-              label->position = MS_UL;     
-            else if(!strncasecmp(vp,"lr",2))
-              label->position = MS_LR;     
-            else if(!strncasecmp(vp,"ur",2))
-              label->position = MS_UR;     
-            else if(!strncasecmp(vp,"ll",2))
-              label->position = MS_LL;     
-            else if(!strncasecmp(vp,"cr",2))
-              label->position = MS_CR;     
-            else if(!strncasecmp(vp,"cl",2))
-              label->position = MS_CL;     
-	    else if(!strncasecmp(vp,"uc",2))
-              label->position = MS_UC;     
-            else if(!strncasecmp(vp,"lc",2))
-              label->position = MS_LC;     
-            else if(!strncasecmp(vp,"cc",2))
-              label->position = MS_CC;     
-          }       
-        }
-      }
+    /* check the labelObj's */
+    for(j=0; j<layer->class[i]->numlabels; j++) {
+      bindLabel(layer, shape, layer->class[i]->labels[j], querymapMode);
     }
-  } /* next classObj */
+  }
 
   return MS_SUCCESS;
 }
@@ -575,7 +580,7 @@
   if(!layer || !shape) return MS_FAILURE;
 
   j = shape->classindex;
-  for(i=0; i<layer->class[j].numlabels; i++) {
+  for(i=0; i<layer->class[j]->numlabels; i++) {
 
     /* RFC 77 TODO: will evaluate label expressions here... */
 
@@ -618,7 +623,7 @@
           status = yyparse(&p);
 
           if (status != 0) {
-	    msSetError(MS_PARSEERR, "Failed to process text expression: %s", "msShapeGetAnnotation", layer->class[c]->text.string);
+	    msSetError(MS_PARSEERR, "Failed to process text expression: %s", "msShapeGetAnnotation", layer->class[j]->text.string);
 	    return MS_FAILURE;
           }
 



More information about the mapserver-commits mailing list