Opened 20 years ago

Closed 19 years ago

#539 closed enhancement (fixed)

[PHP MapScript] need method of determining layers in legend

Reported by: pspencer@… Owned by: mapserverbugs
Priority: high Milestone: 4.4 release
Component: MapScript-PHP Version: 4.1
Severity: minor Keywords:
Cc:

Description

It is currently not possible to determine the layers that will be included or
were included in a legend when using the legend html template processor. 
Request that a function be added to PHP MapScript that returns an array of layer
indexes that will be output in the legend, or processLegendTemplate be given
this return value.

The purpose is to allow a more intelligent layer visibility control to be built
that can detect layers coming in/out of scale and not turn them off.  The
standard way of avoiding problematic layers (like newly added ones) is to
maintain a list of layers that were used to generate the legend on the previous
page and only process visibility changes on those.  The use of opt_flag=1 (or
not using it, actually) means that layers do not appear in the legend output at
all when they are out of scale.  It would be possible to code for this exact
problem but would require quite a lot of php mapscript to detect it.  It also
would only work for scale dependencies ... and would not work for any other
situations where layers are turned on/off by mapserver (are there any?)  The
addition of this functionality would simplify the legend code or at least,
prevent hairy logic in PHP :)

One thing to note.  It should also return (or be possible to request) the
classes and groups since they are also top level blocks in the template
processor.  Not sure what the purpose of this might be, though.

Change History (13)

comment:1 by dmorissette, 20 years ago

How about a $layer->isVisible() call that would return MS_TRUE if a given layer
is currently visible, based on scale, status setting, etc?  This would map
directly to the msLayerIsVisible() function internally which is used in
rendering maps.

Let's rediscuss that after the 4.2 release.

comment:2 by bartvde@…, 20 years ago

Is this not a duplicate of bug no. 648?

http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=648

Or is the isVisible() function needed next to the template processing keyword?

comment:3 by dmorissette, 20 years ago

I'll let Paul decide if he still needs it or notnow that the HTML legend handles
visibility.

comment:4 by pspencer@…, 20 years ago

this is not a duplicate of bug 648.  The request here is to get access to that
information through php_mapscript so that layer control logic can correctly
determine if layers have appeared/disappeared due to scale visibility rather
than the user turning them on and off.

comment:5 by dmorissette, 20 years ago

Paul, which information do you need access to exactly? 
Is it enought to provide a $layer->isVisible() call that returns
MS_TRUE/MS_FALSE as suggested in comment #1 above, or do you need access to more
fine grained information.

comment:6 by pspencer@…, 20 years ago

I need to think this through a bit ... the implementation of this should be
flexible enough to handle forseeable situations if we are going to actually add
the code, so I want to make sure I understand the implications of potential
implementations.  I'll post additional comments when I have thought this through 

comment:7 by dmorissette, 20 years ago

Please keep in mind that $layer->isVisible() is very straightforward to add and
can be added in a few minutes: it is simply a call to the lower-level
msIsLayerVisible(), so we should go for that if that's enought for your needs.
If you need more than that then that may require some real development.

comment:8 by assefa, 19 years ago

is this still needed or can it be set to FUTURE ?

comment:9 by dmorissette, 19 years ago

Milestone: FUTURE
I say we mark this to FUTURE (done) and Paul wake up this bug when you have had
time to think this through (as per comment #6)

comment:10 by pspencer@…, 19 years ago

oddly enough, this problem has come up again a couple of times on the chameleon
mailing list.  I've thought this through and I think that $oLayer->isVisible()
will be sufficient to build much better layer visibility controls that don't
rely on metadata tricks and fancy work-arounds to account for layers that are on
but out of scale.

If it is just a matter of a few minutes, I'd like to see this in 4.4 but it is
not critical for me right now.  

comment:11 by dmorissette, 19 years ago

Status: newassigned
I'll add $layer->isVisible() now.

comment:12 by dmorissette, 19 years ago

Milestone: FUTURE4.4 release

comment:13 by dmorissette, 19 years ago

Resolution: fixed
Status: assignedclosed
Done. I have added $layer->isVisible() to PHP MapScript that returns
MS_TRUE/MS_FALSE depending on whether the layer is currently visible in the map
(i.e. turned on, in scale, etc.). 

Also created bug 1052 about adding this to SWIG MapScript.
Note: See TracTickets for help on using tickets.