Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Map Class Reference

Inheritance diagram for Map:

Inheritance graph
List of all members.

Detailed Description

A wrapper around the base PHP MapScript mapObj.

This is designed to add methods that allow the mapObj to be serialised. This enables it to be used effectively in sessions.

It is used in exactly the same way as the base mapObject except that properties (member variables) must be accessed through the get($property_name) method.

Definition at line 60 of file map.php.

Public Member Functions

 Map ($map_file, $new_map_path=null)
 Constructs a Map.

 loadMapString ($map_string)
 Loads the map configuration from a string, replacing the current map object.

 getCObj ()
 Get the underlying MapScript mapObj resource.

 setCObj ($map)
 Replace the current mapscript mapObj resource.

get ($property_name)
 Return the value of the specified property of the mapscript mapObj resource.

 clone ()
 Returns a handle to a new mapObj which is a clone of the base mapObj.

 set ($property_name, $new_value)
 Set map object property to new value.

 getsymbolbyname ($symbol_name)
 Get the symbol index using the specified name.

 preparequery ()
 Calculate the scale of the map and assign it to the map->scale.

 prepareImage ()
 Return handle on blank image object.

 draw ()
 Render the map and return a handle on the image object.

 drawQuery ()
 Render a query map and return a handle on the image object.

 drawLegend ()
 Render the legend and return a handle on the image object.

 drawReferenceMap ()
 Render the reference map and return a handle on the image object.

 drawScaleBar ()
 Render the scale bar and return a handle on the image object.

 embedlegend ($image)
 Embeds a legend.

 embedScalebar ($image)
 Embeds a scalebar.

 drawLabelCache ($image)
 Renders the labels for a map.

 getLayer ($index)
 Returns a layerObj from the map given an index value.

 getLayerByName ($layer_name)
 Returns a layerObj from the map given a layer name.

 getcolorbyindex ($iCloIndex)
 Returns a colorObj corresponding to the colour index in the palette.

 setextent ($minx, $miny, $maxx, $maxy)
 Set the map extents from georeferenced values.

 zoompoint ($nZoomFactor, $oPixelPox, $nImageWidth, $nImageHeight, $oGeorefExt, $oMaxGeorefExt=null)
 Zoom to a given XY position.

 zoomrectangle ($oPixelExt, $nImageWidth, $nImageHeight, $oGeorefExt)
 Set the map extent to a given value.

 zoomscale ($nScale, $oPixelPos, $nImageWidth, $nImageHeight, $oGeorefExt, $oMaxGeorefExt=null)
 Zoom in or out to a given XY position so that the map is displayed at a specified scale.

 queryByPoint ($point, $mode, $buffer)
 Query all selected layers in map at specific point location.

 queryByRect ($rect)
 Query all selected layers in the map using a specified extent.

 queryByShape ($shape)
 Query all selected layers in the map based on a single shape.

 queryByFeatures ($slayer)
 Perform a query based on a previous set of results from a layer.

 queryByIndex ($layerindex, $tileindex, $shapeindex, $addtoquery=MS_FALSE)
 Add a specific shape on a given layer to the query result.

 savequery ($filename)
 Save the current query in a file.

 loadquery ($filename)
 Loads a query from a file.

 freequery ($layerindex)
 Frees the query result on a layer.

 save ($filename)
 Save current map object state to a file.

 getProjection ()
 Returns a string representation of the projection.

 setProjection ($proj_params, $bSetUnitsAndExtents=MS_FALSE)
 Set map projection and coordinate system.

 setWKTProjection ($proj_params, $bSetUnitsAndExtents=MS_FALSE)
 Set map projection and coordinate system.

 getMetaData ($name)
 Fetch metadata entry by name.

 setMetaData ($name, $value)
 Set a metadata entry for the map.

 removeMetaData ($name)
 Remove a metadata entry for the map.

 getLayersIndexByGroup ($groupname)
 Return an array containing layer indices for all layers belonging to a specified group.

 getAllGroupNames ()
 Return an array containing all group names used in the map.

 getAllLayerNames ()
 Return an array containing all layer names.

 moveLayerUp ($layerindex)
 Move a layer up in the drawing hierarchy.

 moveLayerDown ($layerindex)
 Move a layer down the drawing hierarchy.

 getlayersdrawingorder ()
 Return an array containing layer indices in the order in which they are drawn.

 setlayersdrawingorder ($layeryindex)
 Set the order in which layers are drawn.

 processtemplate ($params, $generateimages=MS_TRUE)
 Process the template file specified in the web object and return the result.

 processquerytemplate ($params, $generateimages=MS_TRUE)
 Process the query template file and return the result.

 processlegendtemplate ($params)
 Process the legend template file and return the result.

 setSymbolSet ($fileName)
 Load and set a symbol file dynamically.

 getNumSymbols ()
 Return the number of symbols in the map.

 setFontSet ($fileName)
 Load and set a new fontset.

 selectOutputFormat ($type)
 Selects the output format to be used in the map.

 saveMapContext ($filename)
 Save the current map object state in WMS Map Context format to a file.

 loadMapContext ($filename)
 Load a WMS Map context XML file into the current mapObj.

 applySLD ($sldxml)
 Apply an SLD document to the map file.

 applySLDURL ($sldurl)
 Apply the SLD document pointed to by the URL to the map file.

 generateSLD ()
 Returns an SLD XML string based on all classes found in all layers.

 toString ()
 Returns the current mapfile as a string.

 __sleep ()
 Prepare object for serialisation.

 __wakeup ()
 Initialise object after unserialisation.


