Skip to content

Commit

Permalink
Merge branch 'branch-6-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Schpidi committed Sep 6, 2012
2 parents 7eaae52 + af90e5a commit 2d4240e
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 19 deletions.
29 changes: 21 additions & 8 deletions mapdraw.c
Expand Up @@ -2033,11 +2033,12 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image,
/* compute the size of the clipping buffer, in pixels. This buffer must account
for the size of symbols drawn to avoid artifacts around the image edges */
int clip_buf = 0;
int s;
rectObj cliprect;
if (layer->class[c]->numstyles > 0) {
for (s=0;s<layer->class[c]->numstyles;s++) {
double maxsize, maxunscaledsize;
symbolObj *symbol;
styleObj *style = layer->class[c]->styles[0];
styleObj *style = layer->class[c]->styles[s];
if (!MS_IS_VALID_ARRAY_INDEX(style->symbol, map->symbolset.numsymbols)) {
msSetError(MS_SYMERR, "Invalid symbol index: %d", "msDrawShape()", style->symbol);
return MS_FAILURE;
Expand All @@ -2056,8 +2057,8 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image,
#endif
}
maxsize = MS_MAX(msSymbolGetDefaultSize(symbol), MS_MAX(style->size, style->width));
maxunscaledsize = MS_MAX(style->minsize, style->minwidth);
clip_buf = MS_NINT(MS_MAX(maxsize * layer->scalefactor, maxunscaledsize) + 1);
maxunscaledsize = MS_MAX(style->minsize*image->resolutionfactor, style->minwidth*image->resolutionfactor);
clip_buf = MS_MAX(clip_buf,MS_NINT(MS_MAX(maxsize * layer->scalefactor, maxunscaledsize) + 1));
}


Expand All @@ -2075,6 +2076,10 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image,
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;
Expand All @@ -2092,10 +2097,18 @@ int msDrawShape(mapObj *map, layerObj *layer, shapeObj *shape, imageObj *image,
}
} else {
/* clip first, then transform. This means we are clipping in geographical space */
cliprect.minx = map->extent.minx - clip_buf*map->cellsize;
cliprect.miny = map->extent.miny - clip_buf*map->cellsize;
cliprect.maxx = map->extent.maxx + clip_buf*map->cellsize;
cliprect.maxy = map->extent.maxy + clip_buf*map->cellsize;
if(shape->type == MS_SHAPE_POLYGON) {
/*
* add a small buffer around the cliping rectangle to
* avoid lines around the edges : #179
*/
clip_buf += 2;
}
clip_buf *= map->cellsize;
cliprect.minx = map->extent.minx - clip_buf;
cliprect.miny = map->extent.miny - clip_buf;
cliprect.maxx = map->extent.maxx + clip_buf;
cliprect.maxy = map->extent.maxy + clip_buf;
if(shape->type == MS_SHAPE_POLYGON) {
msClipPolygonRect(shape, cliprect);
} else {
Expand Down
8 changes: 5 additions & 3 deletions mapfile.c
Expand Up @@ -2899,7 +2899,7 @@ void writeStyle(FILE *stream, int indent, styleObj *style)

if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_ANGLE].item)
writeAttributeBinding(stream, indent, "ANGLE", &(style->bindings[MS_STYLE_BINDING_ANGLE]));
else writeNumberOrKeyword(stream, indent, "ANGLE", 360, style->angle, style->autoangle, 1, MS_TRUE, "AUTO");
else writeNumberOrKeyword(stream, indent, "ANGLE", 0, style->angle, style->autoangle, 1, MS_TRUE, "AUTO");

