Skip to content

Commit

Permalink
Merge pull request #5951 from mapserver/sdlime-backport-5920
Browse files Browse the repository at this point in the history
Backport pull-request #5920 from master to branch-7-4.
  • Loading branch information
sdlime committed Dec 16, 2019
2 parents 0e2b1b3 + 54962c1 commit fd836a1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 43 deletions.
69 changes: 50 additions & 19 deletions mapdraw.c
Expand Up @@ -1354,7 +1354,6 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
if(map->querymap.style == MS_NORMAL || status != MS_SUCCESS) return(status);
}


/* if MS_HILITE, alter the one style (always at least 1 style), and set a MINDISTANCE for the labelObj to avoid duplicates */
if(map->querymap.style == MS_HILITE) {
if (layer->numclasses > 0) {
Expand All @@ -1377,6 +1376,11 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
colorbuffer[i] = layer->class[i]->styles[0]->outlinecolor; /* if no color, save the outlinecolor from the BOTTOM style */
layer->class[i]->styles[0]->outlinecolor = map->querymap.color;
}
} else if (layer->type == MS_LAYER_LINE && layer->class[i]->numstyles > 0 && layer->class[i]->styles[0]->outlinewidth > 0) { /* alter BOTTOM style for lines with outlines */
if(MS_VALID_COLOR(layer->class[i]->styles[0]->color)) {
colorbuffer[i] = layer->class[i]->styles[0]->color; /* save the color from the BOTTOM style */
layer->class[i]->styles[0]->color = map->querymap.color;
} /* else ??? */
} else if (layer->class[i]->numstyles > 0) {
if(MS_VALID_COLOR(layer->class[i]->styles[layer->class[i]->numstyles-1]->color)) {
colorbuffer[i] = layer->class[i]->styles[layer->class[i]->numstyles-1]->color; /* save the color from the TOP style */
Expand All @@ -1388,7 +1392,7 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
} else if (layer->class[i]->numlabels > 0) {
colorbuffer[i] = layer->class[i]->labels[0]->color;
layer->class[i]->labels[0]->color = map->querymap.color;
}
} /* else ??? */

mindistancebuffer[i] = -1; /* RFC77 TODO: only using the first label, is that cool? */
if(layer->class[i]->numlabels > 0) {
Expand Down Expand Up @@ -1428,19 +1432,28 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
}

cache = MS_FALSE;
if(layer->type == MS_LAYER_LINE && layer->class[shape.classindex]->numstyles > 1)
if(layer->type == MS_LAYER_LINE && (layer->class[shape.classindex]->numstyles > 1 || (layer->class[shape.classindex]->numstyles == 1 && layer->class[shape.classindex]->styles[0]->outlinewidth > 0))) {
int i;
cache = MS_TRUE; /* only line layers with multiple styles need be cached (I don't think POLYLINE layers need caching - SDL) */

/* we can't handle caching with attribute binding other than for the first style (#3976) */
for(i=1; i<layer->class[shape.classindex]->numstyles; i++) {
if(layer->class[shape.classindex]->styles[i]->numbindings > 0) cache = MS_FALSE;
}
}

if(annotate && layer->class[shape.classindex]->numlabels > 0) {
drawmode |= MS_DRAWMODE_LABELS;
}

if(cache) {
drawmode |= MS_DRAWMODE_SINGLESTYLE;
status = msDrawShape(map, layer, &shape, image, 0, drawmode); /* draw only the first style */
}
else
styleObj *pStyle = layer->class[shape.classindex]->styles[0];
if (pStyle->outlinewidth > 0) msOutlineRenderingPrepareStyle(pStyle, map, layer, image);
status = msDrawShape(map, layer, &shape, image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE); /* draw only the first style */
if (pStyle->outlinewidth > 0) msOutlineRenderingRestoreStyle(pStyle, map, layer, image);
} else {
status = msDrawShape(map, layer, &shape, image, -1, drawmode); /* all styles */
}
if(status != MS_SUCCESS) {
msLayerClose(layer);
msFree(colorbuffer);
Expand All @@ -1467,19 +1480,36 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)