Public Attributes

 $_m = null
 The PHP MapScript mapObj resource.

 $_map_string = null
 The serialised mapfile.


Constructor & Destructor Documentation

Map::Map map_file,
new_map_path = null
 

Constructs a Map.

Parameters:
$map_file path to the mapfile
$new_map_path base path for all relative paths inside the mapfile

Definition at line 80 of file map.php.


Member Function Documentation

Map::__sleep  ) 
 

Prepare object for serialisation.

This method is automatically called just before the object is serialised to carry out clean-up operations. See the PHP documentation at http://www.php.net/manual/en/language.oop.magic-functions.php for more information.

Returns:
an array of object property names to be serialised.

Reimplemented in MapManager.

Definition at line 732 of file map.php.

Map::__wakeup  ) 
 

Initialise object after unserialisation.

This method is automatically called just after the object is unserialised and ensures it is properly initialised. See the PHP documentation at http://www.php.net/manual/en/language.oop.magic-functions.php for more information.

Returns:
void

Reimplemented in MapManager.

Definition at line 747 of file map.php.

Map::applySLD sldxml  ) 
 

Apply an SLD document to the map file.

Parameters:
$sldxml the filename of the SLD document
Returns:
integer

Definition at line 676 of file map.php.

Map::applySLDURL sldurl  ) 
 

Apply the SLD document pointed to by the URL to the map file.

Parameters:
$sldurl the URL
Returns:
integer

Definition at line 686 of file map.php.

Map::clone  ) 
 

Returns a handle to a new mapObj which is a clone of the base mapObj.

All parameters in the current mapObj are copied to the new mapObj.

Returns:
a mapObj or null on error

Definition at line 145 of file map.php.

Map::draw  ) 
 

Render the map and return a handle on the image object.

Returns:
the imageObj resource

Reimplemented in MapManager.

Definition at line 194 of file map.php.

Map::drawLabelCache image  ) 
 

Renders the labels for a map.

Parameters:
$image the imageObj with which to draw the labels
Returns:
integer -1 on error

Definition at line 260 of file map.php.

Map::drawLegend  ) 
 

Render the legend and return a handle on the image object.

Returns:
the imageObj resource

Definition at line 212 of file map.php.

Map::drawQuery  ) 
 

Render a query map and return a handle on the image object.

Returns:
the imageObj resource

Definition at line 203 of file map.php.

Map::drawReferenceMap  ) 
 

Render the reference map and return a handle on the image object.

Returns:
the imageObj resource

Definition at line 221 of file map.php.

Map::drawScaleBar  ) 
 

Render the scale bar and return a handle on the image object.

Returns:
the imageObj resource

Definition at line 230 of file map.php.

