From 00791ca448286592c609951db4ac531e34bbed46 Mon Sep 17 00:00:00 2001 From: Thomas Bonfort Date: Thu, 6 Sep 2012 19:28:18 +0200 Subject: [PATCH 1/5] update header version for beta3 --- mapserver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapserver.h b/mapserver.h index 4246bde598..09a8202308 100644 --- a/mapserver.h +++ b/mapserver.h @@ -32,7 +32,7 @@ /* ** MapServer version - to be updated for every release */ -#define MS_VERSION "6.2.0-beta2" +#define MS_VERSION "6.2.0-beta3" #define MS_VERSION_MAJOR 6 #define MS_VERSION_MINOR 2 From 5cee74defaf85a8143f83edcd62d20972acd863e Mon Sep 17 00:00:00 2001 From: Alan Boudreault Date: Thu, 6 Sep 2012 20:56:31 +0000 Subject: [PATCH 2/5] implementation of POLYLINE_NO_CLIP --- mapdraw.c | 107 ++++++++++++++++++++++++++++-------- maprendering.c | 9 +++ mapscript/php/mapscript_i.c | 4 +- mapscript/swiginc/rect.i | 2 +- mapscript/swiginc/shape.i | 2 +- mapserver.h | 4 +- 6 files changed, 99 insertions(+), 29 deletions(-) diff --git a/mapdraw.c b/mapdraw.c index f36df9cd08..a7b0efdbda 100644 --- a/mapdraw.c +++ b/mapdraw.c @@ -903,7 +903,7 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image) int status, retcode=MS_SUCCESS; int drawmode=MS_DRAWMODE_FEATURES; char annotate=MS_TRUE; - shapeObj shape; + shapeObj shape, *unclipped_shape = NULL; rectObj searchrect; char cache=MS_FALSE; int maxnumstyles=1; @@ -1038,6 +1038,10 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image) } } + if (layer->type == MS_LAYER_LINE && msLayerGetProcessingKey(layer, "POLYLINE_NO_CLIP")) { + drawmode |= MS_DRAWMODE_UNCLIPPEDLINES; + } + if (cache) { styleObj *pStyle = layer->class[shape.classindex]->styles[0]; colorObj tmp; @@ -1062,7 +1066,14 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image) pStyle->color = pStyle->outlinecolor; pStyle->outlinecolor = tmp; } - status = msDrawShape(map, layer, &shape, image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE); /* draw a single style */ + + if (MS_DRAW_UNCLIPPED_LINES(drawmode)) + status = msDrawShape(map, layer, &shape, + image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE, &unclipped_shape); /* draw a single style */ + else + status = msDrawShape(map, layer, &shape, + image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE, NULL); /* draw a single style */ + if (pStyle->outlinewidth > 0) { /* * RFC 49 implementation: switch back the styleobj to its @@ -1083,27 +1094,43 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image) } } - else - status = msDrawShape(map, layer, &shape, image, -1, drawmode); /* all styles */ + else + status = msDrawShape(map, layer, &shape, image, -1, drawmode, NULL); /* all styles */ if(status != MS_SUCCESS) { + if(unclipped_shape) { + msFreeShape(unclipped_shape); + msFree(unclipped_shape); + } msFreeShape(&shape); retcode = MS_FAILURE; break; } if(shape.numlines == 0) { /* once clipped the shape didn't need to be drawn */ + if(unclipped_shape) { + msFreeShape(unclipped_shape); + msFree(unclipped_shape); + } msFreeShape(&shape); continue; } if(cache) { - if(insertFeatureList(&shpcache, &shape) == NULL) { - retcode = MS_FAILURE; /* problem adding to the cache */ - break; + shapeObj *s = &shape; + if (unclipped_shape) + s = unclipped_shape; + if(insertFeatureList(&shpcache, s) == NULL) { + retcode = MS_FAILURE; /* problem adding to the cache */ + break; } } maxnumstyles = MS_MAX(maxnumstyles, layer->class[shape.classindex]->numstyles); + + if(unclipped_shape) { + msFreeShape(unclipped_shape); + msFree(unclipped_shape); + } msFreeShape(&shape); } @@ -1209,7 +1236,7 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image) int i, status; char annotate=MS_TRUE, cache=MS_FALSE; int drawmode = MS_DRAWMODE_FEATURES|MS_DRAWMODE_QUERY; - shapeObj shape; + shapeObj shape, *unclipped_shape = NULL; int maxnumstyles=1; featureListNodeObjPtr shpcache=NULL, current=NULL; @@ -1344,11 +1371,18 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image) if(cache) { drawmode |= MS_DRAWMODE_SINGLESTYLE; - status = msDrawShape(map, layer, &shape, image, 0, drawmode); /* draw only the first style */ + if (MS_DRAW_UNCLIPPED_LINES(drawmode)) + status = msDrawShape(map, layer, &shape, image, 0, drawmode, &unclipped_shape); /* draw only the first style */ + else + status = msDrawShape(map, layer, &shape, image, 0, drawmode, NULL); /* draw only the first style */ } else - status = msDrawShape(map, layer, &shape, image, -1, drawmode); /* all styles */ + status = msDrawShape(map, layer, &shape, image, -1, drawmode, NULL); /* all styles */ if(status != MS_SUCCESS) { + if(unclipped_shape) { + msFreeShape(unclipped_shape); + msFree(unclipped_shape); + } msLayerClose(layer); msFree(colorbuffer); msFree(mindistancebuffer); @@ -1356,15 +1390,27 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image) } if(shape.numlines == 0) { /* once clipped the shape didn't need to be drawn */ + if(unclipped_shape) { + msFreeShape(unclipped_shape); + msFree(unclipped_shape); + } msFreeShape(&shape); continue; } if(cache) { - if(insertFeatureList(&shpcache, &shape) == NULL) return(MS_FAILURE); /* problem adding to the cache */ + shapeObj *s = &shape; + if (unclipped_shape) + s = unclipped_shape; + if(insertFeatureList(&shpcache, s) == NULL) return(MS_FAILURE); /* problem adding to the cache */ } maxnumstyles = MS_MAX(maxnumstyles, layer->class[shape.classindex]->numstyles); + + if(unclipped_shape) { + msFreeShape(unclipped_shape); + msFree(unclipped_shape); + } msFreeShape(&shape); } @@ -1794,8 +1840,13 @@ int lineLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer, shapeObj * layer->class[c]->styles[s]->maxscaledenom)) { if (layer->class[c]->styles[s]->_geomtransform.type != MS_GEOMTRANSFORM_NONE) msDrawTransformedShape(map, &map->symbolset, image, unclipped_shape, layer->class[c]->styles[s], layer->scalefactor); - else if (!MS_DRAW_SINGLESTYLE(drawmode) || s == style) - msDrawLineSymbol(&map->symbolset, image, shape, layer->class[c]->styles[s], layer->scalefactor); + else if (!MS_DRAW_SINGLESTYLE(drawmode) || s == style) { + if (MS_DRAW_UNCLIPPED_LINES(drawmode)) { + msDrawLineSymbol(&map->symbolset, image, unclipped_shape, layer->class[c]->styles[s], layer->scalefactor); + } + else + msDrawLineSymbol(&map->symbolset, image, shape, layer->class[c]->styles[s], layer->scalefactor); + } } } } @@ -1953,10 +2004,10 @@ int polygonLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer, ** through caching. "querymapMode" parameter is used to tell msBindLayerToShape to not override the ** QUERYMAP HILITE color. */ -int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int drawmode) +int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int drawmode, shapeObj **unclipped_shape) { int c,s,ret=MS_SUCCESS; - shapeObj *anno_shape, *unclipped_shape = shape; + shapeObj *anno_shape, *unclipped_shape_tmp = shape; int bNeedUnclippedShape = MS_FALSE; int bNeedUnclippedAnnoShape = MS_FALSE; int bShapeNeedsClipping = MS_TRUE; @@ -2021,6 +2072,10 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, bShapeNeedsClipping = MS_TRUE; } + if(MS_DRAW_UNCLIPPED_LINES(drawmode)) { + bNeedUnclippedShape = MS_TRUE; + } + if(MS_DRAW_LABELS(drawmode) && MS_DRAW_UNCLIPPED_LABELS(drawmode)) { bNeedUnclippedAnnoShape = MS_TRUE; bNeedUnclippedShape = MS_TRUE; @@ -2072,9 +2127,9 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, - the calls to msClipXXXRect will discard the original lineObjs, whereas we have just copied them because they where needed. These two functions could be changed so they are instructed not to free the original lineObjs. */ - unclipped_shape = (shapeObj *) msSmallMalloc(sizeof (shapeObj)); - msInitShape(unclipped_shape); - msCopyShape(shape, unclipped_shape); + unclipped_shape_tmp = (shapeObj *) msSmallMalloc(sizeof (shapeObj)); + msInitShape(unclipped_shape_tmp); + msCopyShape(shape, unclipped_shape_tmp); cliprect.minx = cliprect.miny = -clip_buf; cliprect.maxx = image->width + clip_buf; @@ -2086,7 +2141,7 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, msClipPolylineRect(shape, cliprect); } if(bNeedUnclippedAnnoShape) { - anno_shape = unclipped_shape; + anno_shape = unclipped_shape_tmp; } else { anno_shape = shape; } @@ -2136,10 +2191,10 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, ret = MS_SUCCESS; break; case MS_LAYER_LINE: - ret = lineLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape, style, drawmode); + ret = lineLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape_tmp, style, drawmode); break; case MS_LAYER_POLYGON: - ret = polygonLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape, drawmode); + ret = polygonLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape_tmp, drawmode); break; case MS_LAYER_POINT: case MS_LAYER_RASTER: @@ -2151,9 +2206,13 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, draw_shape_cleanup: msDrawEndShape(map,layer,image,shape); - if(unclipped_shape != shape) { - msFreeShape(unclipped_shape); - msFree(unclipped_shape); + if(unclipped_shape_tmp != shape) { + if (unclipped_shape) + *unclipped_shape = unclipped_shape_tmp; + else { + msFreeShape(unclipped_shape_tmp); + msFree(unclipped_shape_tmp); + } } return ret; } diff --git a/maprendering.c b/maprendering.c index a70f0c356c..23a24a7115 100644 --- a/maprendering.c +++ b/maprendering.c @@ -367,6 +367,15 @@ int msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolObj *symbol, point.y += oy; } } + + /* if the point is not in the map extent, skip it. (POLYLINE_NO_CLIP) */ + if ( (point.x < -(symbol_width) || point.x > (image->width+symbol_width)) || + (point.y < -(symbol_height) || point.y > (image->height+symbol_height)) ) { + current_length += spacing; + line_in=1; + continue; + } + switch (symbol->type) { case MS_SYMBOL_PIXMAP: ret = renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style); diff --git a/mapscript/php/mapscript_i.c b/mapscript/php/mapscript_i.c index 7fb400ca36..ef7e36e2a0 100644 --- a/mapscript/php/mapscript_i.c +++ b/mapscript/php/mapscript_i.c @@ -1244,7 +1244,7 @@ int shapeObj_add(shapeObj *self, lineObj *line) int shapeObj_draw(shapeObj *self, mapObj *map, layerObj *layer, imageObj *img) { - return msDrawShape(map, layer, self, img, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS); + return msDrawShape(map, layer, self, img, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS, NULL); } void shapeObj_setBounds(shapeObj *self) @@ -1479,7 +1479,7 @@ int rectObj_draw(rectObj *self, mapObj *map, layerObj *layer, shape.classindex = classindex; shape.text = strdup(text); - msDrawShape(map, layer, &shape, img, -1, MS_FALSE); + msDrawShape(map, layer, &shape, img, -1, MS_FALSE, NULL); msFreeShape(&shape); diff --git a/mapscript/swiginc/rect.i b/mapscript/swiginc/rect.i index a4dcafbfd7..5bea1878bb 100644 --- a/mapscript/swiginc/rect.i +++ b/mapscript/swiginc/rect.i @@ -92,7 +92,7 @@ shape.classindex = classindex; shape.text = strdup(text); - msDrawShape(map, layer, &shape, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS); + msDrawShape(map, layer, &shape, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS, NULL); msFreeShape(&shape); diff --git a/mapscript/swiginc/shape.i b/mapscript/swiginc/shape.i index 3c69754962..1063eccb93 100644 --- a/mapscript/swiginc/shape.i +++ b/mapscript/swiginc/shape.i @@ -82,7 +82,7 @@ } int draw(mapObj *map, layerObj *layer, imageObj *image) { - return msDrawShape(map, layer, self, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS); + return msDrawShape(map, layer, self, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS, NULL); } void setBounds() diff --git a/mapserver.h b/mapserver.h index aee5b7a1f0..986e6fcb8b 100644 --- a/mapserver.h +++ b/mapserver.h @@ -2262,8 +2262,10 @@ extern "C" { #define MS_DRAW_QUERY(mode) (MS_DRAWMODE_QUERY&(mode)) #define MS_DRAWMODE_UNCLIPPEDLABELS 0x00010 #define MS_DRAW_UNCLIPPED_LABELS(mode) (MS_DRAWMODE_UNCLIPPEDLABELS&(mode)) +#define MS_DRAWMODE_UNCLIPPEDLINES 0x00020 +#define MS_DRAW_UNCLIPPED_LINES(mode) (MS_DRAWMODE_UNCLIPPEDLINES&(mode)) - MS_DLL_EXPORT int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int mode); + MS_DLL_EXPORT int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int mode, shapeObj **unclipped_shape); MS_DLL_EXPORT int msDrawPoint(mapObj *map, layerObj *layer, pointObj *point, imageObj *image, int classindex, char *labeltext); /*Range Support*/ From ab427ac0c41304d1ee793dd8a2e64473b251fda7 Mon Sep 17 00:00:00 2001 From: Stephan Meissl Date: Fri, 7 Sep 2012 12:00:17 +0200 Subject: [PATCH 3/5] Fixing wrong size in LegendURL of group layers (#4441) and improvements to fix of Style inheritance in WMS (#4442). --- mapwms.c | 84 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/mapwms.c b/mapwms.c index b80b54b37b..39916adab8 100644 --- a/mapwms.c +++ b/mapwms.c @@ -2355,16 +2355,34 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_ } } if (classnameset) { - int size_x=0, size_y=0; - int layer_index[1]; - layer_index[0] = lp->index; - if (msLegendCalcSize(map, 1, &size_x, &size_y, layer_index, 1) == MS_SUCCESS) { + int k, l, size_x=0, size_y=0, num_layers=0; + int *group_layers = (int *)msSmallMalloc(sizeof(int)*map->numlayers); + char ***nestedGroups = NULL; + int *numNestedGroups = NULL; + int *isUsedInNestedGroup = NULL; + + nestedGroups = (char***)msSmallCalloc(map->numlayers, sizeof(char**)); + numNestedGroups = (int*)msSmallCalloc(map->numlayers, sizeof(int)); + isUsedInNestedGroup = (int*)msSmallCalloc(map->numlayers, sizeof(int)); + msWMSPrepareNestedGroups(map, nVersion, nestedGroups, numNestedGroups, isUsedInNestedGroup); + + num_layers = 1; + group_layers[0] = lp->index; + if (isUsedInNestedGroup[lp->index]) { + for (j=0; j < map->numlayers; j++) { + for(k = 0; k < numNestedGroups[j]; k++) { + if (strcasecmp(lp->name, nestedGroups[j][k]) == 0) { + group_layers[num_layers++] = j; + break; + } + } + } + } + group_layers =(int *)msSmallRealloc(group_layers, sizeof(int)*num_layers); + + if (msLegendCalcSize(map, 1, &size_x, &size_y, group_layers, num_layers) == MS_SUCCESS) { const char *styleName = NULL; char *pszEncodedStyleName = NULL; - const char *layerGroups; - char **nestedLayerGroups = NULL; - int k, l, numNestedLayerGroups = 0; - char* errorMsg; layerObj *lp2 = NULL; snprintf(width, sizeof(width), "%d", size_x); @@ -2399,42 +2417,30 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_ if (styleName == NULL) styleName = "default"; pszEncodedStyleName = msEncodeHTMLEntities(styleName); - layerGroups = msOWSLookupMetadata(&(lp->metadata), "MO", "layer_group"); - nestedLayerGroups = (char**)msSmallMalloc(sizeof(char*)); for (i=0; inumclasses; i++) { if (lp->class[i]->name && lp->class[i]->group) { /* Check that style is not inherited from root layer (#4442). */ if (strcasecmp(pszEncodedStyleName, lp->class[i]->group) == 0) - break; + continue; /* Check that style is not inherited from group layer(s) (#4442). */ - if ((layerGroups != NULL) && (strlen(layerGroups) != 0)) { - if (layerGroups[0] != '/') { - errorMsg = "The WMS_LAYER_GROUP metadata does not start with a '/'"; - msSetError(MS_WMSERR, errorMsg, "msDumpLayer()", NULL); - msIO_fprintf(stdout, "\n", errorMsg); - /* cannot return exception at this point because we are already writing to stdout */ - } else { - /* split into subgroups. Start at address + 1 because the first '/' would cause an extra empty group */ - nestedLayerGroups = msStringSplit(layerGroups + 1, '/', &numNestedLayerGroups); - for (j=0; j < numNestedLayerGroups; j++) { - for(k = 0; k < map->numlayers; k++) { - if (GET_LAYER(map, k)->name && strcasecmp(GET_LAYER(map, k)->name, nestedLayerGroups[j]) == 0) { - lp2 = (GET_LAYER(map, k)); - for (l=0; l < lp2->numclasses; l++) { - if (strcasecmp(lp2->class[l]->group, lp->class[i]->group) == 0) - break; - } - if (l < lp2->numclasses) + if (numNestedGroups[lp->index] > 0) { + for (j=0; jindex]; j++) { + for (k=0; k < map->numlayers; k++) { + if (GET_LAYER(map, k)->name && strcasecmp(GET_LAYER(map, k)->name, nestedGroups[lp->index][j]) == 0) { + lp2 = (GET_LAYER(map, k)); + for (l=0; l < lp2->numclasses; l++) { + if (strcasecmp(lp2->class[l]->group, lp->class[i]->group) == 0) break; } - } - if (k < map->numlayers) break; + } } - if (j < numNestedLayerGroups) - continue; + if (l < lp2->numclasses) + break; } + if (j < numNestedGroups[lp->index]) + continue; } if (!classgroups) { classgroups = (char **)msSmallMalloc(sizeof(char *)); @@ -2518,9 +2524,17 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_ } msFree(legendurl); msFreeCharArray(classgroups, iclassgroups); - msFreeCharArray(nestedLayerGroups, numNestedLayerGroups); msFree(mimetype); } + /* free the stuff used for nested layers */ + for (i = 0; i < map->numlayers; i++) { + if (numNestedGroups[i] > 0) { + msFreeCharArray(nestedGroups[i], numNestedGroups[i]); + } + } + free(nestedGroups); + free(numNestedGroups); + free(isUsedInNestedGroup); } } } @@ -3240,7 +3254,7 @@ int msWMSGetCapabilities(mapObj *map, int nVersion, cgiRequestObj *req, owsReque int numtokens = 0; char width[10], height[10]; - group_layers =(int *)msSmallRealloc(group_layers, sizeof(int)*num_layers); + group_layers =(int *)msSmallRealloc(group_layers, sizeof(int)*num_layers); if (msLegendCalcSize(map, 1, &size_x, &size_y, group_layers , num_layers) == MS_SUCCESS) { bufferSize = strlen(script_url_encoded)+300; pszLegendURL = (char*)msSmallMalloc(bufferSize); From 42515e61850ee0bc9cf6a16ebb00092b454bce3b Mon Sep 17 00:00:00 2001 From: Stephan Meissl Date: Fri, 7 Sep 2012 14:04:36 +0200 Subject: [PATCH 4/5] Fixing attribute vocabulary not allowed in WMS 1.1.1 (#4447). --- mapwms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapwms.c b/mapwms.c index 39916adab8..e3e78397ad 100644 --- a/mapwms.c +++ b/mapwms.c @@ -1976,7 +1976,7 @@ void msWMSPrintKeywordlist(FILE *stream, const char *tabspace, /* find out if there's a vocabulary list set */ vocabularylist = msOWSLookupMetadata(metadata, namespaces, vocname); - if ( vocabularylist ) { + if ( vocabularylist && nVersion >= OWS_1_3_0 ) { tokens = msStringSplit(vocabularylist, ',', &ntokens); if ( tokens && ntokens > 0 ) { /* In order to do malloc only once, the length of the metadata*/ From 5bf7c5068699c4d16d7cf7e20e75d18892c1fc69 Mon Sep 17 00:00:00 2001 From: Alan Boudreault Date: Fri, 7 Sep 2012 16:09:03 +0000 Subject: [PATCH 5/5] simpler POLYLINE_NO_CLIP (#4444) --- mapdraw.c | 109 ++++++++++-------------------------- mapscript/php/mapscript_i.c | 4 +- mapscript/swiginc/rect.i | 2 +- mapscript/swiginc/shape.i | 2 +- mapserver.h | 2 +- 5 files changed, 34 insertions(+), 85 deletions(-) diff --git a/mapdraw.c b/mapdraw.c index ba758ab6ae..43ed227ee0 100644 --- a/mapdraw.c +++ b/mapdraw.c @@ -903,7 +903,7 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image) int status, retcode=MS_SUCCESS; int drawmode=MS_DRAWMODE_FEATURES; char annotate=MS_TRUE; - shapeObj shape, *unclipped_shape = NULL; + shapeObj shape; rectObj searchrect; char cache=MS_FALSE; int maxnumstyles=1; @@ -1066,14 +1066,7 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image) pStyle->color = pStyle->outlinecolor; pStyle->outlinecolor = tmp; } - - if (MS_DRAW_UNCLIPPED_LINES(drawmode)) - status = msDrawShape(map, layer, &shape, - image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE, &unclipped_shape); /* draw a single style */ - else - status = msDrawShape(map, layer, &shape, - image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE, NULL); /* draw a single style */ - + status = msDrawShape(map, layer, &shape, image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE); /* draw a single style */ if (pStyle->outlinewidth > 0) { /* * RFC 49 implementation: switch back the styleobj to its @@ -1094,43 +1087,27 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image) } } - else - status = msDrawShape(map, layer, &shape, image, -1, drawmode, NULL); /* all styles */ + else + status = msDrawShape(map, layer, &shape, image, -1, drawmode); /* all styles */ if(status != MS_SUCCESS) { - if(unclipped_shape) { - msFreeShape(unclipped_shape); - msFree(unclipped_shape); - } msFreeShape(&shape); retcode = MS_FAILURE; break; } if(shape.numlines == 0) { /* once clipped the shape didn't need to be drawn */ - if(unclipped_shape) { - msFreeShape(unclipped_shape); - msFree(unclipped_shape); - } msFreeShape(&shape); continue; } if(cache) { - shapeObj *s = &shape; - if (unclipped_shape) - s = unclipped_shape; - if(insertFeatureList(&shpcache, s) == NULL) { - retcode = MS_FAILURE; /* problem adding to the cache */ - break; + if(insertFeatureList(&shpcache, &shape) == NULL) { + retcode = MS_FAILURE; /* problem adding to the cache */ + break; } } maxnumstyles = MS_MAX(maxnumstyles, layer->class[shape.classindex]->numstyles); - - if(unclipped_shape) { - msFreeShape(unclipped_shape); - msFree(unclipped_shape); - } msFreeShape(&shape); } @@ -1236,7 +1213,7 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image) int i, status; char annotate=MS_TRUE, cache=MS_FALSE; int drawmode = MS_DRAWMODE_FEATURES|MS_DRAWMODE_QUERY; - shapeObj shape, *unclipped_shape = NULL; + shapeObj shape; int maxnumstyles=1; featureListNodeObjPtr shpcache=NULL, current=NULL; @@ -1371,18 +1348,11 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image) if(cache) { drawmode |= MS_DRAWMODE_SINGLESTYLE; - if (MS_DRAW_UNCLIPPED_LINES(drawmode)) - status = msDrawShape(map, layer, &shape, image, 0, drawmode, &unclipped_shape); /* draw only the first style */ - else - status = msDrawShape(map, layer, &shape, image, 0, drawmode, NULL); /* draw only the first style */ + status = msDrawShape(map, layer, &shape, image, 0, drawmode); /* draw only the first style */ } else - status = msDrawShape(map, layer, &shape, image, -1, drawmode, NULL); /* all styles */ + status = msDrawShape(map, layer, &shape, image, -1, drawmode); /* all styles */ if(status != MS_SUCCESS) { - if(unclipped_shape) { - msFreeShape(unclipped_shape); - msFree(unclipped_shape); - } msLayerClose(layer); msFree(colorbuffer); msFree(mindistancebuffer); @@ -1390,27 +1360,15 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image) } if(shape.numlines == 0) { /* once clipped the shape didn't need to be drawn */ - if(unclipped_shape) { - msFreeShape(unclipped_shape); - msFree(unclipped_shape); - } msFreeShape(&shape); continue; } if(cache) { - shapeObj *s = &shape; - if (unclipped_shape) - s = unclipped_shape; - if(insertFeatureList(&shpcache, s) == NULL) return(MS_FAILURE); /* problem adding to the cache */ + if(insertFeatureList(&shpcache, &shape) == NULL) return(MS_FAILURE); /* problem adding to the cache */ } maxnumstyles = MS_MAX(maxnumstyles, layer->class[shape.classindex]->numstyles); - - if(unclipped_shape) { - msFreeShape(unclipped_shape); - msFree(unclipped_shape); - } msFreeShape(&shape); } @@ -1840,13 +1798,8 @@ int lineLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer, shapeObj * layer->class[c]->styles[s]->maxscaledenom)) { if (layer->class[c]->styles[s]->_geomtransform.type != MS_GEOMTRANSFORM_NONE) msDrawTransformedShape(map, &map->symbolset, image, unclipped_shape, layer->class[c]->styles[s], layer->scalefactor); - else if (!MS_DRAW_SINGLESTYLE(drawmode) || s == style) { - if (MS_DRAW_UNCLIPPED_LINES(drawmode)) { - msDrawLineSymbol(&map->symbolset, image, unclipped_shape, layer->class[c]->styles[s], layer->scalefactor); - } - else - msDrawLineSymbol(&map->symbolset, image, shape, layer->class[c]->styles[s], layer->scalefactor); - } + else if (!MS_DRAW_SINGLESTYLE(drawmode) || s == style) + msDrawLineSymbol(&map->symbolset, image, shape, layer->class[c]->styles[s], layer->scalefactor); } } } @@ -2004,10 +1957,10 @@ int polygonLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer, ** through caching. "querymapMode" parameter is used to tell msBindLayerToShape to not override the ** QUERYMAP HILITE color. */ -int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int drawmode, shapeObj **unclipped_shape) +int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int drawmode) { int c,s,ret=MS_SUCCESS; - shapeObj *anno_shape, *unclipped_shape_tmp = shape; + shapeObj *anno_shape, *unclipped_shape = shape; int bNeedUnclippedShape = MS_FALSE; int bNeedUnclippedAnnoShape = MS_FALSE; int bShapeNeedsClipping = MS_TRUE; @@ -2071,15 +2024,15 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, shape->bounds.maxy > map->extent.maxy) { bShapeNeedsClipping = MS_TRUE; } - - if(MS_DRAW_UNCLIPPED_LINES(drawmode)) { - bNeedUnclippedShape = MS_TRUE; - } if(MS_DRAW_LABELS(drawmode) && MS_DRAW_UNCLIPPED_LABELS(drawmode)) { bNeedUnclippedAnnoShape = MS_TRUE; bNeedUnclippedShape = MS_TRUE; } + + if(MS_DRAW_UNCLIPPED_LINES(drawmode)) { + bShapeNeedsClipping = MS_FALSE; + } } else { bShapeNeedsClipping = MS_FALSE; } @@ -2128,13 +2081,13 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, - the calls to msClipXXXRect will discard the original lineObjs, whereas we have just copied them because they where needed. These two functions could be changed so they are instructed not to free the original lineObjs. */ - unclipped_shape_tmp = (shapeObj *) msSmallMalloc(sizeof (shapeObj)); - msInitShape(unclipped_shape_tmp); - msCopyShape(shape, unclipped_shape_tmp); + unclipped_shape = (shapeObj *) msSmallMalloc(sizeof (shapeObj)); + msInitShape(unclipped_shape); + msCopyShape(shape, unclipped_shape); if(shape->type == MS_SHAPE_POLYGON) { /* #179: additional buffer for polygons */ clip_buf += 2; - } + } cliprect.minx = cliprect.miny = -clip_buf; cliprect.maxx = image->width + clip_buf; @@ -2146,7 +2099,7 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, msClipPolylineRect(shape, cliprect); } if(bNeedUnclippedAnnoShape) { - anno_shape = unclipped_shape_tmp; + anno_shape = unclipped_shape; } else { anno_shape = shape; } @@ -2204,10 +2157,10 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, ret = MS_SUCCESS; break; case MS_LAYER_LINE: - ret = lineLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape_tmp, style, drawmode); + ret = lineLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape, style, drawmode); break; case MS_LAYER_POLYGON: - ret = polygonLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape_tmp, drawmode); + ret = polygonLayerDrawShape(map, image, layer, shape, anno_shape, unclipped_shape, drawmode); break; case MS_LAYER_POINT: case MS_LAYER_RASTER: @@ -2219,13 +2172,9 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, draw_shape_cleanup: msDrawEndShape(map,layer,image,shape); - if(unclipped_shape_tmp != shape) { - if (unclipped_shape) - *unclipped_shape = unclipped_shape_tmp; - else { - msFreeShape(unclipped_shape_tmp); - msFree(unclipped_shape_tmp); - } + if(unclipped_shape != shape) { + msFreeShape(unclipped_shape); + msFree(unclipped_shape); } return ret; } diff --git a/mapscript/php/mapscript_i.c b/mapscript/php/mapscript_i.c index ef7e36e2a0..7fb400ca36 100644 --- a/mapscript/php/mapscript_i.c +++ b/mapscript/php/mapscript_i.c @@ -1244,7 +1244,7 @@ int shapeObj_add(shapeObj *self, lineObj *line) int shapeObj_draw(shapeObj *self, mapObj *map, layerObj *layer, imageObj *img) { - return msDrawShape(map, layer, self, img, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS, NULL); + return msDrawShape(map, layer, self, img, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS); } void shapeObj_setBounds(shapeObj *self) @@ -1479,7 +1479,7 @@ int rectObj_draw(rectObj *self, mapObj *map, layerObj *layer, shape.classindex = classindex; shape.text = strdup(text); - msDrawShape(map, layer, &shape, img, -1, MS_FALSE, NULL); + msDrawShape(map, layer, &shape, img, -1, MS_FALSE); msFreeShape(&shape); diff --git a/mapscript/swiginc/rect.i b/mapscript/swiginc/rect.i index 5bea1878bb..a4dcafbfd7 100644 --- a/mapscript/swiginc/rect.i +++ b/mapscript/swiginc/rect.i @@ -92,7 +92,7 @@ shape.classindex = classindex; shape.text = strdup(text); - msDrawShape(map, layer, &shape, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS, NULL); + msDrawShape(map, layer, &shape, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS); msFreeShape(&shape); diff --git a/mapscript/swiginc/shape.i b/mapscript/swiginc/shape.i index 1063eccb93..3c69754962 100644 --- a/mapscript/swiginc/shape.i +++ b/mapscript/swiginc/shape.i @@ -82,7 +82,7 @@ } int draw(mapObj *map, layerObj *layer, imageObj *image) { - return msDrawShape(map, layer, self, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS, NULL); + return msDrawShape(map, layer, self, image, -1, MS_DRAWMODE_FEATURES|MS_DRAWMODE_LABELS); } void setBounds() diff --git a/mapserver.h b/mapserver.h index 986e6fcb8b..0e52941fac 100644 --- a/mapserver.h +++ b/mapserver.h @@ -2265,7 +2265,7 @@ extern "C" { #define MS_DRAWMODE_UNCLIPPEDLINES 0x00020 #define MS_DRAW_UNCLIPPED_LINES(mode) (MS_DRAWMODE_UNCLIPPEDLINES&(mode)) - MS_DLL_EXPORT int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int mode, shapeObj **unclipped_shape); + MS_DLL_EXPORT int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image, int style, int mode); MS_DLL_EXPORT int msDrawPoint(mapObj *map, layerObj *layer, pointObj *point, imageObj *image, int classindex, char *labeltext); /*Range Support*/