deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.portal.context
Class DefaultMapModelAccess

java.lang.Object
  extended by org.deegree.portal.context.DefaultMapModelAccess
All Implemented Interfaces:
MapModelAccess

public class DefaultMapModelAccess
extends Object
implements MapModelAccess

Version:
$Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
Author:
Andreas Poth, last edited by: $Author: mschneider $

Field Summary
 
Fields inherited from interface org.deegree.portal.context.MapModelAccess
PAN_EAST, PAN_NORTH, PAN_NORTHEAST, PAN_NORTHWEST, PAN_SOUTH, PAN_SOUTHEAST, PAN_SOUTHWEST, PAN_WEST
 
Constructor Summary
DefaultMapModelAccess(ViewContext vc)
           
 
Method Summary
 ViewContext addCRSToLayer(String name, URL owsAddress, String type, String crsName)
          Adds a CRS to a layer if a ViewContext.
 ViewContext addFormatToLayer(String name, URL owsAddress, String type, String mimeType)
          adds a new image format to a layer of a ViewContext.
 ViewContext addLayer(int index, Layer layer)
          adds a layer to the defined index position of the layer list of a ViewContext.
 ViewContext addLayer(int index, QualifiedName name, URL owsAddress, String type)
          adds a layer provided by the passed OWS to the defined index position of the layer list of a ViewContext.
 ViewContext addLayer(Layer layer)
          adds a layer to the end of the layer list of a ViewContext.
 ViewContext addLayer(QualifiedName name, URL owsAddress, String type)
          adds a layer provided by the passed OWS to the end of the layer list of a ViewContext.
 ViewContext addLayers(Layer[] layers)
          adds a number of layers to the end of the layer list of a ViewContext.
 ViewContext addLayers(QualifiedName[] names, URL[] owsAddresses, String type)
          adds a number of layers provided by the passed OWS to the end of the layer list of a ViewContext.
 ViewContext addStyleToLayer(QualifiedName name, URL owsAddress, String type, String styleName)
          adds a named style to a layer to be available within a context.
 ViewContext assignSLDToLayer(QualifiedName name, URL owsAddress, String type, StyledLayerDescriptor sld)
          assignes a SLD document instead of a style to a layer.
 ViewContext destroyGroup(String groupName)
          destroys a group.
 ViewContext groupLayers(int first, int last, String groupName, String parentGroupName)
          the difference to
 ViewContext groupLayers(String[] layers, URL[] owsAddresses, String[] types, String groupName, String parentGroupName)
          groups a set of layers identified by their names, the address of the OWS that provides it und its type.
 ViewContext pan(double directionDegree, double factor)
          moves a map view to a free definable direction with a given factor
 ViewContext pan(int direction, double factor)
          moves the boundingbox of the map to a well known direction.
 ViewContext recenterMap(Point point)
          centers he map described by a ViewContext to the passed point.
 ViewContext recenterMap(Point point)
          centers he map described by a ViewContext to the passed point.
 ViewContext removeCRSFromLayer(String name, URL owsAddress, String type, String crsName)
          removes a CRS from the list of availabe CRS of a layer.
 ViewContext removeFormatFromLayer(String name, URL owsAddress, String type, String mimeType)
          removes a format from a layer in a ViewContext.
 ViewContext removeLayer(QualifiedName name, URL owsAddress, String type)
          removes a named layer served by the passsed OWS from a ViewContext. if a layer with this name does not exist in a context, the unchanged ViewContext will be returned
 ViewContext removeStyleFromLayer(QualifiedName name, URL owsAddress, String type, String styleName)
          removes a style from the layer defined in a ViewContext.
 ViewContext setCurrentMapFormat(String mimeType, URL owsAddress, String type)
          sets the current image format a map shall be rendered.
 ViewContext setLayerActiveStyle(QualifiedName name, URL owsAddress, String type, String styleName)
          sets the active style (style to be used for rendering) of a layer
 ViewContext setLayers(Layer[] layers)
          sets the layers to a ViewContext.
 ViewContext setLayers(QualifiedName[] names, URL[] owsAddresses, String type)
          sets the layers provided by the passed OWS to a ViewContext.
 ViewContext setLayersVisible(String name, URL owsAddress, String type, boolean visible)
          set a layer to be visible or invisible
 ViewContext setMapBoundingBox(Envelope boundingBox)
          sets the bounding box a map/VieContext
 ViewContext setMapCRS(String crs)
          sets the CRS to be used by the map created from a ViewContext.
 ViewContext setMapSize(int width, int height)
          sets the width and height of a map described by a ViewContext
 ViewContext swapGroups(QualifiedName name, boolean up)
          swaps to groups in their order
 ViewContext swapLayers(QualifiedName name, URL owsAddress, String type, boolean up)
          swaps two layers in their order.
 ViewContext zoom(Point point, double factor)
          zoom in or out of the map described by a ViewContext and recenters it to the passed point.
 ViewContext zoom(Point point, double factor)
          zoom in or out of the map described by a ViewContext and recenters it to the passed point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMapModelAccess

