@@ -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 ) {
@@ -1428,19 +1427,28 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
14281427 }
14291428
14301429 cache = MS_FALSE ;
1431- if (layer -> type == MS_LAYER_LINE && layer -> class [shape .classindex ]-> numstyles > 1 )
1430+ 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 ))) {
1431+ int i ;
14321432 cache = MS_TRUE ; /* only line layers with multiple styles need be cached (I don't think POLYLINE layers need caching - SDL) */
14331433
1434+ /* we can't handle caching with attribute binding other than for the first style (#3976) */
1435+ for (i = 1 ; i < layer -> class [shape .classindex ]-> numstyles ; i ++ ) {
1436+ if (layer -> class [shape .classindex ]-> styles [i ]-> numbindings > 0 ) cache = MS_FALSE ;
1437+ }
1438+ }
1439+
14341440 if (annotate && layer -> class [shape .classindex ]-> numlabels > 0 ) {
14351441 drawmode |= MS_DRAWMODE_LABELS ;
14361442 }
14371443
14381444 if (cache ) {
1439- drawmode |= MS_DRAWMODE_SINGLESTYLE ;
1440- status = msDrawShape (map , layer , & shape , image , 0 , drawmode ); /* draw only the first style */
1441- }
1442- else
1445+ styleObj * pStyle = layer -> class [shape .classindex ]-> styles [0 ];
1446+ if (pStyle -> outlinewidth > 0 ) msOutlineRenderingPrepareStyle (pStyle , map , layer , image );
1447+ status = msDrawShape (map , layer , & shape , image , 0 , drawmode |MS_DRAWMODE_SINGLESTYLE ); /* draw only the first style */
1448+ if (pStyle -> outlinewidth > 0 ) msOutlineRenderingRestoreStyle (pStyle , map , layer , image );
1449+ } else {
14431450 status = msDrawShape (map , layer , & shape , image , -1 , drawmode ); /* all styles */
1451+ }
14441452 if (status != MS_SUCCESS ) {
14451453 msLayerClose (layer );
14461454 msFree (colorbuffer );
@@ -1467,19 +1475,36 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
14671475
14681476 if (shpcache ) {
14691477 int s ;
1470-
1471- for (s = 1 ; s < maxnumstyles ; s ++ ) {
1478+ for (s = 0 ; s < maxnumstyles ; s ++ ) {
14721479 for (current = shpcache ; current ; current = current -> next ) {
14731480 if (layer -> class [current -> shape .classindex ]-> numstyles > s ) {
1474- styleObj * curStyle = layer -> class [current -> shape .classindex ]-> styles [s ];
1481+ styleObj * pStyle = layer -> class [current -> shape .classindex ]-> styles [s ];
1482+ if (pStyle -> _geomtransform .type != MS_GEOMTRANSFORM_NONE )
1483+ continue ; /* skip this as it has already been rendered */
14751484 if (map -> scaledenom > 0 ) {
1476- if ((curStyle -> maxscaledenom != -1 ) && (map -> scaledenom >= curStyle -> maxscaledenom ))
1485+ if ((pStyle -> maxscaledenom != -1 ) && (map -> scaledenom >= pStyle -> maxscaledenom ))
14771486 continue ;
1478- if ((curStyle -> minscaledenom != -1 ) && (map -> scaledenom < curStyle -> minscaledenom ))
1487+ if ((pStyle -> minscaledenom != -1 ) && (map -> scaledenom < pStyle -> minscaledenom ))
14791488 continue ;
14801489 }
1481- if (UNLIKELY (MS_FAILURE == msDrawLineSymbol (map , image , & current -> shape , (layer -> class [current -> shape .classindex ]-> styles [s ]), layer -> scalefactor )))
1482- return MS_FAILURE ;
1490+ if (s == 0 && pStyle -> outlinewidth > 0 && MS_VALID_COLOR (pStyle -> color )) {
1491+ if (UNLIKELY (MS_FAILURE == msDrawLineSymbol (map , image , & current -> shape , pStyle , layer -> scalefactor ))) {
1492+ return MS_FAILURE ;
1493+ }
1494+ } else if (s > 0 ) {
1495+ if (pStyle -> outlinewidth > 0 && MS_VALID_COLOR (pStyle -> outlinecolor )) {
1496+ msOutlineRenderingPrepareStyle (pStyle , map , layer , image );
1497+ if (UNLIKELY (MS_FAILURE == msDrawLineSymbol (map , image , & current -> shape , pStyle , layer -> scalefactor ))) {
1498+ return MS_FAILURE ;
1499+ }
1500+ msOutlineRenderingRestoreStyle (pStyle , map , layer , image );
1501+ }
1502+ /* draw a valid line, i.e. one with a color defined or of type pixmap */
1503+ 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 ))) {
1504+ if (UNLIKELY (MS_FAILURE == msDrawLineSymbol (map , image , & current -> shape , pStyle , layer -> scalefactor )))
1505+ return MS_FAILURE ;
1506+ }
1507+ }
14831508 }
14841509 }
14851510 }
@@ -1501,15 +1526,13 @@ int msDrawQueryLayer(mapObj *map, layerObj *layer, imageObj *image)
15011526 layer -> class [i ]-> styles [layer -> class [i ]-> numstyles - 1 ]-> color = colorbuffer [i ];
15021527 else if (MS_VALID_COLOR (layer -> class [i ]-> styles [layer -> class [i ]-> numstyles - 1 ]-> outlinecolor ))
15031528 layer -> class [i ]-> styles [layer -> class [i ]-> numstyles - 1 ]-> outlinecolor = colorbuffer [i ]; /* if no color, restore outlinecolor for the TOP style */
1504- }
1505- else if (layer -> class [i ]-> numlabels > 0 ) {
1506- if (MS_VALID_COLOR (layer -> class [i ]-> labels [0 ]-> color ))
1507- layer -> class [i ]-> labels [0 ]-> color = colorbuffer [i ];
1529+ } else if (layer -> class [i ]-> numlabels > 0 ) {
1530+ if (MS_VALID_COLOR (layer -> class [i ]-> labels [0 ]-> color ))
1531+ layer -> class [i ]-> labels [0 ]-> color = colorbuffer [i ];
15081532 }
15091533
15101534 if (layer -> class [i ]-> numlabels > 0 )
15111535 layer -> class [i ]-> labels [0 ]-> mindistance = mindistancebuffer [i ]; /* RFC77 TODO: again, only using the first label, is that cool? */
1512-
15131536 }
15141537
15151538 msFree (colorbuffer );
0 commit comments