More than two hierarchy levels in the legend (with MapServer)

6 messages Options
Embed this post
Permalink
Bernhard Schneider

More than two hierarchy levels in the legend (with MapServer)

Reply Threaded More More options
Print post
Permalink
Hello everyone,

For the map application I am currently working on, it would great if I  
could freely nest map groups in the legend. It seems to me, however,  
that Fusion, when using MapServer as map rendering engine, only allows  
two levels of hierarchy, that is, map groups can only contain regular  
map layer, not other map groups.

Because this bothered me, I checked the code, and I think that the  
function parseMapLayersAndGroups() of Fusion.Maps.MapServer is  
responsible for this limitation. This function receives the layer and  
group information in two lists, one containing all map layers  
(including the map groups), and one containing only the map groups.  
Interestingly, the hierarchy information is only given in the layer  
list where each layer knows which layer its parent is. The map groups  
list holds the necessary data structures, but the according fields are  
empty.

In a bold attempt to overcome the limitation, I altered the function  
by adding code (which I am happy to share) that loops through the  
group list. It checks for each group if there is a parent indicated  
for the corresponding map layer (as mentioned, each group also exists  
as layer in the layer list). If so, the parent information is assigned  
to the group so that each group knows whether it belongs to another  
group. I'm not sure whether I made things better or worse, but the fix  
works in my application.

Any thoughts or comments?

Bernhard

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Bernhard Schneider

RE: More than two hierarchy levels in the legend (with MapServer)

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
RE: [fusion-users] More than two hierarchy levels in the legend (with MapServer)

Hello everyone,

Digging a bit further, I realised that the code in LoadMap.php (fusion/MapServer/php/) is responsible for restricting the nesting depth to 2. It retrieves the information from MapScript which itself read it from the map file. There is the comment "parent is always not set for mapserver since we can't have nested groups" in the code.

Is it the MapServer (MapScript) that imposes the limitation? I wonder whether it isn't just a matter of interpreting the map file from a "client side". The map rendering engine should not worry about nesting levels, it only needs to know which layers are visible and in which order they should be drawn. Aren't the groups mainly (only) there for organising the layers in the legend?

Just wondering.
Bernhard


_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Spencer-2

Re: More than two hierarchy levels in the legend (with MapServer)

Reply Threaded More More options
Print post
Permalink
Bernhard,

This restriction comes from the fact that MapServer itself only  
supports one level of grouping via the GROUP keyword in a LAYER  
object.  The map rendering does not specifically use groups, it uses  
the layers themselves in the order they are present in the map file  
(layer at the top is drawn first, subsequent layers are drawn over it  
- painters algorithm).  Groups are only for organising layers in the  
legend.

Cheers

Paul

On 10-Jun-08, at 8:54 AM, Bernhard Schneider wrote:

> Hello everyone,
>
> Digging a bit further, I realised that the code in LoadMap.php  
> (fusion/MapServer/php/) is responsible for restricting the nesting  
> depth to 2. It retrieves the information from MapScript which itself  
> read it from the map file. There is the comment "parent is always  
> not set for mapserver since we can't have nested groups" in the code.
>
> Is it the MapServer (MapScript) that imposes the limitation? I  
> wonder whether it isn't just a matter of interpreting the map file  
> from a "client side". The map rendering engine should not worry  
> about nesting levels, it only needs to know which layers are visible  
> and in which order they should be drawn. Aren't the groups mainly  
> (only) there for organising the layers in the legend?
>
> Just wondering.
> Bernhard
>
> _______________________________________________
> fusion-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fusion-users


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://www.dmsolutions.ca/

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Deschamps

Re: More than two hierarchy levels in the legend (with MapServer)

Reply Threaded More More options
Print post
Permalink
One other thing unmentioned here is that layer "grouping" allows you
to toggle the visibility status of an entire group through the legend
widget.

Cheers

Paul D.


On Tue, Jun 10, 2008 at 10:36 AM, Paul Spencer <[hidden email]> wrote:

