Skip to content

Commit 6a5cad3

Browse files
committed
msLayerIsVisible(): speed it up by doing layer vs map scale comparisons before extent comparison
1 parent 226d19a commit 6a5cad3

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

mapdraw.c

+18-13
Original file line numberDiff line numberDiff line change
@@ -594,17 +594,8 @@ int msLayerIsVisible(mapObj *map, layerObj *layer)
594594
if(layer->type == MS_LAYER_QUERY || layer->type == MS_LAYER_TILEINDEX) return(MS_FALSE);
595595
if((layer->status != MS_ON) && (layer->status != MS_DEFAULT)) return(MS_FALSE);
596596

597-
/* Only return MS_FALSE if it is definitely false. Sometimes it will return MS_UNKNOWN, which we
598-
** consider true, for this use case (it might be visible, try and draw it, see what happens). */
599-
if ( msExtentsOverlap(map, layer) == MS_FALSE ) {
600-
if( layer->debug >= MS_DEBUGLEVEL_V ) {
601-
msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.EXTENT does not intersect MAP.EXTENT\n", layer->name);
602-
}
603-
return(MS_FALSE);
604-
}
605-
606-
if(msEvalContext(map, layer, layer->requires) == MS_FALSE) return(MS_FALSE);
607-
597+
/* Do comparisons of layer scale vs map scale now, since msExtentsOverlap() */
598+
/* can be slow */
608599
if(map->scaledenom > 0) {
609600

610601
/* layer scale boundaries should be checked first */
@@ -614,13 +605,27 @@ int msLayerIsVisible(mapObj *map, layerObj *layer)
614605
}
615606
return(MS_FALSE);
616607
}
617-
if((layer->minscaledenom > 0) && (map->scaledenom <= layer->minscaledenom)) {
608+
if(/*(layer->minscaledenom > 0) &&*/ (map->scaledenom <= layer->minscaledenom)) {
618609
if( layer->debug >= MS_DEBUGLEVEL_V ) {
619610
msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.MINSCALE is too large for this MAP scale\n", layer->name);
620611
}
621612
return(MS_FALSE);
622613
}
623-
614+
}
615+
616+
/* Only return MS_FALSE if it is definitely false. Sometimes it will return MS_UNKNOWN, which we
617+
** consider true, for this use case (it might be visible, try and draw it, see what happens). */
618+
if ( msExtentsOverlap(map, layer) == MS_FALSE ) {
619+
if( layer->debug >= MS_DEBUGLEVEL_V ) {
620+
msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.EXTENT does not intersect MAP.EXTENT\n", layer->name);
621+
}
622+
return(MS_FALSE);
623+
}
624+
625+
if(msEvalContext(map, layer, layer->requires) == MS_FALSE) return(MS_FALSE);
626+
627+
if(map->scaledenom > 0) {
628+
624629
/* now check class scale boundaries (all layers *must* pass these tests) */
625630
if(layer->numclasses > 0) {
626631
for(i=0; i<layer->numclasses; i++) {

0 commit comments

Comments
 (0)