After the users have been defined, we are ready to define applications. To define a MAJAS Application, you need to add a new directory under the /data/ggis/applications directory. The simplest way, is to make a copy of another directory that's already there. The name of this directory is also the name in the url-parameter that you use to access the application. (remember the /application.do?app=....). Inside this directory, there should be some .svg files (application.svg, overview.svg, legend.svg) and an application.xml. Let us first start with the .svg files. There is no need to adjust these, unless you want point-layers in your application. The features of a point layer are displayed using SVG symbols. These symbols are predefined, inside the SVG files. So if you want your own symbols, you have to add them to the list inside the SVG file.
Next there is the application.xml. This is the main configuration file for an application. In the programlisting beneath, you see a simple example of such an application configuration. We will now go over every one of the attributes, to explain their purpose and usage.
Application attributes:
url: The url attribute has 2 parameters. ref stand for the application's name/label. value refers to the url-parameter you give when accessing a MAJAS application (/application.do?app=.....). This also means that the value parameter should be equal to the name of the directory you created in /data/ggis/applications.
backgroundColor: determines the background color of the main SVG map. Needs a html color code.
lineSelectStyle: A CSS string that determines the general style when selecting a line feature.
pointSelectStyle: Reference to a predefined SVG symbol. Make sure this symbol exists, not only in the application.svg, but also in the legend.svg!
polygonSelectStyle: A CSS string that determines the general style of a selected polygon feature.
name: The full name of this application. Should be the same as the 'ref' parameter in the url attribute.
crs: The coordinate reference system for the application. Should be in EPSG format.
preferredWMSFormat: The preferred format for WMS layers, providing the WMS server supports it. Possible values are: 'image/jpeg', 'image/gif', 'image/png'.
layerFactory: Java class that is responsible for creating the layers of the application. In most cases you can simply use the default layer factory ("com.cadrie.majas.core.application.DefaultLayerFactory"), in domein specific cases, it can be usefull to create one's own implementation.
users: The full list of allowed users. These users should be known by Tomcat, and have certain roles. Don't forget to create at least one user-configuration for each user for this application (see previous chapter).
layers: The full list of layers for this application.
gridConfig: The grid configuration. For different scale levels, the map is divided into different squares according to a Morton Code system. This grid configuration defines these morton levels precisely.
Next are the layers. There are 2 types of layers: nodeLayers and leafyLayers. They form a tree-structure, with only the leafs as full-blown layers. The nodes are more for grouping purposes. We will now describe both:
NodeLayer:
layerName: The name of the layer group. (a node layer denotes a group of real layers)
defaultVisible: Should this layer be visible by default? For a nodelayer, it is advised to always set this to 'true'.
displayOrderMap: The display order on the map. Smaller numbers will be on top of bigger numbers. Best to make sure this value is unique over all layers.
displayerOrderTOC: The display order in the table of contents. Smaller numbers will be on top of bigger numbers. This value should be unique for each group of layers.
childLayers: A list of other layers. These can in turn be nodeLayers or LeafyLayers.
LeafyLayer:
layerName: The name of the layer.
defaultVisible: Should this layer be visible by default? True or false.
displayOrderMap: The display order on the map. Smaller numbers will be on top of bigger numbers. Best to make sure this value is unique over all layers.
displayerOrderTOC: The display order in the table of contents. Smaller numbers will be on top of bigger numbers. This value should be unique for each group of layers.
activatable: Is it allowed to activate this layers or not? True or false.
active: Is this layer active by default or not? Do mind that only one layer should be active at any time!
exportable: Is it allowed for users to export the features of this layer to XML or CSV? True or false.
urlProperty: This property can be used to make hyperlinks out of the labels for this layer. What you need to have is a property in your featuretype, that contains a url for each feature. If you fill in the name of the property here (case-sensitive), it will use the url in that property to create a hyperlink out of the label.
layerType: Determines what type of layer this is. Following values are possible:
rasterlayer or WMS.
point layer
line layer
polygon layer
viewScale: Determines the visibility of the layer. A layer can only be visible betwen the 2 scale values (min, max) given here.
showLabels: Should the labels be visible by default or not? True or false.
editableSupported: Is editing in this layer supported or not? True or false.
attribFeatureId: The name of the feature id attribute for the edit-table for this layer. Some extra info is needed here. The default workflow in MAJAS is so that edited features are stored seperatly from the original ones. And only when some edited feature has been accepted, will it be persisted to the real featuretype. In other words, if you want a layer to be editable, you need to use a database datastore (like postgres or oracle), so an extra table can be created (this happens automatically when using the upload scripts). In this extra table for edited features, there are 6 extra columns needed. This is one of them. But depending on the database used, the name may differ. For example, postgres changes all names for lower case, while oracle changes all names to upper case. In other words, if you use an oracle database the value should be "FEATURE_ID", and if you are using a postgres database, the value should be "feature_id". The value will be disregarded if it's not used, but it remains required!
attribVersion: Analogous to above; "VERSION" or "version".
attribEditDate: Analogous to above; "EDIT_DATE" or "edit_date".
attribUserId: Analogous to above; "USER_ID" or "user_id".
attribEditState: Analogous to above; "EDIT_STATE" or "edit_state".
attribFlowState: Analogous to above; "FLOW_STATE" or "flow_state".
featureType: The name of the feature type. This is the source of data for this layer. This name is case-sensitive.
crudValue: Server-side check for CRUD operations. CRUD stands for Create, Read, Update, Delete. Since reading is implicit, we left it out in determining the value for crud operations. What does this mean? Well if you want to enable the Creation of new objects you should user the value '1' here. If you also want Updating to be possible, you should add '2' to it. And if you also want Deleting to be possible, you should add '4' to this. For example, a layer where creating and deleting is possible, but not updating, you have 1+4=5.
snappingRules: A list of snapping rules for this layer. Some functions (i.e. editing) make use of snapping. Here it is possible to determine what points are snappable points for this layer.
identifyingAttributes: A list of attributes for this layer. The identifying attributes are a short list of attributes that can quickly tell you have feature we are talking about. For example, if you have a layer of countries. By seeing the name of a country alone, you know which one is displayed.
viewableAttributes: The full and detailed list of attributes for this layer. The identifying attributes can be handy to quickly identify or select a few features, but if you wish to now more, then there are these viewable attributes.
labelConfig: Configuration for labels. At this moment it only contains the labelAttributeName. This is the name of an attribute that is to be used as label. (attributes are always case-sensitive!)
styleDefs: Style definitions for this layer. It is possible to define multiple styles for one layer. In that case you should define filters to assign certain styles to certain features.
Identifying attributes. The order used here, will also be used in the front end. For example the tabel-tab at the bottom, uses the identifying attributes.
attributeLabel: The labels for an attribute. This labels is used in the front-end or in exports.
attributeName: The real name of an attribute as defined in it's featureType. This is case-sensitive!
Viewable attributes. Again the order in which you define them, is also used on te front-end. For example when editing the attributes of a feature.
attributeLabel: The labels for an attribute. This labels is used in the front-end or in exports.
attributeName: The real name of an attribute as defined in it's featureType. This is case-sensitive!
attributeValidator: A validation filter. When editing a feature, it will make sure that any edited attribute, always passes it's validation filter. If not, the editing will not be allowed. Note that this validator is not required, but it can come in handy.
Style definitions:
id: The style identifier. Should be a unique number for each layer. In case of a point-layer. Start with id=0! (this is a bug we should resolve asap)
name: The name of the style. This name is used in the legend.
svgStyle: The CSS style string to be used in the SVG.
formula: A possible filter. If you define multiple styles for one layer, it is required to use these filters to seperate the features. It is still possible to have one style without a filter formula, but define it as the last one. This because when features are looked up, they are tested against these filters. The first filter that contains this feature, determines the style for that feature. So if you first define a style without filter, every feature will use this style, no matter how many other styles are defined after that.
Grid configuration:
transformationFunction: The transformation function that transforms coordinates between the user space and the svg space. (in SVG the Y-axis points down). The example is correct for EPSG:31300 (Lambert72).
fullMapExtent: The full map extent for this application.
rasterZoomLevels: Determines the zoomlevels or Morton codes in the quadtree. This can influence the speed of the cache.
Example application.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<mc:application xmlns:mc="http://www.majas.org/schema/2006/configuration/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://www.w3.org/1999/xhtml"
xmlns:ns="http://www.majas.org/schema/2006/configuration/"
xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty"
xsi:schemaLocation="http://www.majas.org/schema/2006/configuration/ file://xsd/majas-application.xsd ">
<url ref="test-application" value="url-param" />
<backgroundColor value="#FFFFFF" />
<lineSelectStyle value="stroke:yellow; stroke-opacity: 0.5;" />
<pointSelectStyle value="#selectedPoint" />
<polygonSelectStyle value="color:yellow;fill:yellow;fill-opacity: 0.5;" />
<name value="test-application" />
<crs value="EPSG:31300" />
<preferredWMSFormat value="image/jpeg" />
<layerFactory value="com.cadrie.majas.core.application.DefaultLayerFactory" />
<users>
<user ref="guest" />
<user ref="anotheruser" />
</users>
<layers>
<layer id="1" xsi:type="mc:nodeLayerType">
<layerName value="Feature Layer Group" />
<defaultVisible value="true" />
<displayOrderMap value="1" />
<displayOrderTOC value="3" />
<childLayers>
<layer id="2" xsi:type="mc:leafyLayerType">
<layerName value="First-layer" />
<defaultVisible value="true" />
<displayOrderMap value="2" />
<displayOrderTOC value="1" />
<activatable value="true" />
<active value="false" />
<exportable value="true" />
<urlProperty value="url" />
<layerType value="4" />
<viewScale min="0.0001" max="1000" />
<showLabels value="false" />
<editableSupported value="true" />
<attribFeatureId value="feature_id" />
<attribVersion value="version" />
<attribEditDate value="edit_date" />
<attribUserId value="user_id" />
<attribEditState value="edit_state" />
<attribFlowState value="flow_state" />
<featureType value="postgis:tablename" />
<crudValue value="7" />
<snappingRules>
<snappingRule>
<snapDistance value="100" />
<snappingLayer value="First-layer" />
<snappingType value="1" />
</snappingRule>
</snappingRules>
<identifyingAttributes>
<identifyingAttribute>
<attributeLabel value="Identifier" />
<attributeName value="id"/>
</identifyingAttribute>
</identifyingAttributes>
<viewableAttributes>
<viewableAttribute>
<attributeLabel value="Identifier" />
<attributeName value="id"/>
<attributeValidator value="" />
</viewableAttribute>
<viewableAttribute>
<attributeLabel value="Name" />
<attributeName value="name"/>
<attributeValidator value="" />
</viewableAttribute>
</viewableAttributes>
<labelConfig>
<labelAttributeName value="name" />
</labelConfig>
<styleDefs>
<styleDef>
<id value="1" />
<name value="Some Style" />
<svgStyle value="stroke:#CC3311;stroke-width:0.2%;stroke-opacity:1;" />
<formula value="" />
</styleDef>
</styleDefs>
</layer>
</childLayers>
</layer>
</layers>
<gridConfig>
<transformationFunction value="tmp=configuration.fullMapExtent.upperRightCorner.y+configuration.fullMapExtent.lowerLeftCorner.y; newPoint = new Point(); newPoint.x = point.x; newPoint.y = tmp-point.y; return newPoint;" />
<fullMapExtent minX="20000" maxX="260000" minY="150000" maxY="245000" />
<rasterZoomLevels>
<rasterZoomLevel>
<minViewScale value="0.0001" />
<maxViewScale value="0.01" />
</rasterZoomLevel>
<rasterZoomLevel>
<minViewScale value="0.01" />
<maxViewScale value="0.03" />
</rasterZoomLevel>
<rasterZoomLevel>
<minViewScale value="0.03" />
<maxViewScale value="0.07" />
</rasterZoomLevel>
<rasterZoomLevel>
<minViewScale value="0.07" />
<maxViewScale value="0.1" />
</rasterZoomLevel>
<rasterZoomLevel>
<minViewScale value="0.1" />
<maxViewScale value="0.3" />
</rasterZoomLevel>
<rasterZoomLevel>
<minViewScale value="0.3" />
<maxViewScale value="0.5" />
</rasterZoomLevel>
<rasterZoomLevel>
<minViewScale value="0.5" />
<maxViewScale value="2" />
</rasterZoomLevel>
<rasterZoomLevel>
<minViewScale value="2" />
<maxViewScale value="1000" />
</rasterZoomLevel>
</rasterZoomLevels>
</gridConfig>
The structure of this configuration file is defined in the majas-application.xsd (see majas-application.xsd).