> Bernhard,
>
> This restriction comes from the fact that MapServer itself only supports one
> level of grouping via the GROUP keyword in a LAYER object.  The map
> rendering does not specifically use groups, it uses the layers themselves in
> the order they are present in the map file (layer at the top is drawn first,
> subsequent layers are drawn over it - painters algorithm).  Groups are only
> for organising layers in the legend.
>
> Cheers
>
> Paul
>
> On 10-Jun-08, at 8:54 AM, Bernhard Schneider wrote:
>
>> Hello everyone,
>>
>> Digging a bit further, I realised that the code in LoadMap.php
>> (fusion/MapServer/php/) is responsible for restricting the nesting depth to
>> 2. It retrieves the information from MapScript which itself read it from the
>> map file. There is the comment "parent is always not set for mapserver since
>> we can't have nested groups" in the code.
>>
>> Is it the MapServer (MapScript) that imposes the limitation? I wonder
>> whether it isn't just a matter of interpreting the map file from a "client
>> side". The map rendering engine should not worry about nesting levels, it
>> only needs to know which layers are visible and in which order they should
>> be drawn. Aren't the groups mainly (only) there for organising the layers in
>> the legend?
>>
>> Just wondering.
>> Bernhard
>>
>> _______________________________________________
>> fusion-users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>
>
> __________________________________________
>
>   Paul Spencer
>   Chief Technology Officer
>   DM Solutions Group Inc
>   http://www.dmsolutions.ca/
>
> _______________________________________________
> fusion-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fusion-users
>
_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Bernhard Schneider

RE: More than two hierarchy levels in the legend (with MapServer)

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
RE: [fusion-users] More than two hierarchy levels in the legend (with MapServer)

With respect to MapServer not allowing for nested groups:
a) In the map file, you can add the GROUP key word to groups.
b) By adding some lines of code to MapServer.js, it is then possible to construct a legend with nested groups.
c) The maps are rendered correctly in my application, so it seems that Fusion sends correct information to the MapServer, and the MapServer deals with it the way it should.

With respect to the toggling of the visibity status of entire groups:
-- The out-of-the-box behaviour of Fusion is, IMHO, a bit odd: when I uncheck a group, all layers are unchecked, when I check the group again, all (!) layers in the group are checked. I'd expect the layers to remain unchanged, the status of the groups should simply override the status of the layers, not change it.
-- The behaviour is as expected with nested groups: If I uncheck a group, all nested groups keep their status. The map is still rendered correctly, that is, the nested groups and all the layers contained are not drawn (even though the attribute 'visible' is 'true' for some nested groups and layers).

Bernhard



-----Original Message-----
From: [hidden email] on behalf of Paul Deschamps
Sent: Tue 6/10/2008 5:52 PM
To: Paul Spencer
Cc: Bernhard Schneider; [hidden email]
Subject: Re: [fusion-users] More than two hierarchy levels in the legend (with MapServer)

One other thing unmentioned here is that layer "grouping" allows you
to toggle the visibility status of an entire group through the legend
widget.

Cheers

Paul D.


On Tue, Jun 10, 2008 at 10:36 AM, Paul Spencer <[hidden email]> wrote:
> Bernhard,
>
> This restriction comes from the fact that MapServer itself only supports one
> level of grouping via the GROUP keyword in a LAYER object.  The map
> rendering does not specifically use groups, it uses the layers themselves in
> the order they are present in the map file (layer at the top is drawn first,
> subsequent layers are drawn over it - painters algorithm).  Groups are only
> for organising layers in the legend.
>
> Cheers
>
> Paul
>
> On 10-Jun-08, at 8:54 AM, Bernhard Schneider wrote:
>
>> Hello everyone,
>>
>> Digging a bit further, I realised that the code in LoadMap.php
>> (fusion/MapServer/php/) is responsible for restricting the nesting depth to
>> 2. It retrieves the information from MapScript which itself read it from the
>> map file. There is the comment "parent is always not set for mapserver since
>> we can't have nested groups" in the code.
>>
>> Is it the MapServer (MapScript) that imposes the limitation? I wonder
>> whether it isn't just a matter of interpreting the map file from a "client
>> side". The map rendering engine should not worry about nesting levels, it
>> only needs to know which layers are visible and in which order they should
>> be drawn. Aren't the groups mainly (only) there for organising the layers in
>> the legend?
>>
>> Just wondering.
>> Bernhard
>>
>> _______________________________________________
>> fusion-users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>
>
> __________________________________________
>
>   Paul Spencer
>   Chief Technology Officer
>   DM Solutions Group Inc
>   http://www.dmsolutions.ca/
>
> _______________________________________________
> fusion-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fusion-users
>


