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

svn at osgeo.org svn at osgeo.org
Sun Nov 27 23:12:18 EST 2011


Author: sdlime
Date: 2011-11-27 20:12:18 -0800 (Sun, 27 Nov 2011)
New Revision: 12815

Modified:
   sandbox/sdlime/rfc-77/mapcopy.c
   sandbox/sdlime/rfc-77/maplabel.c
   sandbox/sdlime/rfc-77/maplayer.c
   sandbox/sdlime/rfc-77/mapserver.h
   sandbox/sdlime/rfc-77/maputil.c
Log:
All the major struct changes are in place. On to mapdraw.c...

Modified: sandbox/sdlime/rfc-77/mapcopy.c
===================================================================
--- sandbox/sdlime/rfc-77/mapcopy.c	2011-11-27 23:23:37 UTC (rev 12814)
+++ sandbox/sdlime/rfc-77/mapcopy.c	2011-11-28 04:12:18 UTC (rev 12815)
@@ -548,29 +548,33 @@
  * make exact copies, this method might not get much use.              *
  **********************************************************************/
 
-int msCopyLabelCacheMember(labelCacheMemberObj *dst,
-                           labelCacheMemberObj *src)
+int msCopyLabelCacheMember(labelCacheMemberObj *dst, labelCacheMemberObj *src)
 {
-    int i;
+  int i;
 
-    MS_COPYSTRING(dst->text, src->text);
-    MS_COPYSTELEM(featuresize);
-    MS_COPYSTELEM(numstyles);
+  MS_COPYSTELEM(featuresize);
 
-    for (i = 0; i < dst->numstyles; i++) {
-        msCopyStyle(&(dst->styles[i]), &(src->styles[i]));
-    }
+  MS_COPYSTELEM(numstyles);
+  dst->styles = (styleObj *) msSmallMalloc(sizeof(styleObj)*dst->numstyles);
+  for (i = 0; i < dst->numstyles; i++) {
+    msCopyStyle(&(dst->styles[i]), &(src->styles[i]));
+  }
 
-    msCopyLabel(&(dst->label), &(src->label));
-    MS_COPYSTELEM(layerindex);
-    MS_COPYSTELEM(classindex);
-    MS_COPYSTELEM(tileindex);
-    MS_COPYSTELEM(shapeindex);
-    MS_COPYPOINT(&(dst->point), &(src->point));
-    /* msCopyShape(&(dst->poly), &(src->poly)); */
-    MS_COPYSTELEM(status);
+  MS_COPYSTELEM(numlabels);
+  dst->labels = (labelObj *) msSmallMalloc(sizeof(labelObj)*dst->numlabels);
+  for (i = 0; i < dst->numlabels; i++) {
+    msCopyLabel(&(dst->labels[i]), &(src->labels[i]));
+  }
 
-    return MS_SUCCESS;
+  MS_COPYSTELEM(layerindex);
+  MS_COPYSTELEM(classindex);
+  MS_COPYSTELEM(tileindex);
+  MS_COPYSTELEM(shapeindex);
+  MS_COPYPOINT(&(dst->point), &(src->point));
+  /* msCopyShape(&(dst->poly), &(src->poly)); */
+  MS_COPYSTELEM(status);
+
+  return MS_SUCCESS;
 }
 
 /***********************************************************************

Modified: sandbox/sdlime/rfc-77/maplabel.c
===================================================================
--- sandbox/sdlime/rfc-77/maplabel.c	2011-11-27 23:23:37 UTC (rev 12814)
+++ sandbox/sdlime/rfc-77/maplabel.c	2011-11-28 04:12:18 UTC (rev 12815)
@@ -302,96 +302,92 @@
     return newtext;
 }
 
-int msAddLabel(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label )
+// int msAddLabel(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label )
+int msAddLabel(mapObj *map, layerObj *layer, shapeObj *shape, pointObj *labelpoint, labelPathObj *labelpath, double featuresize)
 {
-  int i;
-  labelCacheSlotObj *cacheslot;
+  int i, priority;
+  labelCacheSlotObj *slot;
 
   labelCacheMemberObj *cachePtr=NULL;
-  layerObj *layerPtr=NULL;
   classObj *classPtr=NULL;
 
-  if(!string) return(MS_SUCCESS); /* not an error */ 
+  if(!map || !layer || !shape) return MS_FAILURE; /* missing required parameters */
+  if(!labelpoint && !labelpath) return MS_FAILURE; /* need either a label point or path */
 