Map::embedlegend image  ) 
 

Embeds a legend.

Parameters:
$image the imageObj resource in which to embed the legend
Returns:
integer

Definition at line 240 of file map.php.

Map::embedScalebar image  ) 
 

Embeds a scalebar.

Parameters:
$image the imageObj in which to embed the scalebar
Returns:
integer

Definition at line 250 of file map.php.

Map::freequery layerindex  ) 
 

Frees the query result on a layer.

Parameters:
$layerindex the index of the layer
Returns:
void

Definition at line 437 of file map.php.

Map::generateSLD  ) 
 

Returns an SLD XML string based on all classes found in all layers.

Returns:
XML string

Definition at line 695 of file map.php.

& Map::get property_name  ) 
 

Return the value of the specified property of the mapscript mapObj resource.

Parameters:
$property_name the name of a mapObj property
Returns:
the property value

Definition at line 132 of file map.php.

Map::getAllGroupNames  ) 
 

Return an array containing all group names used in the map.

Returns:
array

Definition at line 528 of file map.php.

Map::getAllLayerNames  ) 
 

Return an array containing all layer names.

Returns:
array

Definition at line 537 of file map.php.

Map::getCObj  ) 
 

Get the underlying MapScript mapObj resource.

Returns:
the mapscript mapObj resource

Definition at line 112 of file map.php.

Map::getcolorbyindex iCloIndex  ) 
 

Returns a colorObj corresponding to the colour index in the palette.

Parameters:
$iCloIndex the colour index
Returns:
the colorObj

Definition at line 290 of file map.php.

Map::getLayer index  ) 
 

Returns a layerObj from the map given an index value.

Parameters:
$index the layer's index (0 = first layer)
Returns:
the layerObj

Definition at line 270 of file map.php.

Map::getLayerByName layer_name  ) 
 

Returns a layerObj from the map given a layer name.

Parameters:
$layer_name the layer name
Returns:
the layerObj

Definition at line 280 of file map.php.

Map::getlayersdrawingorder  ) 
 

Return an array containing layer indices in the order in which they are drawn.

Returns:
array

Definition at line 566 of file map.php.

Map::getLayersIndexByGroup groupname  ) 
 

Return an array containing layer indices for all layers belonging to a specified group.

Parameters:
$groupname the name of the group
Returns:
the array of indices

Definition at line 519 of file map.php.

Map::getMetaData name  ) 
 

Fetch metadata entry by name.

Parameters:
$name case insensitive name
Returns:
an empty string if no entry matches the name

Definition at line 488 of file map.php.

Map::getNumSymbols  ) 
 

Return the number of symbols in the map.

Returns:
the symbol count

Definition at line 626 of file map.php.

Map::getProjection  ) 
 

Returns a string representation of the projection.

Returns:
the projection or MS_FALSE if no projection is set

Definition at line 456 of file map.php.

Map::getsymbolbyname symbol_name  ) 
 

Get the symbol index using the specified name.

Parameters:
$symbol_name the name of the symbol
Returns:
the symbol index as an integer

Definition at line 166 of file map.php.

Map::loadMapContext filename  ) 
 

Load a WMS Map context XML file into the current mapObj.

Parameters:
$filename the XML file
Returns:
integer

Definition at line 666 of file map.php.

Map::loadMapString map_string  ) 
 

Loads the map configuration from a string, replacing the current map object.

Parameters:
$map_string the mapfile as a string
Returns:
void

Definition at line 97 of file map.php.

References unique_mapfile().

Map::loadquery filename  ) 
 

Loads a query from a file.

Parameters:
$filename the name of the file
Returns:
MS_SUCCESS or MS_FAILURE

Definition at line 427 of file map.php.

Map::moveLayerDown layerindex  ) 
 

Move a layer down the drawing hierarchy.

Parameters:
$layerindex the layer index
Returns:
MS_SUCCESS or MS_FAILURE

Definition at line 557 of file map.php.

Map::moveLayerUp layerindex  ) 
 

Move a layer up in the drawing hierarchy.

Parameters:
$layerindex the layer index
Returns:
MS_SUCCESS or MS_FAILURE

Definition at line 547 of file map.php.