if(shpcache) {
int s;

for(s=1; s<maxnumstyles; s++) {
for(s=0; s<maxnumstyles; s++) {
for(current=shpcache; current; current=current->next) {
if(layer->class[current->shape.classindex]->numstyles > s) {
styleObj *curStyle = layer->class[current->shape.classindex]->styles[s];
styleObj *pStyle = layer->class[current->shape.classindex]->styles[s];
if(pStyle->_geomtransform.type != MS_GEOMTRANSFORM_NONE)
continue; /* skip this as it has already been rendered */
if(map->scaledenom > 0) {
if((curStyle->maxscaledenom != -1) && (map->scaledenom >= curStyle->maxscaledenom))
if((pStyle->maxscaledenom != -1) && (map->scaledenom >= pStyle->maxscaledenom))
continue;
if((curStyle->minscaledenom != -1) && (map->scaledenom < curStyle->minscaledenom))
if((pStyle->minscaledenom != -1) && (map->scaledenom < pStyle->minscaledenom))
continue;
}
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, (layer->class[current->shape.classindex]->styles[s]), layer->scalefactor)))
return MS_FAILURE;
if(s==0 && pStyle->outlinewidth>0 && MS_VALID_COLOR(pStyle->color)) {
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, pStyle, layer->scalefactor))) {
return MS_FAILURE;
}
} else if(s>0) {
if (pStyle->outlinewidth > 0 && MS_VALID_COLOR(pStyle->outlinecolor)) {
msOutlineRenderingPrepareStyle(pStyle, map, layer, image);
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, pStyle, layer->scalefactor))) {
return MS_FAILURE;
}
msOutlineRenderingRestoreStyle(pStyle, map, layer, image);
}
/* draw a valid line, i.e. one with a color defined or of type pixmap */
if(MS_VALID_COLOR(pStyle->color) || (pStyle->symbol<map->symbolset.numsymbols && (map->symbolset.symbol[pStyle->symbol]->type == MS_SYMBOL_PIXMAP || map->symbolset.symbol[pStyle->symbol]->type == MS_SYMBOL_SVG))) {
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, pStyle, layer->scalefactor)))
return MS_FAILURE;
}
}
}
}
}
Expand All @@ -1496,20 +1526,21 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
layer->class[i]->styles[0]->color = colorbuffer[i];
else if(MS_VALID_COLOR(layer->class[i]->styles[0]->outlinecolor))
layer->class[i]->styles[0]->outlinecolor = colorbuffer[i]; /* if no color, restore outlinecolor for the BOTTOM style */
} else if (layer->type == MS_LAYER_LINE && layer->class[i]->numstyles > 0 && layer->class[i]->styles[0]->outlinewidth > 0) {
if(MS_VALID_COLOR(layer->class[i]->styles[0]->color))
layer->class[i]->styles[0]->color = colorbuffer[i];
} else if (layer->class[i]->numstyles > 0) {
if(MS_VALID_COLOR(layer->class[i]->styles[layer->class[i]->numstyles-1]->color))
layer->class[i]->styles[layer->class[i]->numstyles-1]->color = colorbuffer[i];
else if(MS_VALID_COLOR(layer->class[i]->styles[layer->class[i]->numstyles-1]->outlinecolor))
layer->class[i]->styles[layer->class[i]->numstyles-1]->outlinecolor = colorbuffer[i]; /* if no color, restore outlinecolor for the TOP style */
}
else if (layer->class[i]->numlabels > 0) {
if(MS_VALID_COLOR(layer->class[i]->labels[0]->color))
layer->class[i]->labels[0]->color = colorbuffer[i];
} else if (layer->class[i]->numlabels > 0) {
if(MS_VALID_COLOR(layer->class[i]->labels[0]->color))
layer->class[i]->labels[0]->color = colorbuffer[i];
}

if(layer->class[i]->numlabels > 0)
layer->class[i]->labels[0]->mindistance = mindistancebuffer[i]; /* RFC77 TODO: again, only using the first label, is that cool? */

}