public DefaultMapModelAccess(ViewContext vc)
Parameters:
vc -
Method Detail

addCRSToLayer

public ViewContext addCRSToLayer(String name,
                                 URL owsAddress,
                                 String type,
                                 String crsName)
                          throws PortalException
Description copied from interface: MapModelAccess
Adds a CRS to a layer if a ViewContext.

Specified by:
addCRSToLayer in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS that serves this layer
type - OWS type (WCS, WMS or WFS)
crsName - name of the CRS to be added (e.g. EPSG:4326)
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer is not known by a ViewContext or the CRS is not supported for this layer/OWS

addFormatToLayer

public ViewContext addFormatToLayer(String name,
                                    URL owsAddress,
                                    String type,
                                    String mimeType)
                             throws PortalException
Description copied from interface: MapModelAccess
adds a new image format to a layer of a ViewContext. This method is useful because not every image format e.g.a WMS offers must be registered to be available through a Web Map Context.

Specified by:
addFormatToLayer in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS
type - OWS type (WCS, WMS or WFS)
mimeType - new format to add to the layer
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the passed mimeType is not suported by the passed OWS

addLayer

public ViewContext addLayer(QualifiedName name,
                            URL owsAddress,
                            String type)
                     throws PortalException
Description copied from interface: MapModelAccess
adds a layer provided by the passed OWS to the end of the layer list of a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
addLayer in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS that serves the layer
type - OWS type (WCS, WMS or WFS)
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer already is registered to a ViewContext or the OWS does not serves a layer with this name.

addLayer

public ViewContext addLayer(int index,
                            QualifiedName name,
                            URL owsAddress,
                            String type)
                     throws PortalException
Description copied from interface: MapModelAccess
adds a layer provided by the passed OWS to the defined index position of the layer list of a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
addLayer in interface MapModelAccess
Parameters:
index - index position where to insert the layer
name - name of the layer
owsAddress - address of the OWS that serves the layer
type - OWS type (WCS, WMS or WFS)
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer already is registered to a ViewContext or the OWS does not serves a layer with this name or the index is < 0 or > the number of layers -1;

addLayer

public ViewContext addLayer(int index,
                            Layer layer)
                     throws PortalException
Description copied from interface: MapModelAccess
adds a layer to the defined index position of the layer list of a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
addLayer in interface MapModelAccess
Parameters:
index - index position where to insert the layer
layer - layer to add
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer already is registered to a ViewContext or the index is < 0 or > the number of layers -1;

addLayer

public ViewContext addLayer(Layer layer)
                     throws PortalException
Description copied from interface: MapModelAccess
adds a layer to the end of the layer list of a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
addLayer in interface MapModelAccess
Parameters:
layer - layer to add
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer already is registered to a ViewContext.

addLayers

public ViewContext addLayers(QualifiedName[] names,
                             URL[] owsAddresses,
                             String type)
                      throws PortalException
Description copied from interface: MapModelAccess
adds a number of layers provided by the passed OWS to the end of the layer list of a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
addLayers in interface MapModelAccess
Parameters:
names - names of the layer
owsAddresses - addresses of the OWS's that serves the layer
type - OWS type (WCS, WMS or WFS)
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if of the layers already is registered to a ViewContext or the OWS does not serves one the layers or the OWS does not serves one the layers or names and owsAddresses are not of the same size.

addLayers

public ViewContext addLayers(Layer[] layers)
                      throws PortalException
Description copied from interface: MapModelAccess
adds a number of layers to the end of the layer list of a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
addLayers in interface MapModelAccess
Parameters:
layers - layers to add
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if of the layers already is registered to a ViewContext.

