org.kaboum.util
Class KaboumMapServerTools

java.lang.Object
  extended by org.kaboum.util.KaboumMapServerTools

public class KaboumMapServerTools
extends java.lang.Object

Cette classe s'occupe de traduire les requètes de l'applet sous une forme compréhensible par mapserver.

Author:
Jérôme Gasperi aka jrom

Field Summary
 boolean displayInline
          If true display Inline Feature
 boolean displayItemQueryMap
          tells if applet is in ITEM_QUERYMAP mode.
 KaboumExtent extent
          Spatial extent of current map (i.e.
 java.util.Vector historyArray
          History array
 java.awt.Point img
          Image click point
static java.lang.String K_MODE_BROWSE
           
static java.lang.String K_MODE_ITEM_NQUERYMAP
           
static java.lang.String K_MODE_ITEM_QUERYMAP
           
static java.lang.String K_MODE_MAP
          Public constant
static java.lang.String K_MODE_NQUERY
           
static java.lang.String K_MODE_QUERY
           
static java.lang.String K_MODE_REFERENCE
           
static java.lang.String K_TYPE_IMAGE_JPEG
           
 java.lang.String layersList
          Layers (cf: mapserver)
 java.lang.String mapPath
          Chemin absolu du map file (cf: mapserver)
 java.lang.String mapserverURL
          Chemin relatif à mapserver (cf: mapserver)
 int maxWinSize
          Max Window Size (cf: EGIS add-on from terraSIP project)
 KaboumPrecisionModel pm
          Precision Model
 KaboumExtent previousExtent
          Spatial extent of previous map (i.e.
 java.lang.String queryLayersList
          Query layers (cf: mapserver)
 KaboumExtent realExtent
          Spatial adjusted extent of current map (i.e. real extent)
 KaboumExtent referenceExtent
          Spatial extent of reference map (i.e. initial extent)
 int scale
          Current scale
 
Constructor Summary
KaboumMapServerTools(java.lang.String _mapserverURL, java.lang.String _mapPath, int _historyMaxSize, KaboumPrecisionModel _pm, java.lang.String _layersList, java.lang.String _queryLayersList, KaboumExtent _restrictedExtent, int _maxScale, boolean _useCache, KaboumExtent _referenceExtent, java.awt.Dimension _screenSize, KaboumGGDIndex _GGDIndex)
          Constructeur
 
Method Summary
 void boxToMapExtent(double x1, double y1, double x2, double y2)
          Calculate map coordinate from a dragged box.
 void centerMapExtent(KaboumCoordinate internal)
          Calculate new extent center on a map coordinates
 double getDistance(KaboumCoordinate coordA, KaboumCoordinate coordB)
          Return the distance between two points
 KaboumExtent getExtent()
          Return the uncorrected spatial extent
 java.lang.String getItemQueryMapString()
          Return the item query map string
 java.lang.String getMapCoordString(int x, int y)
          Return the string equivalence of mouse position in either map coordinates and mouse coordinates
 java.lang.String getMapString()
          Return the mapserver URL string to draw the map
 KaboumExtent getPreviousExtent()
          Return the previous extent
 java.lang.String getPrintURL(int w, int h)
          Mapserver URL for printing
 java.lang.String getQueryString()
          Return the mapserver URL string to query a layer
 KaboumExtent getRealExtent()
          Return the current spatial extent
 java.lang.String getReferenceString()
          Return the reference map URL string
 int getScale()
          Return the current map scale.
 java.lang.String getUniqueMapString()
          Return a unique map String to mapserver by appending a time stamp to the last parameter
 KaboumExtent getValidExtent(KaboumExtent e)
          Return a valid extent depending on zoomOutRestriction status and maxScale restriction.
 void historyAddExtent(java.lang.String extent)
          Add a new extent in history array
 java.lang.String historyNextExtent()
          Return the next extent in history
 java.lang.String historyPrevExtent()
          Return the previous extent in history
 int internalToMouseX(double x)
          Cette méthode renvois la coordonnée x souris d'un point d'abscisse x dans le repère de la carte
 java.awt.Point internalToMouseXY(KaboumCoordinate internal)
          Return the Point(x,y) equivalence of an internal coordinate
 int internalToMouseY(double y)
          Cette méthode renvois la coordonnée y souris d'un point d'abscisse y dans le repère de la carte
 java.awt.Polygon internalToPolygon(KaboumCoordinate[] internals)
          Convert an array of internal coordinates into a java.awt.Polygon
 double mouseXToInternal(double x)
          Cette méthode renvois la coordonnée x carte d'un point d'abscisse x dans le repère de la zone d'affichage de la carte (haut pixel)
 KaboumCoordinate mouseXYToInternal(int x, int y)
          Return the internal coordinate corresponding to the mouse position
 double mouseYToInternal(double y)
          Cette méthode renvois la coordonnée y carte d'un point d'ordonnée y dans le repère de la zone d'affichage de la carte (haut pixel)
 void setAdjustedCoordinates()
          Compute the spatial extent containing the whole image
 void setExtent(KaboumExtent e)
          Set the current spatial extent
 void setImageQuality(int i)
          Set the image quality
 void setImageType(java.lang.String str)
          Set the image type
 void setInlineFeatureString(java.lang.String layer, java.lang.String points, java.lang.String text)
          Set the inline feature string
 void setItemQueryMapString(java.lang.String mode, java.lang.String layer, java.lang.String[] qitem, java.lang.String qstring, java.lang.String extraParams)
          Set the item query map string
 void setLayersList(java.lang.String str)
          Layers initialisation
 void setQueryLayersList(java.lang.String str)
          Query layers initialisation.
 double setScale(int scale)
          Set the map scale
 void zoomToMapExtent(double x1, double y1, double factor)
          Calculate map coordinates centered on a mouse click
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

K_MODE_MAP

public static final java.lang.String K_MODE_MAP
Public constant

See Also:
Constant Field Values

K_MODE_QUERY

public static final java.lang.String K_MODE_QUERY
See Also:
Constant Field Values

K_MODE_NQUERY

public static final java.lang.String K_MODE_NQUERY
See Also:
Constant Field Values

K_MODE_ITEM_QUERYMAP

public static final java.lang.String K_MODE_ITEM_QUERYMAP
See Also:
Constant Field Values

K_MODE_ITEM_NQUERYMAP

public static final java.lang.String K_MODE_ITEM_NQUERYMAP
See Also:
Constant Field Values

K_MODE_REFERENCE

public static final java.lang.String K_MODE_REFERENCE
See Also:
Constant Field Values

K_MODE_BROWSE

public static final java.lang.String K_MODE_BROWSE
See Also:
Constant Field Values

K_TYPE_IMAGE_JPEG

public static final java.lang.String K_TYPE_IMAGE_JPEG
See Also:
Constant Field Values

extent

public KaboumExtent extent
Spatial extent of current map (i.e. "mouse extent" or false extent)


realExtent

public KaboumExtent realExtent
Spatial adjusted extent of current map (i.e. real extent)


referenceExtent

public KaboumExtent referenceExtent
Spatial extent of reference map (i.e. initial extent)


previousExtent

public KaboumExtent previousExtent
Spatial extent of previous map (i.e. "undo" extent)


pm

public KaboumPrecisionModel pm
Precision Model


layersList

public java.lang.String layersList
Layers (cf: mapserver)


queryLayersList

public java.lang.String queryLayersList
Query layers (cf: mapserver)


mapPath

public java.lang.String mapPath
Chemin absolu du map file (cf: mapserver)


mapserverURL

public java.lang.String mapserverURL
Chemin relatif à mapserver (cf: mapserver)


img

public java.awt.Point img
Image click point


historyArray

public java.util.Vector historyArray
History array


scale

public int scale
Current scale


maxWinSize

public int maxWinSize
Max Window Size (cf: EGIS add-on from terraSIP project)


displayInline

public boolean displayInline
If true display Inline Feature


displayItemQueryMap

public boolean displayItemQueryMap
tells if applet is in ITEM_QUERYMAP mode. In this case, specific Mapserver URL will be maintained to display found features with their hilited color.
To do so, the mapserver URL will be modified to include itemquerymap parameters

See Also:
property
Constructor Detail

KaboumMapServerTools

public KaboumMapServerTools(java.lang.String _mapserverURL,
                            java.lang.String _mapPath,
                            int _historyMaxSize,
                            KaboumPrecisionModel _pm,
                            java.lang.String _layersList,
                            java.lang.String _queryLayersList,
                            KaboumExtent _restrictedExtent,
                            int _maxScale,
                            boolean _useCache,
                            KaboumExtent _referenceExtent,
                            java.awt.Dimension _screenSize,
                            KaboumGGDIndex _GGDIndex)
Constructeur

Parameters:
mapserverURL - MapServer cgi URL (ex: http:://132.149.92.10/cgi-bin/mapserver.cgi)
mapPath - Absolute path to the map file
historyMaxSize - Size of history array
precisionModel - Precision Model
layersList - Initial layers list
queryLayersList - Initial query layers
restrictedExtent - Set the maximum valid extent
maxScale - Maximum scale allow in zoom in
noCache - Images are cached by http server (FALSE) or no
referenceExtent - Initial map extent
screenSize - Size of the window applet
_GGDIndex - GGDIndex reference
Method Detail

mouseXYToInternal

public KaboumCoordinate mouseXYToInternal(int x,
                                          int y)
Return the internal coordinate corresponding to the mouse position

Parameters:
x - Mouse x position
y - Mouse y position

mouseXToInternal

public double mouseXToInternal(double x)
Cette méthode renvois la coordonnée x carte d'un point d'abscisse x dans le repère de la zone d'affichage de la carte (haut pixel)


mouseYToInternal

public double mouseYToInternal(double y)
Cette méthode renvois la coordonnée y carte d'un point d'ordonnée y dans le repère de la zone d'affichage de la carte (haut pixel)


internalToMouseX

public int internalToMouseX(double x)
Cette méthode renvois la coordonnée x souris d'un point d'abscisse x dans le repère de la carte


internalToMouseY

public int internalToMouseY(double y)
Cette méthode renvois la coordonnée y souris d'un point d'abscisse y dans le repère de la carte


internalToMouseXY

public java.awt.Point internalToMouseXY(KaboumCoordinate internal)
Return the Point(x,y) equivalence of an internal coordinate


internalToPolygon

public java.awt.Polygon internalToPolygon(KaboumCoordinate[] internals)
Convert an array of internal coordinates into a java.awt.Polygon


setImageType

public void setImageType(java.lang.String str)
Set the image type

Parameters:
imageType - Type of image

setImageQuality

public void setImageQuality(int i)
Set the image quality

Parameters:
imageType - Type of image

setExtent

public void setExtent(KaboumExtent e)
Set the current spatial extent

Parameters:
e - New extent

setLayersList

public void setLayersList(java.lang.String str)
Layers initialisation

Parameters:
str - Layers list. The layers list is a string in which each layer name is separated with a ","

setQueryLayersList

public void setQueryLayersList(java.lang.String str)
Query layers initialisation.

Parameters:
str - Query layer list. Query layers list is a string in which each layer name is separated with a ","

getRealExtent

public KaboumExtent getRealExtent()
Return the current spatial extent


getExtent

public KaboumExtent getExtent()
Return the uncorrected spatial extent


getPreviousExtent

public KaboumExtent getPreviousExtent()
Return the previous extent


getMapString

public java.lang.String getMapString()
Return the mapserver URL string to draw the map


getUniqueMapString

public java.lang.String getUniqueMapString()
Return a unique map String to mapserver by appending a time stamp to the last parameter


getItemQueryMapString

public java.lang.String getItemQueryMapString()
Return the item query map string


setInlineFeatureString

public void setInlineFeatureString(java.lang.String layer,
                                   java.lang.String points,
                                   java.lang.String text)
Set the inline feature string


setItemQueryMapString

public void setItemQueryMapString(java.lang.String mode,
                                  java.lang.String layer,
                                  java.lang.String[] qitem,
                                  java.lang.String qstring,
                                  java.lang.String extraParams)
Set the item query map string

Parameters:
mode: - the mapserver mode, either itemquerymap or itemnquerymap, according to the received kaboumCommand string
layer: - the name of the layer on which the attribute query is performed (currently, only one layer is supported.
qitem: - an array of items (=layer's attribute) on which the search is performed
extraParams: - a string containing extra mapserver parameters to pass for this query. theses parameters are treated as they are passed, without any processing.
this mechanism allows, for instance, to overload mapfile parameters.
qstring: - the mapserver query string, pertinent to the current layer (postgis, dbf, etc.
it is up to the user to generate a valid query string.

getQueryString

public java.lang.String getQueryString()
Return the mapserver URL string to query a layer


getReferenceString

public java.lang.String getReferenceString()
Return the reference map URL string


getPrintURL

public java.lang.String getPrintURL(int w,
                                    int h)
Mapserver URL for printing

Parameters:
w - Width of the new map to print
h - Height of the new map to print

getMapCoordString

public java.lang.String getMapCoordString(int x,
                                          int y)
Return the string equivalence of mouse position in either map coordinates and mouse coordinates

Parameters:
x - Coordonnées x du pointeur souris
y - Coordonnées y du pointeur souris

getDistance

public double getDistance(KaboumCoordinate coordA,
                          KaboumCoordinate coordB)
Return the distance between two points

Parameters:
coordA - Coordinate A (internal representation)
coordB - Coordinate B (internal representation)

getScale

public int getScale()
Return the current map scale. Inferred from msCalculateScale function in mapserver source code (cf: mapscale.c)


setScale

public double setScale(int scale)
Set the map scale


boxToMapExtent

public void boxToMapExtent(double x1,
                           double y1,
                           double x2,
                           double y2)
Calculate map coordinate from a dragged box. If zoomOutRestriction is set to true and the dragged box is outside the bounds, the new box is set into the bounds and freeze to the closest one.

Parameters:
x1 - ULX mouse coordinate
y1 - ULY mouse coordinate
x1 - LRX mouse coordinate
y2 - LRY mouse coordinate

zoomToMapExtent

public void zoomToMapExtent(double x1,
                            double y1,
                            double factor)
Calculate map coordinates centered on a mouse click

Parameters:
x1 - X mouse coordinate
y1 - Y mouse coordinate
factor - Zoom factor (Ex: 0.5 = zoom x-2; 1 = pan; 2 = zoom x2; etc...)

centerMapExtent

public void centerMapExtent(KaboumCoordinate internal)
Calculate new extent center on a map coordinates

Parameters:
internal - Internal coordinate

getValidExtent

public KaboumExtent getValidExtent(KaboumExtent e)
Return a valid extent depending on zoomOutRestriction status and maxScale restriction.

Parameters:
e - Extent

setAdjustedCoordinates

public void setAdjustedCoordinates()
Compute the spatial extent containing the whole image


historyAddExtent

public void historyAddExtent(java.lang.String extent)
Add a new extent in history array


historyPrevExtent

public java.lang.String historyPrevExtent()
Return the previous extent in history


historyNextExtent

public java.lang.String historyNextExtent()
Return the next extent in history



Copyright © 2005 Kaboum team. All Rights Reserved.