msFree(colorbuffer);
Expand Down
41 changes: 17 additions & 24 deletions mapwms.c
Expand Up @@ -994,7 +994,6 @@ int msWMSLoadGetMapParams(mapObj *map, int nVersion,
epsgbuf[0]='\0';
srsbuffer[0]='\0';


/* Some of the getMap parameters are actually required depending on the */
/* request, but for now we assume all are optional and the map file */
/* defaults will apply. */
Expand Down Expand Up @@ -1035,9 +1034,6 @@ int msWMSLoadGetMapParams(mapObj *map, int nVersion,
request = values[i];
}




if (strcasecmp(names[i], "LAYERS") == 0) {
int j, k, iLayer, *layerOrder;
int nLayerOrder = 0;
Expand Down Expand Up @@ -1153,7 +1149,6 @@ int msWMSLoadGetMapParams(mapObj *map, int nVersion,
used with msLoadProjection and that does alreay the job */
/* snprintf(srsbuffer, 100, "init=epsg:%.20s", values[i]+5); */


snprintf(srsbuffer, sizeof(srsbuffer), "EPSG:%.20s",values[i]+5);
snprintf(epsgbuf, sizeof(epsgbuf), "EPSG:%.20s",values[i]+5);

Expand All @@ -1164,7 +1159,6 @@ int msWMSLoadGetMapParams(mapObj *map, int nVersion,
srsbuffer[strlen(srsbuffer)-1] = '\0';
if (epsgbuf[strlen(epsgbuf)-1] == ',')
epsgbuf[strlen(epsgbuf)-1] = '\0';

}

/* we need to wait until all params are read before */
Expand Down Expand Up @@ -1650,29 +1644,12 @@ this request. Check wms/ows_enable_request settings.",
}
}

/*
** Apply vendor-specific filter if specified
*/
if (filter) {
if (sld_url || sld_body) {
msSetError(MS_WMSERR,
"Vendor-specific FILTER parameter cannot be used with SLD or SLD_BODY.",
"msWMSLoadGetMapParams()");
return msWMSException(map, nVersion, NULL, wms_exception_format);
}

if (msWMSApplyFilter(map, nVersion, filter, need_axis_swap, wms_exception_format) == MS_FAILURE) {
return MS_FAILURE;/* msWMSException(map, nVersion, "InvalidFilterRequest"); */
}
}

if (sld_url || sld_body) {
int nLayersBefore, nLayerAfter;
char request_tmp[32];
char *pszLayerNames = NULL;
nLayersBefore = map->numlayers;


/* -------------------------------------------------------------------- */
/* if LAYERS parameter was not given, set all layers to off */
/* -------------------------------------------------------------------- */
Expand All @@ -1683,7 +1660,6 @@ this request. Check wms/ows_enable_request settings.",
}
}


/*apply sld if defined. This is done here so that bbox and srs are already applied*/
if (sld_url) {
if ((status = msSLDApplySLDURL(map, sld_url, -1, NULL, &pszLayerNames)) != MS_SUCCESS)
Expand Down Expand Up @@ -1734,6 +1710,7 @@ this request. Check wms/ows_enable_request settings.",
msFree(pszLayerNames);

}

/* Validate Styles :
** MapServer advertize styles through th group setting in a class object.
** If no styles are set MapServer expects to have empty values
Expand Down Expand Up @@ -1909,6 +1886,22 @@ this request. Check wms/ows_enable_request settings.",

}

/*
** Apply vendor-specific filter if specified
*/
if (filter) {
if (sld_url || sld_body) {
msSetError(MS_WMSERR,
"Vendor-specific FILTER parameter cannot be used with SLD or SLD_BODY.",
"msWMSLoadGetMapParams()");
return msWMSException(map, nVersion, NULL, wms_exception_format);
}

if (msWMSApplyFilter(map, nVersion, filter, need_axis_swap, wms_exception_format) == MS_FAILURE) {
return MS_FAILURE;/* msWMSException(map, nVersion, "InvalidFilterRequest"); */
}
}

return MS_SUCCESS;
}

Expand Down

0 comments on commit fd836a1

Please sign in to comment.