Map::prepareImage  ) 
 

Return handle on blank image object.

Returns:
the imageObj resource

Definition at line 184 of file map.php.

Map::preparequery  ) 
 

Calculate the scale of the map and assign it to the map->scale.

Returns:
void

Definition at line 175 of file map.php.

Map::processlegendtemplate params  ) 
 

Process the legend template file and return the result.

Parameters:
$params associative array specifying tag name=>value pairs for substitution
Returns:
processed template

Definition at line 607 of file map.php.

Map::processquerytemplate params,
generateimages = MS_TRUE
 

Process the query template file and return the result.

Parameters:
$params associative array specifying tag name=>value pairs for substitution
$generateimages MS_TRUE to generate content for image tags, MS_FALSE otherwise. Defaults to MS_TRUE
Returns:
processed template string

Definition at line 597 of file map.php.

Map::processtemplate params,
generateimages = MS_TRUE
 

Process the template file specified in the web object and return the result.

Parameters:
$params associative array specifying tag name=>value pairs for substitution
$generateimages MS_TRUE to generate content for image tags, MS_FALSE otherwise. Defaults to MS_TRUE
Returns:
processed template string

Definition at line 586 of file map.php.

Map::queryByFeatures slayer  ) 
 

Perform a query based on a previous set of results from a layer.

Parameters:
$slayer the index of the layer
Returns:
MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found

Definition at line 394 of file map.php.

Map::queryByIndex layerindex,
tileindex,
shapeindex,
addtoquery = MS_FALSE
 

Add a specific shape on a given layer to the query result.

Parameters:
$layerindex the index of the layer
$tileindex the index of the tile
$shapeindex the index of the shape
$addtoquery if true the shape will be added to the existing query list. Default behaviour is to free the existing query list and add only the new shape
Returns:
MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found

Definition at line 407 of file map.php.

Map::queryByPoint point,
mode,
buffer
 

Query all selected layers in map at specific point location.

Parameters:
$point pointObj specifying point in georeferenced map coordinates
$mode MS_SINGLE or MS_MULTIPLE depending on the number of results required
$buffer a value >0 equates to a tolerance buffer specified in ground units. A value <=0 defaults to tolerances set in the map file
Returns:
MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found

Definition at line 364 of file map.php.

Map::queryByRect rect  ) 
 

Query all selected layers in the map using a specified extent.

Parameters:
$rect rectObj specifying query extent in georeferenced coordinates
Returns:
MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found

Definition at line 374 of file map.php.

Map::queryByShape shape  ) 
 

Query all selected layers in the map based on a single shape.

Parameters:
$shape shapeObj representing a polygon specfying the query extent
Returns:
MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found

Definition at line 384 of file map.php.

Map::removeMetaData name  ) 
 

Remove a metadata entry for the map.

Parameters:
$name 
Returns:
MS_SUCCESS or MS_FAILURE

Definition at line 509 of file map.php.

Map::save filename  ) 
 

Save current map object state to a file.

Parameters:
$filename the name of the file
Returns:
-1 on error

Definition at line 447 of file map.php.

Map::saveMapContext filename  ) 
 

Save the current map object state in WMS Map Context format to a file.

Parameters:
$filename the filename to save to
Returns:
integer

Definition at line 656 of file map.php.

Map::savequery filename  ) 
 

Save the current query in a file.

Parameters:
$filename the name of the file
Returns:
MS_SUCCESS or MS_FAILURE

Definition at line 417 of file map.php.

Map::selectOutputFormat type  ) 
 

Selects the output format to be used in the map.

Parameters:
$type either the mime-type or name of an output format
Returns:
MS_FAILURE if no corresponding output format type is found, MS_SUCCESS otherwise

Definition at line 646 of file map.php.

Map::set property_name,
new_value
 

Set map object property to new value.

Parameters:
$property_name mapObj property name
$new_value value to set property to
Returns:
a positive integer or -1 on error

Definition at line 156 of file map.php.

Map::setCObj map  ) 
 

Replace the current mapscript mapObj resource.

Parameters:
$map a mapscript mapObj resource
Returns:
void

Definition at line 122 of file map.php.