addStyleToLayer

public ViewContext addStyleToLayer(QualifiedName name,
                                   URL owsAddress,
                                   String type,
                                   String styleName)
                            throws PortalException
Description copied from interface: MapModelAccess
adds a named style to a layer to be available within a context.

Specified by:
addStyleToLayer in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS that serves this layer
type - OWS type (WCS, WMS or WFS)
styleName - name of the style to be set
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer is not known by a ViewContext or the style is not available for this layer

assignSLDToLayer

public ViewContext assignSLDToLayer(QualifiedName name,
                                    URL owsAddress,
                                    String type,
                                    StyledLayerDescriptor sld)
                             throws PortalException
Description copied from interface: MapModelAccess
assignes a SLD document instead of a style to a layer. Usually this should be a SLD containing one named layer or one user layer and one user style. But it also will be possible to have a SLD with several layers (named layers as well as user layers). But this may cause some irritations so it should be avoided.

Specified by:
assignSLDToLayer in interface MapModelAccess
Parameters:
name - name of the layer the SLD should be assigned to
owsAddress - address of the OWS that serves this layer(s) if the SLD contains named layer(s). Otherwise the parameter can be null
type - OWS type (WCS, WMS or WFS)
sld - SLD that shall be assigned
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer is not known by a ViewContext or if the SLD contains a named layer but owsAddress is passed.

destroyGroup

public ViewContext destroyGroup(String groupName)
Description copied from interface: MapModelAccess
destroys a group. If a group with the passed name does not exist a ViewContext will be returned unchanged

Specified by:
destroyGroup in interface MapModelAccess
Parameters:
groupName - name of the group to be removed
Returns:
modified ViewContext

groupLayers

public ViewContext groupLayers(int first,
                               int last,
                               String groupName,
                               String parentGroupName)
                        throws PortalException
Description copied from interface: MapModelAccess
the difference to

Specified by:
groupLayers in interface MapModelAccess
Parameters:
first - zero based index of the first layer to add to the group
last - zero based index of the last layer to add to the group
groupName - unique name of the group
parentGroupName - name of the parent group. may be null
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if first or last is < 0 or larger than the total number of layers -1 or a layer is already member of a group
See Also:
is that the layers are identified by theri index position in a ViewContext

groupLayers

public ViewContext groupLayers(String[] layers,
                               URL[] owsAddresses,
                               String[] types,
                               String groupName,
                               String parentGroupName)
                        throws PortalException
Description copied from interface: MapModelAccess
groups a set of layers identified by their names, the address of the OWS that provides it und its type. A group has a name that must be unique and a parent that may is null. If no parent is given the group will be located underneath the root node.

Specified by:
groupLayers in interface MapModelAccess
Parameters:
layers - layers to be grouped.
groupName - unique name of the group
parentGroupName - name of the parent group. may be null
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if one of the layers is not served by the assigned OWS or a layer is already member of a group

pan

public ViewContext pan(double directionDegree,
                       double factor)
                throws PortalException
Description copied from interface: MapModelAccess
moves a map view to a free definable direction with a given factor

Specified by:
pan in interface MapModelAccess
Parameters:
directionDegree - direction measured in degree that map view shall be moved to
factor - factor measured in % the map view shall be moved
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if factor is <= 0

pan

public ViewContext pan(int direction,
                       double factor)
                throws PortalException,
                       ContextException
moves the boundingbox of the map to a well known direction. Directions that are known:

Specified by:
pan in interface MapModelAccess
Parameters:
direction - direction the map view shall be moved to
factor - factor measured in % the map view shall be moved
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if passed direction is not valid or factor is <= 0
ContextException
See Also:
MapModelAccess.PAN_NORTH, MapModelAccess.PAN_NORTHEAST, MapModelAccess.PAN_NORTHWEST, MapModelAccess.PAN_SOUTH, MapModelAccess.PAN_SOUTHEAST, MapModelAccess.PAN_SOUTHWEST, MapModelAccess.PAN_WEST, MapModelAccess.PAN_EAST

recenterMap

public ViewContext recenterMap(Point point)
                        throws ContextException
centers he map described by a ViewContext to the passed point. The behavior of this method is the same as

Specified by:
recenterMap in interface MapModelAccess
Parameters:
point - point (pixel coordinates) of the current map that marks the new center of the map
Returns:
modified ViewContext
Throws:
ContextException
See Also:
with a passed factor == 0;

