Skip to content
Permalink
Browse files

Bring msDrawQueryLayer() in line with msDrawVectorLayer() - addresses #…

  • Loading branch information
sdlime committed Nov 12, 2019
1 parent d0c31fb commit 8bd3d91dccd2f90ec399a09abd339b20b5a34d12
Showing with 41 additions and 18 deletions.
  1. +41 −18 mapdraw.c
@@ -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) {
@@ -1433,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);
@@ -1472,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;
}
}
}
}
}
@@ -1509,15 +1534,13 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
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);

0 comments on commit 8bd3d91

Please sign in to comment.
You can’t perform that action at this time.