Skip to content

Commit

Permalink
Merge branch 'bug-4276'
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Apr 8, 2012
2 parents 571ab48 + 82057aa commit 8c6e47d
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 35 deletions.
13 changes: 12 additions & 1 deletion maplabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,18 @@ int msAddLabel(mapObj *map, labelObj *label, int layerindex, int classindex, sha
classObj *classPtr=NULL;

if(!label) return(MS_FAILURE); // RFC 77 TODO: set a proper message
if(!label->annotext || label->status == MS_OFF) return(MS_SUCCESS); /* not an error */
if(label->status == MS_OFF) return(MS_SUCCESS); /* not an error */
if(!label->annotext) {
/* check if we have a labelpnt style */
for(i=0;i<label->numstyles;i++) {
if(label->styles[i]->_geomtransform.type == MS_GEOMTRANSFORM_LABELPOINT)
break;
}
if(i==label->numstyles) {
/* label has no text or marker symbols */
return MS_SUCCESS;
}
}

layerPtr = (GET_LAYER(map, layerindex)); /* set up a few pointers for clarity */
classPtr = GET_LAYER(map, layerindex)->class[classindex];
Expand Down
38 changes: 24 additions & 14 deletions maplegend.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ int msEmbedLegend(mapObj *map, imageObj *img)
map->numlayers++;
if(initLayer((GET_LAYER(map, l)), map) == -1) return(-1);
GET_LAYER(map, l)->name = msStrdup("__embed__legend");
GET_LAYER(map, l)->type = MS_LAYER_ANNOTATION;
GET_LAYER(map, l)->type = MS_LAYER_POINT;

if(msGrowLayerClasses( GET_LAYER(map, l) ) == NULL)
return(-1);
Expand All @@ -714,23 +714,33 @@ int msEmbedLegend(mapObj *map, imageObj *img)

GET_LAYER(map, l)->status = MS_ON;

if(msMaybeAllocateClassStyle(GET_LAYER(map, l)->class[0], 0)==MS_FAILURE) return MS_FAILURE;
GET_LAYER(map, l)->class[0]->styles[0]->symbol = s;
GET_LAYER(map, l)->class[0]->styles[0]->color.pen = -1;

if(!GET_LAYER(map, l)->class[0]->labels) {
if(msGrowClassLabels(GET_LAYER(map, l)->class[0]) == NULL) return MS_FAILURE;
}
initLabel(GET_LAYER(map, l)->class[0]->labels[0]);
GET_LAYER(map, l)->class[0]->labels[0]->force = MS_TRUE;
GET_LAYER(map, l)->class[0]->labels[0]->size = MS_MEDIUM; /* must set a size to have a valid label definition */
GET_LAYER(map, l)->class[0]->labels[0]->priority = MS_MAX_LABEL_PRIORITY;
GET_LAYER(map, l)->class[0]->labels[0]->annotext = msStrdup(" ");

if(map->legend.postlabelcache) /* add it directly to the image */
if(map->legend.postlabelcache) /* add it directly to the image */ {
if(msMaybeAllocateClassStyle(GET_LAYER(map, l)->class[0], 0)==MS_FAILURE) return MS_FAILURE;
GET_LAYER(map, l)->class[0]->styles[0]->symbol = s;
GET_LAYER(map, l)->class[0]->styles[0]->color.pen = -1;
msDrawMarkerSymbol(&map->symbolset, img, &point, GET_LAYER(map, l)->class[0]->styles[0], 1.0);
else
}
else {
if(!GET_LAYER(map, l)->class[0]->labels) {
if(msGrowClassLabels(GET_LAYER(map, l)->class[0]) == NULL) return MS_FAILURE;
initLabel(GET_LAYER(map, l)->class[0]->labels[0]);
GET_LAYER(map, l)->class[0]->labels[0]->force = MS_TRUE;
GET_LAYER(map, l)->class[0]->labels[0]->size = MS_MEDIUM; /* must set a size to have a valid label definition */
GET_LAYER(map, l)->class[0]->labels[0]->priority = MS_MAX_LABEL_PRIORITY;
GET_LAYER(map, l)->class[0]->labels[0]->annotext = NULL;
}
if(GET_LAYER(map, l)->class[0]->labels[0]->numstyles == 0) {
if(msGrowLabelStyles(GET_LAYER(map,l)->class[0]->labels[0]) == NULL)
return(MS_FAILURE);
GET_LAYER(map,l)->class[0]->labels[0]->numstyles = 1;
initStyle(GET_LAYER(map,l)->class[0]->labels[0]->styles[0]);
GET_LAYER(map,l)->class[0]->labels[0]->styles[0]->_geomtransform.type = MS_GEOMTRANSFORM_LABELPOINT;
}
GET_LAYER(map,l)->class[0]->labels[0]->styles[0]->symbol = s;
msAddLabel(map, GET_LAYER(map, l)->class[0]->labels[0], l, 0, NULL, &point, NULL, -1);
}

/* Mark layer as deleted so that it doesn't interfere with html legends or with saving maps */
GET_LAYER(map, l)->status = MS_DELETE;
Expand Down
48 changes: 28 additions & 20 deletions mapscale.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ imageObj *msDrawScalebar(mapObj *map)

int msEmbedScalebar(mapObj *map, imageObj *img)
{
int l,index;
int l,index,s;
pointObj point;
imageObj *image = NULL;
rendererVTableObj *renderer = MS_MAP_RENDERER(map);
Expand All @@ -358,11 +358,11 @@ int msEmbedScalebar(mapObj *map, imageObj *img)

if((embededSymbol=msGrowSymbolSet(&map->symbolset)) == NULL)
return MS_FAILURE;
s = map->symbolset.numsymbols;
map->symbolset.numsymbols++;

image = msDrawScalebar(map);
if(!image) {
msSetError(MS_RENDERERERR,"failed to create scalebar image","msEmbedScalebar()");
return MS_FAILURE;
}
embededSymbol->pixmap_buffer = calloc(1,sizeof(rasterBufferObj));
Expand Down Expand Up @@ -416,7 +416,7 @@ int msEmbedScalebar(mapObj *map, imageObj *img)
map->numlayers++;
if(initLayer((GET_LAYER(map, l)), map) == -1) return(-1);
GET_LAYER(map, l)->name = msStrdup("__embed__scalebar");
GET_LAYER(map, l)->type = MS_LAYER_ANNOTATION;
GET_LAYER(map, l)->type = MS_LAYER_POINT;

if (msGrowLayerClasses( GET_LAYER(map, l) ) == NULL)
return(-1);
Expand All @@ -429,25 +429,33 @@ int msEmbedScalebar(mapObj *map, imageObj *img)
}

GET_LAYER(map, l)->status = MS_ON;

/* TODO: Change this when we get rid of MS_MAXSTYLES */
if (msMaybeAllocateClassStyle(GET_LAYER(map, l)->class[0], 0)==MS_FAILURE) return MS_FAILURE;
GET_LAYER(map, l)->class[0]->styles[0]->symbol = map->symbolset.numsymbols -1 ;
GET_LAYER(map, l)->class[0]->styles[0]->color.pen = -1;

if(!GET_LAYER(map, l)->class[0]->labels) {
if(msGrowClassLabels(GET_LAYER(map, l)->class[0]) == NULL) return MS_FAILURE;
}
initLabel(GET_LAYER(map, l)->class[0]->labels[0]);
GET_LAYER(map, l)->class[0]->labels[0]->force = MS_TRUE;
GET_LAYER(map, l)->class[0]->labels[0]->size = MS_MEDIUM; /* must set a size to have a valid label definition */
GET_LAYER(map, l)->class[0]->labels[0]->priority = MS_MAX_LABEL_PRIORITY;
GET_LAYER(map, l)->class[0]->labels[0]->annotext = msStrdup(" ");

if(map->scalebar.postlabelcache) /* TODO: add it directly to the image */

if(map->scalebar.postlabelcache) /* add it directly to the image */ {
if(msMaybeAllocateClassStyle(GET_LAYER(map, l)->class[0], 0)==MS_FAILURE) return MS_FAILURE;
GET_LAYER(map, l)->class[0]->styles[0]->symbol = s;
GET_LAYER(map, l)->class[0]->styles[0]->color.pen = -1;
msDrawMarkerSymbol(&map->symbolset, img, &point, GET_LAYER(map, l)->class[0]->styles[0], 1.0);
else
}
else {
if(!GET_LAYER(map, l)->class[0]->labels) {
if(msGrowClassLabels(GET_LAYER(map, l)->class[0]) == NULL) return MS_FAILURE;
initLabel(GET_LAYER(map, l)->class[0]->labels[0]);
GET_LAYER(map, l)->class[0]->labels[0]->force = MS_TRUE;
GET_LAYER(map, l)->class[0]->labels[0]->size = MS_MEDIUM; /* must set a size to have a valid label definition */
GET_LAYER(map, l)->class[0]->labels[0]->priority = MS_MAX_LABEL_PRIORITY;
GET_LAYER(map, l)->class[0]->labels[0]->annotext = NULL;
}
if(GET_LAYER(map, l)->class[0]->labels[0]->numstyles == 0) {
if(msGrowLabelStyles(GET_LAYER(map,l)->class[0]->labels[0]) == NULL)
return(MS_FAILURE);
GET_LAYER(map,l)->class[0]->labels[0]->numstyles = 1;
initStyle(GET_LAYER(map,l)->class[0]->labels[0]->styles[0]);
GET_LAYER(map,l)->class[0]->labels[0]->styles[0]->_geomtransform.type = MS_GEOMTRANSFORM_LABELPOINT;
}
GET_LAYER(map,l)->class[0]->labels[0]->styles[0]->symbol = s;
msAddLabel(map, GET_LAYER(map, l)->class[0]->labels[0], l, 0, NULL, &point, NULL, -1);
}


/* Mark layer as deleted so that it doesn't interfere with html legends or with saving maps */
GET_LAYER(map, l)->status = MS_DELETE;
Expand Down

0 comments on commit 8c6e47d

Please sign in to comment.