Skip to content

Commit 8bd3d91

Browse files
committed
Bring msDrawQueryLayer() in line with msDrawVectorLayer() - addresses #5744.
1 parent d0c31fb commit 8bd3d91

File tree

1 file changed

+41
-18
lines changed

1 file changed

+41
-18
lines changed

Diff for: mapdraw.c

+41-18
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,6 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
13541354
if(map->querymap.style == MS_NORMAL || status != MS_SUCCESS) return(status);
13551355
}
13561356

1357-
13581357
/* if MS_HILITE, alter the one style (always at least 1 style), and set a MINDISTANCE for the labelObj to avoid duplicates */
13591358
if(map->querymap.style == MS_HILITE) {
13601359
if (layer->numclasses > 0) {
@@ -1433,19 +1432,28 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
14331432
}
14341433

14351434
cache = MS_FALSE;
1436-
if(layer->type == MS_LAYER_LINE && layer->class[shape.classindex]->numstyles > 1)
1435+
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))) {
1436+
int i;
14371437
cache = MS_TRUE; /* only line layers with multiple styles need be cached (I don't think POLYLINE layers need caching - SDL) */
14381438

1439+
/* we can't handle caching with attribute binding other than for the first style (#3976) */
1440+
for(i=1; i<layer->class[shape.classindex]->numstyles; i++) {
1441+
if(layer->class[shape.classindex]->styles[i]->numbindings > 0) cache = MS_FALSE;
1442+
}
1443+
}
1444+
14391445
if(annotate && layer->class[shape.classindex]->numlabels > 0) {
14401446
drawmode |= MS_DRAWMODE_LABELS;
14411447
}
14421448

14431449
if(cache) {
1444-
drawmode |= MS_DRAWMODE_SINGLESTYLE;
1445-
status = msDrawShape(map, layer, &shape, image, 0, drawmode); /* draw only the first style */
1446-
}
1447-
else
1450+
styleObj *pStyle = layer->class[shape.classindex]->styles[0];
1451+
if (pStyle->outlinewidth > 0) msOutlineRenderingPrepareStyle(pStyle, map, layer, image);
1452+
status = msDrawShape(map, layer, &shape, image, 0, drawmode|MS_DRAWMODE_SINGLESTYLE); /* draw only the first style */
1453+
if (pStyle->outlinewidth > 0) msOutlineRenderingRestoreStyle(pStyle, map, layer, image);
1454+
} else {
14481455
status = msDrawShape(map, layer, &shape, image, -1, drawmode); /* all styles */
1456+
}
14491457
if(status != MS_SUCCESS) {
14501458
msLayerClose(layer);
14511459
msFree(colorbuffer);
@@ -1472,19 +1480,36 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
14721480

14731481
if(shpcache) {
14741482
int s;
1475-
1476-
for(s=1; s<maxnumstyles; s++) {
1483+
for(s=0; s<maxnumstyles; s++) {
14771484
for(current=shpcache; current; current=current->next) {
14781485
if(layer->class[current->shape.classindex]->numstyles > s) {
1479-
styleObj *curStyle = layer->class[current->shape.classindex]->styles[s];
1486+
styleObj *pStyle = layer->class[current->shape.classindex]->styles[s];
1487+
if(pStyle->_geomtransform.type != MS_GEOMTRANSFORM_NONE)
1488+
continue; /* skip this as it has already been rendered */
14801489
if(map->scaledenom > 0) {
1481-
if((curStyle->maxscaledenom != -1) && (map->scaledenom >= curStyle->maxscaledenom))
1490+
if((pStyle->maxscaledenom != -1) && (map->scaledenom >= pStyle->maxscaledenom))
14821491
continue;
1483-
if((curStyle->minscaledenom != -1) && (map->scaledenom < curStyle->minscaledenom))
1492+
if((pStyle->minscaledenom != -1) && (map->scaledenom < pStyle->minscaledenom))
14841493
continue;
14851494
}
1486-
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, (layer->class[current->shape.classindex]->styles[s]), layer->scalefactor)))
1487-
return MS_FAILURE;
1495+
if(s==0 && pStyle->outlinewidth>0 && MS_VALID_COLOR(pStyle->color)) {
1496+
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, pStyle, layer->scalefactor))) {
1497+
return MS_FAILURE;
1498+
}
1499+
} else if(s>0) {
1500+
if (pStyle->outlinewidth > 0 && MS_VALID_COLOR(pStyle->outlinecolor)) {
1501+
msOutlineRenderingPrepareStyle(pStyle, map, layer, image);
1502+
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, pStyle, layer->scalefactor))) {
1503+
return MS_FAILURE;
1504+
}
1505+
msOutlineRenderingRestoreStyle(pStyle, map, layer, image);
1506+
}
1507+
/* draw a valid line, i.e. one with a color defined or of type pixmap */
1508+
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))) {
1509+
if(UNLIKELY(MS_FAILURE == msDrawLineSymbol(map, image, &current->shape, pStyle, layer->scalefactor)))
1510+
return MS_FAILURE;
1511+
}
1512+
}
14881513
}
14891514
}
14901515
}
@@ -1509,15 +1534,13 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
15091534
layer->class[i]->styles[layer->class[i]->numstyles-1]->color = colorbuffer[i];
15101535
else if(MS_VALID_COLOR(layer->class[i]->styles[layer->class[i]->numstyles-1]->outlinecolor))
15111536
layer->class[i]->styles[layer->class[i]->numstyles-1]->outlinecolor = colorbuffer[i]; /* if no color, restore outlinecolor for the TOP style */
1512-
}
1513-
else if (layer->class[i]->numlabels > 0) {
1514-
if(MS_VALID_COLOR(layer->class[i]->labels[0]->color))
1515-
layer->class[i]->labels[0]->color = colorbuffer[i];
1537+
} else if (layer->class[i]->numlabels > 0) {
1538+
if(MS_VALID_COLOR(layer->class[i]->labels[0]->color))
1539+
layer->class[i]->labels[0]->color = colorbuffer[i];
15161540
}
15171541

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

15231546
msFree(colorbuffer);

0 commit comments

Comments
 (0)