* Test whether a layer should be drawn or not in the current map view and * at the current scale. * Returns TRUE if layer is visible, FALSE if not. */
| 585 | * Returns TRUE if layer is visible, FALSE if not. |
| 586 | */ |
| 587 | int msLayerIsVisible(mapObj *map, layerObj *layer) |
| 588 | { |
| 589 | int i; |
| 590 | |
| 591 | if(!layer->data && !layer->tileindex && !layer->connection && !layer->features && !layer->layerinfo) |
| 592 | return(MS_FALSE); /* no data associated with this layer, not an error since layer may be used as a template from MapScript */ |
| 593 | |
| 594 | if(layer->type == MS_LAYER_QUERY || layer->type == MS_LAYER_TILEINDEX) return(MS_FALSE); |
| 595 | if((layer->status != MS_ON) && (layer->status != MS_DEFAULT)) return(MS_FALSE); |
| 596 | |
| 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 | |
| 608 | if(map->scaledenom > 0) { |
| 609 | |
| 610 | /* layer scale boundaries should be checked first */ |
| 611 | if((layer->maxscaledenom > 0) && (map->scaledenom > layer->maxscaledenom)) { |
| 612 | if( layer->debug >= MS_DEBUGLEVEL_V ) { |
| 613 | msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.MAXSCALE is too small for this MAP scale\n", layer->name); |
| 614 | } |
| 615 | return(MS_FALSE); |
| 616 | } |
| 617 | if((layer->minscaledenom > 0) && (map->scaledenom <= layer->minscaledenom)) { |
| 618 | if( layer->debug >= MS_DEBUGLEVEL_V ) { |
| 619 | msDebug("msLayerIsVisible(): Skipping layer (%s) because LAYER.MINSCALE is too large for this MAP scale\n", layer->name); |
| 620 | } |
| 621 | return(MS_FALSE); |
| 622 | } |
| 623 | |
| 624 | /* now check class scale boundaries (all layers *must* pass these tests) */ |
| 625 | if(layer->numclasses > 0) { |
| 626 | for(i=0; i<layer->numclasses; i++) { |
| 627 | if((layer->class[i]->maxscaledenom > 0) && (map->scaledenom > layer->class[i]->maxscaledenom)) |
| 628 | continue; /* can skip this one, next class */ |
| 629 | if((layer->class[i]->minscaledenom > 0) && (map->scaledenom <= layer->class[i]->minscaledenom)) |
| 630 | continue; /* can skip this one, next class */ |
| 631 | |
| 632 | break; /* can't skip this class (or layer for that matter) */ |
| 633 | } |
| 634 | if(i == layer->numclasses) { |
| 635 | if( layer->debug >= MS_DEBUGLEVEL_V ) { |
| 636 | msDebug("msLayerIsVisible(): Skipping layer (%s) because no CLASS in the layer is in-scale for this MAP scale\n", layer->name); |
| 637 | } |
| 638 | return(MS_FALSE); |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | } |
| 643 | |
| 644 | if (layer->maxscaledenom <= 0 && layer->minscaledenom <= 0) { |
no test coverage detected