_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Deschamps

Re: More than two hierarchy levels in the legend (with MapServer)

Reply Threaded More More options
Print post
Permalink
I have noticed this as well can you please log a ticket Bernhard.

Cheers

Paul D.

On Thu, Jun 12, 2008 at 2:10 AM, Bernhard Schneider
<[hidden email]> wrote:

> With respect to MapServer not allowing for nested groups:
> a) In the map file, you can add the GROUP key word to groups.
> b) By adding some lines of code to MapServer.js, it is then possible to
> construct a legend with nested groups.
> c) The maps are rendered correctly in my application, so it seems that
> Fusion sends correct information to the MapServer, and the MapServer deals
> with it the way it should.
>
> With respect to the toggling of the visibity status of entire groups:
> -- The out-of-the-box behaviour of Fusion is, IMHO, a bit odd: when I
> uncheck a group, all layers are unchecked, when I check the group again, all
> (!) layers in the group are checked. I'd expect the layers to remain
> unchanged, the status of the groups should simply override the status of the
> layers, not change it.
> -- The behaviour is as expected with nested groups: If I uncheck a group,
> all nested groups keep their status. The map is still rendered correctly,
> that is, the nested groups and all the layers contained are not drawn (even
> though the attribute 'visible' is 'true' for some nested groups and layers).
>
> Bernhard
>
>
>
> -----Original Message-----
> From: [hidden email] on behalf of Paul Deschamps
> Sent: Tue 6/10/2008 5:52 PM
> To: Paul Spencer
> Cc: Bernhard Schneider; [hidden email]
> Subject: Re: [fusion-users] More than two hierarchy levels in the legend
> (with MapServer)
>
> One other thing unmentioned here is that layer "grouping" allows you
> to toggle the visibility status of an entire group through the legend
> widget.
>
> Cheers
>
> Paul D.
>
>
> On Tue, Jun 10, 2008 at 10:36 AM, Paul Spencer <[hidden email]>
> wrote:
>> Bernhard,
>>
>> This restriction comes from the fact that MapServer itself only supports
>> one
>> level of grouping via the GROUP keyword in a LAYER object.  The map
>> rendering does not specifically use groups, it uses the layers themselves
>> in
>> the order they are present in the map file (layer at the top is drawn
>> first,
>> subsequent layers are drawn over it - painters algorithm).  Groups are
>> only
>> for organising layers in the legend.
>>
>> Cheers
>>
>> Paul
>>
>> On 10-Jun-08, at 8:54 AM, Bernhard Schneider wrote:
>>
>>> Hello everyone,
>>>
>>> Digging a bit further, I realised that the code in LoadMap.php
>>> (fusion/MapServer/php/) is responsible for restricting the nesting depth
>>> to
>>> 2. It retrieves the information from MapScript which itself read it from
>>> the
>>> map file. There is the comment "parent is always not set for mapserver
>>> since
>>> we can't have nested groups" in the code.
>>>
>>> Is it the MapServer (MapScript) that imposes the limitation? I wonder
>>> whether it isn't just a matter of interpreting the map file from a
>>> "client
>>> side". The map rendering engine should not worry about nesting levels, it
>>> only needs to know which layers are visible and in which order they
>>> should
>>> be drawn. Aren't the groups mainly (only) there for organising the layers
>>> in
>>> the legend?
>>>
>>> Just wondering.
>>> Bernhard
>>>
>>> _______________________________________________
>>> fusion-users mailing list
>>> [hidden email]
>>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>>
>>
>> __________________________________________
>>
>>   Paul Spencer
>>   Chief Technology Officer
>>   DM Solutions Group Inc
>>   http://www.dmsolutions.ca/
>>
>> _______________________________________________
>> fusion-users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/fusion-users
>>
>
>
_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users