Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
msLayerIsVisible(): speed it up by doing layer vs map scale compariso…
…ns before extent comparison
  • Loading branch information
rouault committed Oct 12, 2017
1 parent 226d19a commit 6a5cad3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions mapdraw.c
Expand Up @@ -594,17 +594,8 @@ int msLayerIsVisible(mapObj *map, layerObj *layer)
if(layer->type == MS_LAYER_QUERY || layer->type == MS_LAYER_TILEINDEX) return(MS_FALSE);
if((layer->status != MS_ON) && (layer->status != MS_DEFAULT)) return(MS_FALSE);

/* Only return MS_FALSE if it is definitely false. Sometimes it will return MS_UNKNOWN, which we
** consider true, for this use case (it might be visible, try and draw it, see what happens). */
if ( msExtentsOverlap(map, layer) == MS_FALSE ) {
if( layer->debug >= MS_DEBUGLEVEL_V ) {
msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.EXTENT does not intersect MAP.EXTENT\n", layer->name);
}
return(MS_FALSE);
}

if(msEvalContext(map, layer, layer->requires) == MS_FALSE) return(MS_FALSE);

/* Do comparisons of layer scale vs map scale now, since msExtentsOverlap() */
/* can be slow */
if(map->scaledenom > 0) {

/* layer scale boundaries should be checked first */
Expand All @@ -614,13 +605,27 @@ int msLayerIsVisible(mapObj *map, layerObj *layer)
}
return(MS_FALSE);
}
if((layer->minscaledenom > 0) && (map->scaledenom <= layer->minscaledenom)) {
if(/*(layer->minscaledenom > 0) &&*/ (map->scaledenom <= layer->minscaledenom)) {
if( layer->debug >= MS_DEBUGLEVEL_V ) {
msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.MINSCALE is too large for this MAP scale\n", layer->name);
}
return(MS_FALSE);
}

}

/* Only return MS_FALSE if it is definitely false. Sometimes it will return MS_UNKNOWN, which we
** consider true, for this use case (it might be visible, try and draw it, see what happens). */
if ( msExtentsOverlap(map, layer) == MS_FALSE ) {
if( layer->debug >= MS_DEBUGLEVEL_V ) {
msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.EXTENT does not intersect MAP.EXTENT\n", layer->name);
}
return(MS_FALSE);
}

if(msEvalContext(map, layer, layer->requires) == MS_FALSE) return(MS_FALSE);

if(map->scaledenom > 0) {

/* now check class scale boundaries (all layers *must* pass these tests) */
if(layer->numclasses > 0) {
for(i=0; i<layer->numclasses; i++) {
Expand Down

0 comments on commit 6a5cad3

Please sign in to comment.