recenterMap

public ViewContext recenterMap(Point point)
                        throws ContextException
centers he map described by a ViewContext to the passed point. The behavior of this method is the same as

Specified by:
recenterMap in interface MapModelAccess
Parameters:
point - point (map coordinates) of the current map that marks the new center of the map
Returns:
modified ViewContext
Throws:
ContextException
See Also:
with a passed factor == 0;

removeCRSFromLayer

public ViewContext removeCRSFromLayer(String name,
                                      URL owsAddress,
                                      String type,
                                      String crsName)
Description copied from interface: MapModelAccess
removes a CRS from the list of availabe CRS of a layer. If the layer or the CRS does not exist in a ViewContext the ViewContext will be returned unchanged.

Specified by:
removeCRSFromLayer in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS that serves this layer
type - OWS type (WCS, WMS or WFS)
crsName - name of the CRS to be removed from a layers CRS list
Returns:
modified ViewContext

removeFormatFromLayer

public ViewContext removeFormatFromLayer(String name,
                                         URL owsAddress,
                                         String type,
                                         String mimeType)
                                  throws PortalException
Description copied from interface: MapModelAccess
removes a format from a layer in a ViewContext.

Specified by:
removeFormatFromLayer in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS
type - OWS type (WCS, WMS or WFS)
mimeType - format to be removed
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the removed format is the current format of the layer.
See Also:
MapModelAccess.addFormatToLayer(String, URL, String, String)

removeLayer

public ViewContext removeLayer(QualifiedName name,
                               URL owsAddress,
                               String type)
Description copied from interface: MapModelAccess
removes a named layer served by the passsed OWS from a ViewContext. if a layer with this name does not exist in a context, the unchanged ViewContext will be returned

Specified by:
removeLayer in interface MapModelAccess
Parameters:
name - name of the layer to be removed
owsAddress - address of the OWS that serves the layer
type - OWS type (WCS, WMS or WFS)
Returns:
modified ViewContext

removeStyleFromLayer

public ViewContext removeStyleFromLayer(QualifiedName name,
                                        URL owsAddress,
                                        String type,
                                        String styleName)
Description copied from interface: MapModelAccess
removes a style from the layer defined in a ViewContext. If a style with passed named is not assigned to a layer the ViewContext will be returend unchanged.

Specified by:
removeStyleFromLayer in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS that serves this layer
type - OWS type (WCS, WMS or WFS)
styleName - name of the style to be removed
Returns:
modified ViewContext

setCurrentMapFormat

public ViewContext setCurrentMapFormat(String mimeType,
                                       URL owsAddress,
                                       String type)
                                throws PortalException
Description copied from interface: MapModelAccess
sets the current image format a map shall be rendered. In theory OGC WMC specification allows rendering of each layer in a different image format but this seems to be very complicated, slow and not very useful, so deegree just supports one format for each OWS.

Specified by:
setCurrentMapFormat in interface MapModelAccess
Parameters:
mimeType - image format
owsAddress - address of the OWS the format shall be used for
type - OWS type
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the passed mimeType is not suported by the passed OWS or one of its layers as defined in a ViewContext

setLayerActiveStyle

public ViewContext setLayerActiveStyle(QualifiedName name,
                                       URL owsAddress,
                                       String type,
                                       String styleName)
                                throws PortalException
Description copied from interface: MapModelAccess
sets the active style (style to be used for rendering) of a layer

Specified by:
setLayerActiveStyle in interface MapModelAccess
Parameters:
name - name of the layer a style shall be set to
owsAddress - address of the OWS that serves this layer
type - OWS type (WCS, WMS or WFS)
styleName - name of the style to be assigned
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer or style are not known by a ViewContext or the style is not available for this layer

setLayers

public ViewContext setLayers(QualifiedName[] names,
                             URL[] owsAddresses,
                             String type)
                      throws PortalException
Description copied from interface: MapModelAccess
sets the layers provided by the passed OWS to a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
setLayers in interface MapModelAccess
Parameters:
names - names of the layer
owsAddresses - addresses of the OWS that serves the layer. each passed layername is assigned to the OWS URL at the same index position.
type - OWS type (WCS, WMS or WFS)
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if of the layers already is registered to a ViewContext or the OWS does not serves one the layers or names and owsAddresses are not of the same size.

