MENUS MANAGEMENT


In this tutorial we are going to explain how OWGIS manages the menus displayed in the Main Layers dropdowns and the menus displayed by the Optional Layers window.

Menus are defined in xml files stored at OWGIS_PATH/web/layers. They use the tag Menus to encompass all the menus and the element Menu to define new menus. The element Menu only has two required attributes ID (id of the menu) and EN (English text of the menu). The next code shows an example of how to define a new menu.

<MenuConf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
        <Menus>
            <Menu ID="id1" EN="Hello world!" />
        </Menus>
</MenuConf>

Multiple languages

OWGIS allows multiple languages to be defined on the menus. The user can add a new language by simply defining a two character string that correspond to the Browser language. The next example contains a menu with texts in English and Spanish.

This website contains a list of the two character strings used to identify a language in a browser, which can be used to add a new language string in OWGIS.

...
    <Menu ID="id1" EN="Hello world!" ES="Buenos dias mundo!" />...

Menus and Main Layers

The Main layers are related with the menus by using the attribute Menu. This attribute receives a list of menu id's separated by colon. OWGIS will create a three of 'menus' that correspond to layers and it will build the corresponding interface for the user. In order to understand better how does the menu management work lets show an example. If we define the following four menus:

...
    <Menu ID="id1" EN="Menu 1" ES="Menu ES 1" />
    <Menu ID="id2" EN="Menu 2" ES="Menu ES 2" />
    <Menu ID="id3" EN="Menu 3" ES="Menu ES 3" />
    <Menu ID="id4" EN="Menu 4" ES="Menu ES 4" />...

We can use them to relate different layers.

Example 1.

Example 1 can be tested here  or downloaded the XML from here or downloaded the WAR file from here .

Use all the menus to access just one layer.

...
    <layer Menu='id1,id2,id3,id4' name='layer1' ... />...

This example will build the following tree and dropdown menu:

     

Example 2

Example 2 can be tested here  or downloaded the XML from here or downloaded the WAR file from here

In this example we use the created menus to access two different layers.

...
    <layer Menu='id1,id3,id4' name='layer1' ... />
    <layer Menu='id1,id2' name='layer2' ... />...

OWGIS will build the following tree and dropdown menu for the configuration shown in example 2:

   

Example 3

Example 3 can be tested here  or downloaded the XML from here or downloaded the WAR file from here

One last example, here we use the menus to access three different layers.

...
    <layer Menu='id1,id4' name='layer1' ... />
    <layer Menu='id1,id2' name='layer2' ... />
    <layer Menu='id1,id3' name='layer3' ... />...

OWGIS will build the following tree for the configuration shown in example 3:

Menus and Optional Layers

I the same way that menus can be used to add Main Layers, they can be used to create Optional Layers. The prodedure is the same, we include a list of menus id's separated by colons on the Menu element of the layers. There should always be at least one optional layer. For the next examples we are using the following menus:

...
    <Menu ID="id1" EN="Menu 1" ES="Menu ES 1" />
    <Menu ID="id2" EN="Menu 2" ES="Menu ES 2" />
    <Menu ID="id3" EN="Menu 3" ES="Menu ES 3" />
    <Menu ID="id4" EN="Menu 4" ES="Menu ES 4" />
    <Menu ID="id5" EN="Menu 5" ES="Menu ES 5" />...

Example 4.

Example 4 can be tested here  or downloaded the XML from here or downloaded the WAR file from here

In this example the four previously defined menus are used to create 4 Main layers and 4 Optional layers.

...
    <MainLayers>
        <layer Menu='id1,id4' name='layer1' ... />
        <layer Menu='id1,id2' name='layer2' ... />
        <layer Menu='id1,id3' name='layer3' ... />
        <layer Menu='id2'     name='layer4' ... />
    </MainLayers>
    <OptionalLayers>
        <layer Menu='id1,id2' name='layer1 Opt' ... />
        <layer Menu='id1,id3' name='layer2 Opt' ... />
        <layer Menu='id3,id4' name='layer3 Opt' ... />
        <layer Menu='id5'     name='layer4 Opt' ... />
    </OptionalLayers>...