Map::setextent minx,
miny,
maxx,
maxy
 

Set the map extents from georeferenced values.

Parameters:
$minx the minimum X value
$miny the minimum Y value
$maxx the maximum X value
$maxy the maximum Y value
Returns:
void

Definition at line 303 of file map.php.

Map::setFontSet fileName  ) 
 

Load and set a new fontset.

Parameters:
$fileName the location of the fontset
Returns:
integer

Definition at line 636 of file map.php.

Map::setlayersdrawingorder layeryindex  ) 
 

Set the order in which layers are drawn.

Parameters:
$layeryindex the layer indices
Returns:
MS_TRUE or MS_FALSE

Definition at line 576 of file map.php.

Map::setMetaData name,
value
 

Set a metadata entry for the map.

Parameters:
$name 
$value 
Returns:
MS_SUCCESS or MS_FAILURE

Definition at line 499 of file map.php.

Map::setProjection proj_params,
bSetUnitsAndExtents = MS_FALSE
 

Set map projection and coordinate system.

Parameters:
$proj_params a single string of comma-delimited PROJ.4 parameters
$bSetUnitsAndExtents MS_TRUE updates map units and extents based on the new projection. Defaults to MS_FALSE.
Returns:
integer

Definition at line 467 of file map.php.

Map::setSymbolSet fileName  ) 
 

Load and set a symbol file dynamically.

Parameters:
$fileName the name of the symbol file
Returns:
integer

Definition at line 617 of file map.php.

Map::setWKTProjection proj_params,
bSetUnitsAndExtents = MS_FALSE
 

Set map projection and coordinate system.

Parameters:
$proj_params OGC WKT projection
$bSetUnitsAndExtents MS_TRUE updates map units and extents based on the new projection. Defaults to MS_FALSE.
Returns:
integer

Definition at line 478 of file map.php.

Map::toString  ) 
 

Returns the current mapfile as a string.

Returns:
string

Definition at line 709 of file map.php.

References unique_mapfile().

Map::zoompoint nZoomFactor,
oPixelPox,
nImageWidth,
nImageHeight,
oGeorefExt,
oMaxGeorefExt = null
 

Zoom to a given XY position.

Parameters:
$nZoomFactor Zoom factor; positive values zoom in, negative values zoom out. 1 recenters
$oPixelPox pointObj containing pixel position with (0,0) == top left
$nImageWidth the width of the image
$nImageHeight the height of the image
$oGeorefExt a rectObj specifying the current georeferenced map extent
$oMaxGeorefExt a rectObj specifying the maximum georeferenced extent
Returns:
void

Definition at line 318 of file map.php.

Map::zoomrectangle oPixelExt,
nImageWidth,
nImageHeight,
oGeorefExt
 

Set the map extent to a given value.

Parameters:
$oPixelExt rectObj specifying the new extent
$nImageWidth the width of the image
$nImageHeight the height of the image
$oGeorefExt the current georeferenced extent
Returns:
void

Definition at line 334 of file map.php.

Map::zoomscale nScale,
oPixelPos,
nImageWidth,
nImageHeight,
oGeorefExt,
oMaxGeorefExt = null
 

Zoom in or out to a given XY position so that the map is displayed at a specified scale.

Parameters:
$nScale scale at which the map should be displayed
$oPixelPos XY image coordinates to centre on where (0,0) == top left
$nImageWidth the width of the image
$nImageHeight the height of the image
$oGeorefExt rectObj specifying the current georeferenced extent
$oMaxGeorefExt rectObj specifying the maximum georeferenced extent
Returns:
void

Definition at line 349 of file map.php.


Member Data Documentation

Map::$_m = null
 

The PHP MapScript mapObj resource.

Definition at line 63 of file map.php.

Map::$_map_string = null
 

The serialised mapfile.

This is only ever populated during serialisation; it contains the mapfile which is then used to re-instantiate the mapscript mapObj when the object is unserialised. Therefore for all intents and purposes it will be null.

Definition at line 73 of file map.php.


The documentation for this class was generated from the following file:
Generated on Mon Feb 14 11:40:07 2005 for MapManager by doxygen 1.3.5