setLayers

public ViewContext setLayers(Layer[] layers)
                      throws PortalException
Description copied from interface: MapModelAccess
sets the layers to a ViewContext. A layer may be a WMS layer, a WFS feature type or a WCS coverage.

Specified by:
setLayers in interface MapModelAccess
Parameters:
layers - layers to add
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if of the layers already is registered to a ViewContext.

setLayersVisible

public ViewContext setLayersVisible(String name,
                                    URL owsAddress,
                                    String type,
                                    boolean visible)
                             throws PortalException
Description copied from interface: MapModelAccess
set a layer to be visible or invisible

Specified by:
setLayersVisible in interface MapModelAccess
Parameters:
name - name of the layer
owsAddress - address of the OWS that serves this layer
type - OWS type (WCS, WMS or WFS)
visible - true if a layer shall be visible; false if not.
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer is not known by a ViewContext.

setMapBoundingBox

public ViewContext setMapBoundingBox(Envelope boundingBox)
                              throws ContextException
sets the bounding box a map/VieContext

Specified by:
setMapBoundingBox in interface MapModelAccess
Parameters:
boundingBox - new boundingbox
Returns:
modified ViewContext
Throws:
ContextException

setMapCRS

public ViewContext setMapCRS(String crs)
                      throws PortalException
Description copied from interface: MapModelAccess
sets the CRS to be used by the map created from a ViewContext.

Specified by:
setMapCRS in interface MapModelAccess
Parameters:
crs - name of the CRS e.g. EPSG:4326
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the CRS is not known by all layers available through a ViewContext

setMapSize

public ViewContext setMapSize(int width,
                              int height)
                       throws PortalException
sets the width and height of a map described by a ViewContext

Specified by:
setMapSize in interface MapModelAccess
Parameters:
width - map width measured in pixel
height - map height measured in pixel
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if width or height < 1 (even a width or height of 1 pixel is not really useful but formal it is valid);

swapGroups

public ViewContext swapGroups(QualifiedName name,
                              boolean up)
                       throws PortalException
Description copied from interface: MapModelAccess
swaps to groups in their order

Specified by:
swapGroups in interface MapModelAccess
Parameters:
name - name of the group to be moved up or down
up - true if a group should be moved up otherwise it will be moved down.
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if a group with the passed name does not exist in a ViewContext
See Also:
MapModelAccess.swapLayers(QualifiedName, URL, String, boolean)

swapLayers

public ViewContext swapLayers(QualifiedName name,
                              URL owsAddress,
                              String type,
                              boolean up)
                       throws PortalException
swaps two layers in their order. The layer identified by the passed name and OWS can be moved up or down for one position. If a layer can not be moved up or down because it is already the top or bottom most layer the unchanged ViewContext will be returned

Notice: if to layers to be swaped are served by differend OWS at least one new image-layer must be created by the client.

Specified by:
swapLayers in interface MapModelAccess
Parameters:
name - name of the layer to be moved up or down in the list
owsAddress - address of the OWS that serves the layer
type - OWS type (WCS, WMS or WFS)
up - true if layer should be moved up otherwise it will be moved down.
Returns:
modified ViewContext
Throws:
PortalException - will be thrown if the layer does not exists in a ViewContext.

zoom

public ViewContext zoom(Point point,
                        double factor)
                 throws ContextException
zoom in or out of the map described by a ViewContext and recenters it to the passed point.
  • factor > 0: zoomout
  • factor < 0: zoomin
  • factor == 0: recenter

Specified by:
zoom in interface MapModelAccess
Parameters:
factor - zoom factor in % of the boundingbox size
point - point (pixel coordinates) of the current map that marks the new center of the map
Returns:
modified ViewContext
Throws:
ContextException

zoom

public ViewContext zoom(Point point,
                        double factor)
                 throws ContextException
zoom in or out of the map described by a ViewContext and recenters it to the passed point.
  • factor > 0: zoomout
  • factor < 0: zoomin
  • factor == 0: recenter

Specified by:
zoom in interface MapModelAccess
Parameters:
factor - zoom factor in % of the boundingbox size
point - point (map coordinates) of the current map that marks the new center of the map
Returns:
modified ViewContext
Throws:
ContextException

deegree 2.3 (2010/04/09 10:10 build-4-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org