writeKeyword(stream, indent, "ANTIALIAS", style->antialias, 1, MS_TRUE, "TRUE");
writeColor(stream, indent, "BACKGROUNDCOLOR", NULL, &(style->backgroundcolor));
Expand Down Expand Up @@ -2946,8 +2946,10 @@ void writeStyle(FILE *stream, int indent, styleObj *style)
writeNumber(stream, indent, "MINSCALEDENOM", -1, style->minscaledenom);
writeNumber(stream, indent, "MINSIZE", MS_MINSYMBOLSIZE, style->minsize);
writeNumber(stream, indent, "MINWIDTH", MS_MINSYMBOLWIDTH, style->minwidth);
writeDimension(stream, indent, "OFFSET", style->offsetx, style->offsety, style->bindings[MS_STYLE_BINDING_OFFSET_X].item, style->bindings[MS_STYLE_BINDING_OFFSET_Y].item);
writeDimension(stream, indent, "POLAROFFSET", style->polaroffsetpixel, style->polaroffsetangle,
if((style->numbindings > 0 && (style->bindings[MS_STYLE_BINDING_OFFSET_X].item||style->bindings[MS_STYLE_BINDING_OFFSET_Y].item))||style->offsetx!=0||style->offsety!=0)
writeDimension(stream, indent, "OFFSET", style->offsetx, style->offsety, style->bindings[MS_STYLE_BINDING_OFFSET_X].item, style->bindings[MS_STYLE_BINDING_OFFSET_Y].item);
if((style->numbindings > 0 && (style->bindings[MS_STYLE_BINDING_POLAROFFSET_PIXEL].item||style->bindings[MS_STYLE_BINDING_POLAROFFSET_ANGLE].item))||style->polaroffsetangle!=0||style->polaroffsetpixel!=0)
writeDimension(stream, indent, "POLAROFFSET", style->polaroffsetpixel, style->polaroffsetangle,
style->bindings[MS_STYLE_BINDING_POLAROFFSET_PIXEL].item, style->bindings[MS_STYLE_BINDING_POLAROFFSET_ANGLE].item);

if(style->numbindings > 0 && style->bindings[MS_STYLE_BINDING_OPACITY].item)
Expand Down
5 changes: 5 additions & 0 deletions mapscript/php/class.c
Expand Up @@ -216,6 +216,11 @@ PHP_METHOD(classObj, __set)

php_class = (php_class_object *) zend_object_store_get_object(zobj TSRMLS_CC);

/* special case for "template" which we want to set to NULL and not an empty string */
if(Z_TYPE_P(value)==IS_NULL && !strcmp(property,"template")) {
msFree(php_class->class->template);
php_class->class->template = NULL;
} else
IF_SET_STRING("name", php_class->class->name, value)
else IF_SET_STRING("title", php_class->class->title, value)
else IF_SET_LONG("type", php_class->class->type, value)
Expand Down
5 changes: 5 additions & 0 deletions mapscript/php/layer.c
Expand Up @@ -343,6 +343,11 @@ PHP_METHOD(layerObj, __set)

php_layer = (php_layer_object *) zend_object_store_get_object(zobj TSRMLS_CC);

/* special case for "template" which we want to set to NULL and not an empty string */
if(Z_TYPE_P(value)==IS_NULL && !strcmp(property,"template")) {
msFree(php_layer->layer->template);
php_layer->layer->template = NULL;
} else
IF_SET_LONG("status", php_layer->layer->status, value)
else IF_SET_LONG("debug", php_layer->layer->debug, value)
else IF_SET_STRING("classitem", php_layer->layer->classitem, value)
Expand Down
5 changes: 4 additions & 1 deletion mapscript/python/Makefile.in
Expand Up @@ -50,7 +50,10 @@ _mapscript.la: mapscript_wrap.lo pygdioctx/pygdioctx.lo $(MS_LIB)
mapscript_wrap.c: ../mapscript.i
$(SWIG) -python -shadow -modern -templatereduce -fastdispatch -fvirtual -fastproxy -modernargs -castmode -dirvtable -fastinit -fastquery -noproxydel -nobuildnone $(DEFINES) -o mapscript_wrap.c ../mapscript.i

install: _mapscript.la
install-dirs:
$(INSTALL) -d $(DESTDIR)$(PYLIBDIR)

install: install-dirs _mapscript.la
$(LTINSTALL) $(INSTALL) _mapscript.la $(DESTDIR)$(PYLIBDIR)
$(INSTALL) -c mapscript.py $(DESTDIR)$(PYLIBDIR)

Expand Down
68 changes: 61 additions & 7 deletions mapwms.c
Expand Up @@ -370,7 +370,7 @@ void msWMSPrepareNestedGroups(mapObj* map, int nVersion, char*** nestedGroups, i
msIO_fprintf(stdout, "<!-- ERROR: %s -->\n", errorMsg);
/* cannot return exception at this point because we are already writing to stdout */
} else {
/* split into subgroups. Start at adres + 1 because the first '/' would cause an extra emtpy group */
/* split into subgroups. Start at address + 1 because the first '/' would cause an extra empty group */
nestedGroups[i] = msStringSplit(groups + 1, '/', &numNestedGroups[i]);
/* */
for (j = 0; j < map->numlayers; j++) {
Expand Down Expand Up @@ -1619,15 +1619,21 @@ this request. Check wms/ows_enable_request settings.",
/* Check the style of the root layer */
} else if (map->name && strcasecmp(map->name, layers[i]) == 0) {
const char *styleName = NULL;
char *pszEncodedStyleName = NULL;
styleName = msOWSLookupMetadata(&(map->web.metadata), "MO", "style_name");
if (!styleName || strcasecmp(styleName, tokens[i]) != 0) {
if (styleName == NULL)
styleName = "default";
pszEncodedStyleName = msEncodeHTMLEntities(styleName);
if (strcasecmp(pszEncodedStyleName, tokens[i]) != 0) {
msSetError(MS_WMSERR, "Style (%s) not defined on root layer.",
"msWMSLoadGetMapParams()", tokens[i]);
msFreeCharArray(tokens, n);
msFreeCharArray(layers, numlayers);
msFree(pszEncodedStyleName);

return msWMSException(map, nVersion, "StyleNotDefined", wms_exception_format);
}
msFree(pszEncodedStyleName);
}

}
Expand Down Expand Up @@ -2353,6 +2359,14 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_
int layer_index[1];
layer_index[0] = lp->index;
if (msLegendCalcSize(map, 1, &size_x, &size_y, layer_index, 1) == 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);
snprintf(height, sizeof(height), "%d", size_y);

Expand All @@ -2376,16 +2390,57 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_

/* -------------------------------------------------------------------- */
/* check if the group parameters for the classes are set. We */
/* should then publish the deffrent class groups as diffrent styles.*/
/* should then publish the different class groups as different styles.*/
/* -------------------------------------------------------------------- */
iclassgroups = 0;
classgroups = NULL;

styleName = msOWSLookupMetadata(&(map->web.metadata), "MO", "style_name");
if (styleName == NULL)
styleName = "default";
pszEncodedStyleName = msEncodeHTMLEntities(styleName);
layerGroups = msOWSLookupMetadata(&(lp->metadata), "MO", "layer_group");
nestedLayerGroups = (char**)msSmallMalloc(sizeof(char*));

for (i=0; i<lp->numclasses; 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;
/* 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, "<!-- ERROR: %s -->\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)
break;
}
}
if (k < map->numlayers)
break;
}
if (j < numNestedLayerGroups)
continue;
}
}
if (!classgroups) {
classgroups = (char **)msSmallMalloc(sizeof(char *));
classgroups[iclassgroups++]= msStrdup(lp->class[i]->group);
} else {
/* Output style only once. */
for (j=0; j<iclassgroups; j++) {
if (strcasecmp(classgroups[j], lp->class[i]->group) == 0)
break;
Expand All @@ -2398,6 +2453,7 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_
}
}
}
msFree(pszEncodedStyleName);
if (classgroups == NULL) {
classgroups = (char **)msSmallMalloc(sizeof(char *));
classgroups[0]= msStrdup("default");
Expand Down Expand Up @@ -2461,10 +2517,8 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_
msIO_fprintf(stdout, " </Style>\n");
}
msFree(legendurl);
for (i=0; i<iclassgroups; i++)
msFree(classgroups[i]);
msFree(classgroups);

msFreeCharArray(classgroups, iclassgroups);
msFreeCharArray(nestedLayerGroups, numNestedLayerGroups);
msFree(mimetype);
}
}
Expand Down

0 comments on commit 2d4240e

Please sign in to comment.