phpDocumentor SMap
[ class tree: SMap ] [ index: SMap ] [ all elements ]

Class: SMap_Util

Source Location: /SMap.php

Class SMap_Util

Class Overview

Utility functions

These should all be callable in static context.

Located in /SMap.php [line 787]



		
		
		
		

Methods

[ Top ]
Method Summary
static array   centerBounds()   Create bounds centered on this point
static integer   dec()   Decode a char as an integer
static string   enc()   Encode an integer as a char
static string   genMapKey()   Generates a map key that can be used to identify a layout that may be stored in the database or filesystem.
static string   genTileKey()   Generate a key for a tile
static void   normalizeBounds()   Shifts the given bounds to be "normal"
static string   reduceSigFigs()   Rounds to reduce the number of sig figs in a float
static string   transPng()   Make an XHTML image tag compatable with IE
static void   wrapBounds()   Shifts a view around a wrapped map

[ Top ]
Methods
static method centerBounds  [line 953]

  static array centerBounds( float $Bx, float $By, float $muPerTileX, float $muPerTileY, integer $tilesX, integer $tilesY, [boolean $normalize = true]  )

Create bounds centered on this point

Parameters:
float   $Bx:  Center point X
float   $By:  Center point Y
float   $muPerTileX:  Map units per tile X
float   $muPerTileY:  Map units per tile Y
integer   $tilesX:  Number of tiles that should be in the X dir
integer   $tilesY:  Number of tiles that should be in the Y dir
boolean   $normalize:  Normalizes bounds also (default= true)

API Tags:
Return:  The new bounds
Usedby:  SMap_Layer_Zoom::getZoomURL()
Access:  public
Uses:  SMap_Util::normalizeBounds()


[ Top ]
static method dec  [line 1003]

  static integer dec( string $chr  )

Decode a char as an integer

Unpack the url.

Parameters:
string   $chr: 

API Tags:
Usedby:  SMap_Form::decodeTileGrid()
Access:  public
See:  SMap_Util::enc()


[ Top ]
static method enc  [line 982]

  static string enc( integer $int  )

Encode an integer as a char

This function is used so we can pack the URL smaller. The chars used are [0-9A-Za-z].

Parameters:
integer   $int: 

API Tags:
Usedby:  SMap_Form::encodeTileGrid()
Access:  public


[ Top ]
static method genMapKey  [line 821]

  static string genMapKey( array $layers, integer $zoom, string $lang  )

Generates a map key that can be used to identify a layout that may be stored in the database or filesystem.

The layers list must be a numrical list in the order that the layers were applied.

Parameters:
array   $layers:  Active layers.
integer   $zoom:  Current view level.
string   $lang:  ISO 639-2 three letter language string

API Tags:
Return:  SMap key, 40 chars or less
Usedby:  SMap_Tile::genMapKey()
Usedby:  SMap::__construct()
Access:  public


[ Top ]
static method genTileKey  [line 855]

  static string genTileKey( array $bounds, array $tileGrid  )

Generate a key for a tile

The layers list must be a numrical list in the order that the layers were applied. Uses reduceSigFigs() to round the floats, so you can use 'sigFigs' to alter the size of thte numbers produced.

Parameters:
array   $bounds:  Bounds array
array   $tileGrid:  Position relative to other tiles

API Tags:
Return:  Key for this tile
Access:  public
Uses:  SMap_Util::reduceSigFigs()


[ Top ]
static method normalizeBounds  [line 929]

  static void normalizeBounds( array &$B, float $muPerTileX, float $muPerTileY, integer $tilesX, integer $tilesY  )

Shifts the given bounds to be "normal"

Shifts the bounds to contain an integer multiple of tiles, and for there to be an integer multiple of tiles between the current bounds and (0,0). When tiles are normalized like this there can be less precision in the URL. Any rounding errors are normalized out here.

Parameters:
array   &$B:  Bounds to normalize
float   $muPerTileX:  Map units per tile X
float   $muPerTileY:  Map units per tile Y
integer   $tilesX:  Number of tiles that should be in the X dir
integer   $tilesY:  Number of tiles that should be in the Y dir

API Tags:
Usedby:  SMap_Util::centerBounds()
Usedby:  SMap_Form::__construct()
Access:  public


[ Top ]
static method reduceSigFigs  [line 801]

  static string reduceSigFigs( float $float  )

Rounds to reduce the number of sig figs in a float

Useful when comparing two floating point numbers and printing numbers on a page. It should print numbers such that similar floating point numbers are always printed with the same string.

Use the 'sigFigs' option to alter the precision of the produced strings.

Parameters:
float   $float:  Just another float.

API Tags:
Return:  Float expressed as a string.
Usedby:  SMap_Util::genTileKey()
Access:  public


[ Top ]
static method transPng  [line 1029]

  static string transPng( string $url, string $alt, integer $w, integer $h, string $tags, string $style  )

Make an XHTML image tag compatable with IE

MSIE sucks at the whole "internet" thing. Maybe they'll get it right next time. In the mean time, this function specifically emits an image tag that hacks transparency into a given PNG.

Parameters:
string   $url:  Image URL
string   $alt:  Image Alt tag
integer   $w:  Image width
integer   $h:  Image height
string   $tags:  Extra tags (caller escapes)
string   $style:  Extra style (caller escapes)

API Tags:
Return:  Image tag
Access:  public


[ Top ]
static method wrapBounds  [line 889]

  static void wrapBounds( array &$bounds, array $wrap  )

Shifts a view around a wrapped map

Parameters:
array   &$bounds:  The bounds to wrap
array   $wrap:  The wrapping information

API Tags:
Usedby:  SMap_Layer_Pan::getShiftedURL()
Usedby:  SMap_Form::__construct()
Access:  public


[ Top ]

Documentation generated on Mon, 09 Apr 2007 18:56:05 -0500 by phpDocumentor 1.3.0