-  layerPtr = (GET_LAYER(map, layerindex)); /* set up a few pointers for clarity */
-  classPtr = GET_LAYER(map, layerindex)->class[classindex];
+  classPtr = layer->class[shape->classindex];
+  if(classPtr->numlabels != shape->numtext) return MS_FAILURE; /* shouldn't happen */
 
-  if( label == NULL )
-    label = &(classPtr->label);
+  /* TODO: RFC 77: could happen in msShapeGetAnnotation() or move to the numtext/numlabels loops below */
+  // if(map->scaledenom > 0) {
+  //   if((label->maxscaledenom != -1) && (map->scaledenom >= label->maxscaledenom))
+  //     return(MS_SUCCESS);
+  //   if((label->minscaledenom != -1) && (map->scaledenom < label->minscaledenom))
+  //     return(MS_SUCCESS);
+  // }
 
-  if(map->scaledenom > 0) {
-    if((label->maxscaledenom != -1) && (map->scaledenom >= label->maxscaledenom))
-      return(MS_SUCCESS);
-    if((label->minscaledenom != -1) && (map->scaledenom < label->minscaledenom))
-      return(MS_SUCCESS);
-  }
+  /* validate label priority value and get ref on label cache for it */
+  priority = classPtr->labels[0]->priority; /* take priority from the first label */
+  if (priority < 1)
+    priority = 1;
+  else if (priority > MS_MAX_LABEL_PRIORITY)
+    priority = MS_MAX_LABEL_PRIORITY;
 
-  /* Validate label priority value and get ref on label cache for it */
-  if (label->priority < 1)
-    label->priority = 1;
-  else if (label->priority > MS_MAX_LABEL_PRIORITY)
-    label->priority = MS_MAX_LABEL_PRIORITY;
+  slot = &(map->labelcache.slots[priority-1]);
 