The trees genereated internally by OWGIS to relate menus and layers looks like this:

 

LAYERS MANAGEMENT


Now we are going to explain how OWGIS manages the Main Layers and the Optional Layers configuration.

Layers are defined in xml files stored at OWGIS_PATH/web/layers along with the menus. We can define two different types of layers: MainLayers and OptionalLayers. We can also define the BackgroundLayers, but we are most likely going to use the same for every project, the next code shows our default background layer. 

    <BackgroundLayers server="http://ncwms.coaps.fsu.edu/geoserver/wms">
    <layer name='comm:pyrResult512' featureInfo="comm:gebco" />
</BackgroundLayers>

MainLayers and OptionalLayers each use the tag with the same name. These elements most important attributes are Menu (id of the menu), server (where the layers are hosted) and name (name of the layer in the server). Both inherit their attributes to their children tags layer, meaning that if you specified a value for an attribute in the parent tag MainLayers you don't need to add that attribute to the layer child tag (in case you want it to be inherit but you can also define a different one).

Main Layers from ncWMS2

Example can be tested here  or downloaded the XML from here

We've seen how to relate the menus to the layers, but how can we configure a layer to look exactly like we want to. The next code shows an example of how to define a main layer hosted by a ncWMS2 server.

    <MainLayers format="image/gif" server="http://132.248.8.238:8080/ncWMS_2015/wms" ncWMStwo="true" > 
<layer Menu='id1,id4' name='adcir_pom/zeta' palette="adcirc" mincolor="-3" maxcolor="3" belowMinColor="transparent" aboveMaxColor="transparent" />
</MainLayers>

For OWGIS to be able to display a layer from ncWMS2 you only have to declare the attribute ncWMStwo as true. The attribute palette tells it what palette from ncWMS2 to use to draw the layer, while mincolor and maxcolor indicate the range for the palette. The attributes belowMinColor and aboveMaxColor are used so that any value thats not between the range appears as transparent or invisible. 

Layers with Streamlines 

Example can be tested here  or downloaded the XML from here

To display a layer with streamlines you only need to declare the attribute overlaystreamlines with the name of the data set and variable from the server. Here is an example code:

    <MainLayers format="image/gif" ncWMStwo="true" server="http://132.248.8.238:8080/ncWMS_2015/wms" > 
<layer Menu="Pom,Altura" name="wwiii_pom/hs" style="default-scalar" defParticleSpeed="0.03" overlaystreamlines="wwiii_pom/U:wwiii_pom/V" ... />
...

Along with the attribute overlaystreamlines you can set the speed of the particles using the attribute defParticleSpeed

There are many other attributes you can use to personalize the way OWGIS displays the layers, here is the list of all the attributes you can set for the tag MainLayers:

server Indicates the URL of the server from which the layer is going to be loaded.
name Indicates the name of the layer in the server usually goes by data set/variable name. This value is mandatory. An example name from ncWMS2: wwiii_pom/hs.
BBOX Indicates the geographic limits of the layers. Follows the format of: minLon, minLat, maxLon, maxLat, e.g. -180, 90, -90, 180.
localAddress To indicate if the server from which the layer is going to be loaded is local. Use a local address like localhost or 127.0.0.1.
zoom To indicate in what zoom value the layer is going to load at first. The value must be a number that is less or equal to the zoomLevels set in general map options. 
center To indicate the center of the map where the layer is going to load at first. This value is in the  form: Lon,Lat.
vectorLayer Indicates whether the layer is or is not a vector layer. The possible values are true and false.
format The format of the images to be returned by the server. E.g. image/gif.
proj Is the projection of the layer commonly EPSG:4326.
trans_effect Define the transition effect used by OpenLayers when zoom is used. Currently it can be none or resize (default).
width Number of columns that this layer has. This property is very important because affects the way WCS request the layers. It is also used to define the resolution of the animation for ncwms layers. It is not used to request normal maps, for this case the size of the browser window is used and required.
height Number of rows that this layer has. This property is very important becaouse affects the way WCS request the layers.It is also used to define the resolution of the animation for ncwms layers. It is not used to request normal maps, for this case the size of the browser window is used and required.
mincolor This is the minimum of the range used to plot the data, it must be a number.
maxcolor Indicates the maxium of the range used to plot the data, it must be a number. 
palette The name of the color palette, which is located on the previously defined server, with which the layer will be loaded at startup.
tiled To indicate if the way to load the layer is by tiles or not. The possible values are true and false.
aboveMaxColor Indicates the color to be used to draw all the values above the range defined in the layer. Only works for ncWMS2.
belowMinColor  Indicates the color to be used to draw all the values below the range defined in the layer. Only works for ncWMS2.
ncWMS It is used to indicate whether the layer comes from an ncWMS version 1 server. Possible values are true and false.
ncWMStwo It is used to indicate whether the layer comes from an ncWMS version 2 server. Possible values are true and false.
style The name of the style with which the layer that is on the previously defined server will be loaded.
max_time_range The possible values are week, month, by month and year
Menu The list of menu id's separated by colon which indicates the position of the layer in the menu.
featureInfo Indicates where to extract the information to show when you click in a point in the layer. The value is the name of the layer in the server usually goes by data set/variable name.
CQL  
cqlqols  
jsonp Possible values are true and false.
Overlaystreamlines Indicates the layer from which to draw the streamlines. The value is the name of the layer in the server usually goes by data set/variable name.
defParticleSpeed The speed of the particles, only works if the attribute overlaystreamlines is defined. Usually a number much smaller than 1.

Optional Layers

These are the layers that provide information to support main layers. At least one optional layer must always be defined. This type of layer can be declared to load as default along the main layer using the attribute selected as following:

    <OptionalLayers BBOX="-180,90,-90,180" server="http://132.248.8.238:8080/geoserver/wms" vectorLayer="true"> 
      <layer Menu="lev1,states" name="demo:us_states" EN="US States" selected="true" />
    </OptionalLayers>

Here is the list of all the attributes you can set for the tag OptionalLayers:

server Indicates the URL of the server from which the layer is going to be loaded.
format The format of the images to be returned by the server. E.g. image/gif.
palette The name of the color palette, which is located on the previously defined server, with which the layer will be loaded at startup.
vectorLayer Indicates whether the layer is or is not a vector layer. The possible values are true and false.
width Number of columns that this layer has. This property is very important because affects the way WCS request the layers. It is also used to define the resolution of the animation for ncwms layers. It is not used to request normal maps, for this case the size of the browser window is used and required.
height Number of rows that this layer has. This property is very important becaouse affects the way WCS request the layers.It is also used to define the resolution of the animation for ncwms layers. It is not used to request normal maps, for this case the size of the browser window is used and required.
trans_effect Define the transition effect used by OpenLayers when zoom is used. Currently it can be none or resize (default).
mincolor This is the minimum of the range used to plot the data, it must be a number.
maxcolor The maxium of the range used to plot the data. It must be a number.
tiled Used to indicate if the way to load the layer is by tiles or not. The possible values are true and false.
ncWMS It is used to indicate whether the layer comes from an ncWMS version 1 server. Possible values are true and false.
ncWMStwo It is used to indicate whether the layer comes from an ncWMS version 2 server. Possible values are true and false.
style The name of the style with which the layer that is on the previously defined server will be loaded.
selected Indicates if the layer is selected by default when first loaded the map or not. Values are either true or false.
name Indicates the name of the layer in the server usually goes by data set/variable name. This value is mandatory. An example name from ncWMS2: wwiii_pom/hs.
Menu The list of menu id's separated by colon.
featureInfo Indicates where to extract the information to show when you click in a point in the layer. The value is the name of the layer in the server usually goes by data set/variable name.
jsonp Possible values are true and false.

GitHub

GitHub of Olmo Zavala

GO

Collaborators

Collaborators in this project

GO

Sponsors

Our Sponsors

GO