Skip to content

Commit

Permalink
Ensure break out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Mar 3, 2024
1 parent ab65f9c commit 7173853
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 30 deletions.
17 changes: 0 additions & 17 deletions src/mapdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,23 +323,6 @@ imageObj *msDrawMap(mapObj *map, int querymap) {
msDebug("msDrawMap(): rendering using outputformat named %s (%s).\n",
map->outputformat->name, map->outputformat->driver);

/* If an SLD file is set in the layer's styleitem, apply SLD to the layer
* before attempting to draw */
const int nLayersBefore =
map->numlayers; // use a constant as applying SLD can copy
// layers if multiple styles are used
for (i = 0; i < nLayersBefore; i++) {
// skip layers we aren't drawing?
if (map->layerorder[i] == -1)
continue;

lp = GET_LAYER(map, map->layerorder[i]);

// no need to apply style if we aren't drawing the layer
if (lp->status != MS_ON)
continue;
}

#if defined(USE_WMS_LYR) || defined(USE_WFS_LYR)

/* Time the OWS query phase */
Expand Down
26 changes: 13 additions & 13 deletions src/mapogcsld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,13 @@ int msSLDApplySLD(mapObj *map, const char *psSLDXML, int iLayer,
int i;

msSLDApplySLD_DuplicateLayers(map, nSLDLayers, pasSLDLayers);

for (i = 0; i < map->numlayers; i++) {
layerObj *lp = NULL;
const char *pszWMSLayerName = NULL;
int j;
int bUseSpecificLayer = 0;

// if the iLayer layer index has been passed, we don't
// need to loop through all the layers in the map
if (iLayer >= 0 && iLayer < map->numlayers) {
i = iLayer;
bUseSpecificLayer = 1;
Expand Down Expand Up @@ -530,18 +529,19 @@ int msSLDApplySLD(mapObj *map, const char *psSLDXML, int iLayer,
break;
}
}
if (bUseSpecificLayer && bSldApplied == 0) {
// there was no name match between the map layer and the SLD named layer
// check if we should apply the first SLD layer anyway
const char *pszSLDAllowAnyName =
msLookupHashTable(&(lp->metadata), "SLD_USE_FIRST_STYLE");
if (pszSLDAllowAnyName) {
sldLayer = &pasSLDLayers[0];
if (msApplySldLayerToMapLayer(sldLayer, lp) == MS_FAILURE) {
return MS_FAILURE;
};
if (bUseSpecificLayer) {
if (bSldApplied == 0) {
// there was no name match between the map layer and the SLD named
// layer check if we should apply the first SLD layer anyway
const char *pszSLDAllowAnyName =
msLookupHashTable(&(lp->metadata), "SLD_USE_FIRST_STYLE");
if (pszSLDAllowAnyName) {
sldLayer = &pasSLDLayers[0];
if (msApplySldLayerToMapLayer(sldLayer, lp) == MS_FAILURE) {
return MS_FAILURE;
};
}
}
} else {
break;
}
}
Expand Down

0 comments on commit 7173853

Please sign in to comment.