-  cacheslot = &(map->labelcache.slots[label->priority-1]);
-
-  if(cacheslot->numlabels == cacheslot->cachesize) { /* just add it to the end */
-    cacheslot->labels = (labelCacheMemberObj *) realloc(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT));
-    MS_CHECK_ALLOC(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE);
-    cacheslot->cachesize += MS_LABELCACHEINCREMENT;
+  if(slot->numlabels == slot->cachesize) { /* just add it to the end */
+    slot->labels = (labelCacheMemberObj *) realloc(slot->labels, sizeof(labelCacheMemberObj)*(slot->cachesize+MS_LABELCACHEINCREMENT));
+    MS_CHECK_ALLOC(slot->labels, sizeof(labelCacheMemberObj)*(slot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE);
+    slot->cachesize += MS_LABELCACHEINCREMENT;
   }
 
-  cachePtr = &(cacheslot->labels[cacheslot->numlabels]);
+  cachePtr = &(slot->labels[slot->numlabels]);
 
-  cachePtr->layerindex = layerindex; /* so we can get back to this *raw* data if necessary */
-  cachePtr->classindex = classindex;
+  cachePtr->layerindex = layer->index; /* so we can get back to this *raw* data if necessary */
+  cachePtr->classindex = shape->classindex;
 
-  if(shape) {
-    cachePtr->tileindex = shape->tileindex;
-    cachePtr->shapeindex = shape->index;
-    cachePtr->shapetype = shape->type;
-  } else {
-    cachePtr->tileindex = cachePtr->shapeindex = -1;    
-    cachePtr->shapetype = MS_SHAPE_POINT;
-  }
+  cachePtr->tileindex = shape->tileindex; /* shape argument *is* required, but doesn't necessarily have to  */
+  cachePtr->shapeindex = shape->index;
+  cachePtr->shapetype = shape->type;
 
-  /* Store the label point or the label path (Bug #1620) */
-  if ( point ) {
-    cachePtr->point = *point; /* the actual label point */
+  /* Store the label point or the label path (bug #1620) */
+  if(labelpoint) {
+    cachePtr->point = *labelpoint; /* the actual label point */
     cachePtr->point.x = MS_NINT(cachePtr->point.x);
     cachePtr->point.y = MS_NINT(cachePtr->point.y);
     cachePtr->labelpath = NULL;
-  } else if ( labelpath ) {
+  } else if(labelpath) {
     int i;
     cachePtr->labelpath = labelpath;
-    /* Use the middle point of the labelpath for mindistance calculations */
-    i = labelpath->path.numpoints / 2;
+    i = labelpath->path.numpoints / 2; /* Use the middle point of the labelpath for mindistance calculations */
     cachePtr->point.x = MS_NINT(labelpath->path.point[i].x);
     cachePtr->point.y = MS_NINT(labelpath->path.point[i].y);
   }
 
-  cachePtr->text = msStrdup(string); /* the actual text */
+  cachePtr->text = (char **) msSmallMalloc(sizeof(char *)*shape->numtext);
+  for(i=0; i<shape->numtext; i++)
+    cachePtr->text[i] = msStrdup(shape->text[i]); /* text to be rendered */
 
   /* TODO: perhaps we can get rid of this next section and just store a marker size? Why do we cache the styles for a point layer? */
 
-  /* copy the styles (only if there is an accompanying marker)
-   * We cannot simply keeep refs because the rendering code alters some members of the style objects
-   */
+  /* copy the styles (only if there is an accompanying marker):
+  **   we cannot simply keep refs because the rendering code alters some members of the style objects
+  */
+  cachePtr->numstyles = 0;
   cachePtr->styles = NULL;
-  cachePtr->numstyles = 0;
-  if(layerPtr->type == MS_LAYER_ANNOTATION && classPtr->numstyles > 0) {
+  if(layer->type == MS_LAYER_ANNOTATION && classPtr->numstyles > 0) {
     cachePtr->numstyles = classPtr->numstyles;
-    cachePtr->styles = (styleObj *) msSmallMalloc(sizeof(styleObj)*classPtr->numstyles);
-    if (classPtr->numstyles > 0) {
-      for(i=0; i<classPtr->numstyles; i++) {
-	initStyle(&(cachePtr->styles[i]));
-	msCopyStyle(&(cachePtr->styles[i]), classPtr->styles[i]);
-      }
-    }
+    cachePtr->styles = (styleObj *) msSmallMalloc(sizeof(styleObj)*cachePtr->numstyles);
+    for(i=0; i<cachePtr->numstyles; i++)
+      msCopyStyle(&(cachePtr->styles[i]), classPtr->styles[i]);
   }
 
-  /* copy the label */
-  initLabel(&(cachePtr->label));
-  msCopyLabel(&(cachePtr->label), label);
+  /* copy the labels:
+  **   we cannot simply keep refs because the rendering code alters some members of the style objects
+  */
+  cachePtr->numlabels = classPtr->numlabels;
+  cachePtr->labels = (labelObj *) msSmallMalloc(sizeof(labelObj)*cachePtr->numlabels);
+  for(i=0; i<cachePtr->numlabels; i++)
+    msCopyLabel(&(cachePtr->labels[i]), classPtr->labels[i]);
 
   cachePtr->markerid = -1;
 
@@ -402,51 +398,62 @@
 
   cachePtr->status = MS_FALSE;
 
-  if(layerPtr->type == MS_LAYER_POINT) { /* cache the marker placement, it's already on the map */
+  if(layer->type == MS_LAYER_POINT) { /* cache the marker placement, it's already on the map */
     rectObj rect;
     int w, h;
 
-    if(cacheslot->nummarkers == cacheslot->markercachesize) { /* just add it to the end */
-      cacheslot->markers = (markerCacheMemberObj *) realloc(cacheslot->markers, sizeof(markerCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT));
-      MS_CHECK_ALLOC(cacheslot->markers, sizeof(markerCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE); 
-      cacheslot->markercachesize+=MS_LABELCACHEINCREMENT;
+    if(slot->nummarkers == slot->markercachesize) { /* just add it to the end */
+      slot->markers = (markerCacheMemberObj *) realloc(slot->markers, sizeof(markerCacheMemberObj)*(slot->cachesize+MS_LABELCACHEINCREMENT));
+      MS_CHECK_ALLOC(slot->markers, sizeof(markerCacheMemberObj)*(slot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE); 
+      slot->markercachesize+=MS_LABELCACHEINCREMENT;
     }
 
-    i = cacheslot->nummarkers;
+    i = slot->nummarkers;
 
-    cacheslot->markers[i].poly = (shapeObj *) msSmallMalloc(sizeof(shapeObj));
-    msInitShape(cacheslot->markers[i].poly);
+    slot->markers[i].poly = (shapeObj *) msSmallMalloc(sizeof(shapeObj));
+    msInitShape(slot->markers[i].poly);
 
     /* TO DO: at the moment only checks the bottom style, perhaps should check all of them */
     /* #2347: after RFC-24 classPtr->styles could be NULL so we check it */
     if(classPtr->styles != NULL) {
-      if(msGetMarkerSize(&map->symbolset, classPtr->styles[0], &w, &h, layerPtr->scalefactor) != MS_SUCCESS) 
+      if(msGetMarkerSize(&map->symbolset, classPtr->styles[0], &w, &h, layer->scalefactor) != MS_SUCCESS) 
         return(MS_FAILURE);
     } else {
-      msSetError(MS_MISCERR, "msAddLabel error: missing style definition for layer '%s'", "msAddLabel()", layerPtr->name);
+      msSetError(MS_MISCERR, "msAddLabel error: missing style definition for layer '%s'", "msAddLabel()", layer->name);
       return(MS_FAILURE);
     }
-    rect.minx = MS_NINT(point->x - .5 * w);
-    rect.miny = MS_NINT(point->y - .5 * h);
+    rect.minx = MS_NINT(labelpoint->x - .5 * w);
+    rect.miny = MS_NINT(labelpoint->y - .5 * h);
     rect.maxx = rect.minx + (w-1);
     rect.maxy = rect.miny + (h-1);
-    msRectToPolygon(rect, cacheslot->markers[i].poly);    
-    cacheslot->markers[i].id = cacheslot->numlabels;
+    msRectToPolygon(rect, slot->markers[i].poly);    
+    slot->markers[i].id = slot->numlabels;
  
     cachePtr->markerid = i;
 
-    cacheslot->nummarkers++;
+    slot->nummarkers++;
   }
 
-  cacheslot->numlabels++;
+  slot->numlabels++;
 
-  /* Maintain main labelCacheObj.numlabels only for backwards compatibility */
+  /* maintain main labelCacheObj.numlabels only for backwards compatibility */
   map->labelcache.numlabels++;
 
   return(MS_SUCCESS);
 }
 
-/* msTestLabelCacheCollisions()
+static int compareLabelText(char **text1, int numtext1, char **text2, int numtext2) {
+  int i, j;
+  for(i=0; i<numtext1; i++) {
+    for(j=0; j<numtext2; j++) {
+      if(strcmp(text1[i], text2[j]) == 0) return MS_TRUE;
+    }
+  }
+  return MS_FALSE; /* no exact matches in either array */
+}
+
+/* 
+** msTestLabelCacheCollisions()
 **
 ** Compares current label against labels already drawn and markers from cache and discards it
 ** by setting cachePtr->status=MS_FALSE if it is a duplicate, collides with another label,
@@ -459,66 +466,72 @@
                                 labelCacheMemberObj *cachePtr, int current_priority, 
                                 int current_label, int mindistance, double label_size)
 {
-    int i, p;
+  int i, p;
 
-    /* Check against image bounds first 
-    ** Pass mapwidth=-1 to skip this test
-     */
-    if(!labelPtr->partials && mapwidth > 0 && mapheight > 0) {
-        if(labelInImage(mapwidth, mapheight, cachePtr->poly, buffer) == MS_FALSE) {
-	    cachePtr->status = MS_FALSE;
-            return;
-        }
+  /* 
+  ** Check against image bounds first. Pass mapwidth=-1 and mapheight=-1 to skip this test.
+  */
+  if(!labelPtr->partials && mapwidth > 0 && mapheight > 0) {
+    if(labelInImage(mapwidth, mapheight, cachePtr->poly, buffer) == MS_FALSE) {
+      cachePtr->status = MS_FALSE;
+      return;
     }
+  }
 
-    /* Compare against all rendered markers from this priority level and higher.
-    ** Labels can overlap their own marker and markers from lower priority levels
-    */
-    for (p=current_priority; p < MS_MAX_LABEL_PRIORITY; p++) {
-        labelCacheSlotObj *markerslot;
-        markerslot = &(labelcache->slots[p]);
+  /* 
+  ** Compare against all rendered markers from this priority level and higher.
+  ** Labels can overlap their own marker and markers from lower priority levels.
+  */
+  for (p=current_priority; p < MS_MAX_LABEL_PRIORITY; p++) {
+    labelCacheSlotObj *markerslot;
+    markerslot = &(labelcache->slots[p]);
 
-        for ( i = 0; i < markerslot->nummarkers; i++ ) {
-            if ( !(p == current_priority && current_label == markerslot->markers[i].id) ) {  /* labels can overlap their own marker */
-                if ( intersectLabelPolygons(markerslot->markers[i].poly, cachePtr->poly ) == MS_TRUE ) {
-                    cachePtr->status = MS_FALSE;  /* polys intersect */
-                    return;
-                }
-            }
+    for ( i = 0; i < markerslot->nummarkers; i++ ) {
+      if ( !(p == current_priority && current_label == markerslot->markers[i].id) ) {  /* labels can overlap their own marker */
+        if ( intersectLabelPolygons(markerslot->markers[i].poly, cachePtr->poly ) == MS_TRUE ) {
+          cachePtr->status = MS_FALSE;  /* polys intersect */
+          return;
         }
+      }
     }
+  }
 
-    /* compare against rendered labels */
-    i = current_label+1;
+  /*
+  ** Compare against rendered labels 
+  */
+  i = current_label+1;
 
-    for(p=current_priority; p<MS_MAX_LABEL_PRIORITY; p++) {
-        labelCacheSlotObj *cacheslot;
-        cacheslot = &(labelcache->slots[p]);
+  for (p=current_priority; p<MS_MAX_LABEL_PRIORITY; p++) {
+    labelCacheSlotObj *cacheslot;
+    cacheslot = &(labelcache->slots[p]);
 
-        for(  ; i < cacheslot->numlabels; i++) { 
-            if(cacheslot->labels[i].status == MS_TRUE) { /* compare bounding polygons and check for duplicates */
-                /* We add the label_size to the mindistance value when comparing because we do want the mindistance 
-                   value between the labels and not only from point to point. */
-                if(label_size > 0 && (mindistance != -1) && 
-                   (cachePtr->layerindex == cacheslot->labels[i].layerindex) && (cachePtr->classindex == cacheslot->labels[i].classindex) && 
-                   (strcmp(cachePtr->text,cacheslot->labels[i].text) == 0) &&
-                   (msDistancePointToPoint(&(cachePtr->point), &(cacheslot->labels[i].point)) <= (mindistance + label_size))) { /* label is a duplicate */
-                    cachePtr->status = MS_FALSE;
-                    return;
-                }
+    for (  ; i < cacheslot->numlabels; i++) { 
+      if(cacheslot->labels[i].status == MS_TRUE) { /* compare bounding polygons and check for duplicates */
 
-                if(intersectLabelPolygons(cacheslot->labels[i].poly, cachePtr->poly) == MS_TRUE) { /* polys intersect */
-                    cachePtr->status = MS_FALSE;
-                    return;
-                }
-            }
-        } /* i */
+        /* 
+        ** We add the label_size to the mindistance value when comparing because we do want the mindistance 
+        ** value between the labels and not only from point to point. 
+        **   (TODO: how to handle in RFC77 with mindistance, index checks are ok)
+        */
+        if(label_size > 0 && (mindistance != -1) && 
+            (cachePtr->layerindex == cacheslot->labels[i].layerindex) && (cachePtr->classindex == cacheslot->labels[i].classindex) && 
+	    (compareLabelText(cachePtr->text, cachePtr->numlabels, cacheslot->labels[i].text, cacheslot->numlabels) == MS_TRUE) &&
+            (msDistancePointToPoint(&(cachePtr->point), &(cacheslot->labels[i].point)) <= (mindistance + label_size))) { /* label is a duplicate */
+          cachePtr->status = MS_FALSE;
+          return;
+        }
 
-        i = 0; /* Start over with 1st label of next slot */
-    } /* p */
+        if(intersectLabelPolygons(cacheslot->labels[i].poly, cachePtr->poly) == MS_TRUE) { /* polys intersect */
+          cachePtr->status = MS_FALSE;
+          return;
+        }
+      }
+    } /* i */
+
+    i = 0; /* Start over with 1st label of next slot */
+  } /* p */
 }
 
-
 /* msGetLabelCacheMember()
 **
 ** Returns label cache members by index, making all members of the cache

Modified: sandbox/sdlime/rfc-77/maplayer.c
===================================================================
--- sandbox/sdlime/rfc-77/maplayer.c	2011-11-27 23:23:37 UTC (rev 12814)
+++ sandbox/sdlime/rfc-77/maplayer.c	2011-11-28 04:12:18 UTC (rev 12815)
@@ -461,7 +461,7 @@
 */
 int msLayerWhichItems(layerObj *layer, int get_all, char *metadata)
 {
-  int i, j, k, rv;
+  int i, j, k, l, rv;
   int nt=0;
 
   if (!layer->vtable) {
@@ -510,12 +510,16 @@
     if(layer->class[i]->expression.type == MS_EXPRESSION)
       nt += msCountChars(layer->class[i]->expression.string, '[');
 
-    nt += layer->class[i]->label.numbindings;
-    for(j=0; j<layer->class[i]->label.numstyles; j++) {
-      if(layer->class[i]->label.styles[j]->rangeitem) nt++;
-      nt += layer->class[i]->label.styles[j]->numbindings;
-      if(layer->class[i]->label.styles[j]->_geomtransform.type == MS_GEOMTRANSFORM_EXPRESSION)
-        nt += msCountChars(layer->class[i]->label.styles[j]->_geomtransform.string, '[');
+    for(l=0; l<layer->class[i]->numlabels; l++) {
+      nt += layer->class[i]->labels[l]->numbindings;
+      for(k=0; k<layer->class[i]->labels[l]->numstyles; k++) {
+        if(layer->class[i]->labels[l]->styles[j]->rangeitem) nt++;
+        nt += layer->class[i]->labels[l]->styles[j]->numbindings;
+        if(layer->class[i]->labels[l]->styles[j]->_geomtransform.type == MS_GEOMTRANSFORM_EXPRESSION)
+          nt += msCountChars(layer->class[i]->labels[l]->styles[j]->_geomtransform.string, '[');
+      }
+
+      /* RFC 77: will need to support expression and text attributes here... */
     }
 
     if(layer->class[i]->text.type == MS_EXPRESSION || (layer->class[i]->text.string && strchr(layer->class[i]->text.string,'[') != NULL && strchr(layer->class[i]->text.string,']') != NULL))
@@ -562,19 +566,23 @@
         if(layer->class[i]->styles[j]->_geomtransform.type == MS_GEOMTRANSFORM_EXPRESSION) 
           msTokenizeExpression(&(layer->class[i]->styles[j]->_geomtransform), layer->items, &(layer->numitems));
       }
-      for(j=0; j<layer->class[i]->label.numstyles; j++) {
-        if(layer->class[i]->label.styles[j]->rangeitem) layer->class[i]->label.styles[j]->rangeitemindex = string2list(layer->items, &(layer->numitems), layer->class[i]->label.styles[j]->rangeitem);
-        for(k=0; k<MS_STYLE_BINDING_LENGTH; k++)
-          if(layer->class[i]->label.styles[j]->bindings[k].item) layer->class[i]->label.styles[j]->bindings[k].index = string2list(layer->items, &(layer->numitems), layer->class[i]->label.styles[j]->bindings[k].item);
-        if(layer->class[i]->label.styles[j]->_geomtransform.type == MS_GEOMTRANSFORM_EXPRESSION) 
-          msTokenizeExpression(&(layer->class[i]->label.styles[j]->_geomtransform), layer->items, &(layer->numitems));
+
+      /* class labels and label styles (items, bindings, geomtransform) */
+      for(l=0; l<layer->class[i]->numlabels; l++) {
+        for(j=0; j<layer->class[i]->labels[l]->numstyles; j++) {
+          if(layer->class[i]->labels[l]->styles[j]->rangeitem) layer->class[i]->labels[l]->styles[j]->rangeitemindex = string2list(layer->items, &(layer->numitems), layer->class[i]->labels[l]->styles[j]->rangeitem);
+          for(k=0; k<MS_STYLE_BINDING_LENGTH; k++)
+            if(layer->class[i]->labels[l]->styles[j]->bindings[k].item) layer->class[i]->labels[l]->styles[j]->bindings[k].index = string2list(layer->items, &(layer->numitems), layer->class[i]->labels[l]->styles[j]->bindings[k].item);
+          if(layer->class[i]->labels[l]->styles[j]->_geomtransform.type == MS_GEOMTRANSFORM_EXPRESSION) 
+            msTokenizeExpression(&(layer->class[i]->labels[l]->styles[j]->_geomtransform), layer->items, &(layer->numitems));
+        }
+        for(k=0; k<MS_LABEL_BINDING_LENGTH; k++)
+          if(layer->class[i]->labels[l]->bindings[k].item) layer->class[i]->labels[l]->bindings[k].index = string2list(layer->items, &(layer->numitems), layer->class[i]->labels[l]->bindings[k].item);
       }
 
-      /* class text and label bindings */
+      /* class text */
       if(layer->class[i]->text.type == MS_EXPRESSION || (layer->class[i]->text.string && strchr(layer->class[i]->text.string,'[') != NULL && strchr(layer->class[i]->text.string,']') != NULL))
         msTokenizeExpression(&(layer->class[i]->text), layer->items, &(layer->numitems));
-      for(k=0; k<MS_LABEL_BINDING_LENGTH; k++)
-        if(layer->class[i]->label.bindings[k].item) layer->class[i]->label.bindings[k].index = string2list(layer->items, &(layer->numitems), layer->class[i]->label.bindings[k].item);
     }
 
     /* layer filter */

Modified: sandbox/sdlime/rfc-77/mapserver.h
===================================================================
--- sandbox/sdlime/rfc-77/mapserver.h	2011-11-27 23:23:37 UTC (rev 12814)
+++ sandbox/sdlime/rfc-77/mapserver.h	2011-11-28 04:12:18 UTC (rev 12815)
@@ -1055,13 +1055,14 @@
 %immutable;
 #endif /* SWIG */
 typedef struct {
-  char *text;
+  char **text; /* copied from the shapeObj (count should match numlabels) */
   double featuresize;
 
   styleObj *styles; /* copied from the classObj, only present if there is a marker to be drawn */
   int numstyles;
 
-  labelObj label; /* copied from the classObj */
+  labelObj *labels; /* copied from the classObj */
+  int numlabels;
 
   int layerindex; /* indexes */
   int classindex;
@@ -1985,7 +1986,8 @@
 MS_DLL_EXPORT int msGetTruetypeTextBBox(rendererVTableObj *renderer, char *font, double size, char *string, rectObj *rect, double **advances);
 
 MS_DLL_EXPORT int msGetLabelSize(mapObj *map, labelObj *label, char *string, double size, rectObj *rect, double **advances);
-MS_DLL_EXPORT int msAddLabel(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label);
+// MS_DLL_EXPORT int msAddLabel(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label);
+MS_DLL_EXPORT int msAddLabel(mapObj *map, layerObj *layer, shapeObj *shape, pointObj *labelpoint, labelPathObj *labelpath, double featuresize);
 MS_DLL_EXPORT void msTestLabelCacheCollisions(labelCacheObj *labelcache, labelObj *labelPtr, int mapwidth, int mapheight, int buffer, labelCacheMemberObj *cachePtr, int current_priority, int current_label, int mindistance, double label_size);
 MS_DLL_EXPORT labelCacheMemberObj *msGetLabelCacheMember(labelCacheObj *labelcache, int i);
 

Modified: sandbox/sdlime/rfc-77/maputil.c
===================================================================
--- sandbox/sdlime/rfc-77/maputil.c	2011-11-27 23:23:37 UTC (rev 12814)
+++ sandbox/sdlime/rfc-77/maputil.c	2011-11-28 04:12:18 UTC (rev 12815)
@@ -580,6 +580,11 @@
   if(!layer || !shape) return MS_FAILURE;
 
   j = shape->classindex;
+
+   /* initialize space for multiple text values */
+  shape->text = (char **) msSmallMalloc(sizeof(char *)*layer->class[j]->numlabels);
+  shape->numtext = layer->class[j]->numlabels;
+
   for(i=0; i<layer->class[j]->numlabels; i++) {
 
     /* RFC 77 TODO: will evaluate label expressions here... */



More information about the mapserver-commits mailing list