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

Class: SMap_Tile

Source Location: /SMap/Tile.php

Class SMap_Tile

Class Overview

Represents a piece of a view

Each tile is a section of the view. A tile is as large or small as needed. Larger tiles mean fewer requests to the webserver. Smaller tiles mean a greater opportunity for caching.

Located in /SMap/Tile.php [line 50]



		
				Author(s):
		
API Tags:
Usedby:  SMap::dispTileImg()

Properties

Methods

[ Top ]
Constant Summary
POSX   Array indicies for tile position
POSY  
TILESX  
TILESY  
VIEWX  
VIEWY  

[ Top ]
Property Summary
array   $bounds   The bounds of this tile
boolean   $cachedRects   Might we be dealing with cached rects?
integer   $cacheTime   Cache time of this tile's data in seconds
object   $canvas   A canvas
boolean   $constrained   Have we constrained this tile yet?
boolean   $flattened   Have we flattened this tile yet?
integer   $heightPx   Tile height in pixels
string   $imgCache   The raw image as retrieved from cache
integer   $imgFmt   View format
array   $imgMap   Image map for this image
integer   $lastModified   Last modified time for this tile
array   $layerObjs   Each layer's objects
array   $layers   List of layers that have been applied to this tile
object   $map   The map that contains this tile
array   $objs   Objects that need to be rendered
boolean   $rendered   Have we rendered this tile yet?
array   $tileGrid   This tile's position relative to other tiles
boolean   $tileGridNeeded   Is the tile grid needed to draw this tile?
object   $view   View that this tile is in
integer   $widthPx   Tile width in pixels

[ Top ]
Method Summary
SMap_Tile   __construct()   Set the properties of this tile
void   addLayer()   Add a layer to this tile.
void   addObject()   Apply an object to this tile
void   constrain()   Constrain each obect to this tile
void   createImage()   Ensures that we have a rendered image
void   display()   Display the current image
void   flatten()   Flattens the layers by reducing them to objects
void   flattenImg()   The image specific part of flattening
string   genMapKey()   Generate a 'map key'
array   getImageGET()   Get GET request vars to create an image URL
array   getImageMap()   Return the parameters for an image map (links)
void   needGrid()   Marks the tile grid as in use
void   setLastModified()   Sets the last modified time for this tile
mixed   __get()   Access useful vars read-only

[ Top ]
Properties
array   $bounds = array() [line 96]

The bounds of this tile

API Tags:
Access:  protected


[ Top ]
boolean   $cachedRects = false [line 185]

Might we be dealing with cached rects?

API Tags:
Access:  protected


[ Top ]
integer   $cacheTime = false [line 164]

Cache time of this tile's data in seconds

The option 'cacheTime' by default. There is no 'setter' function for cache time because flatten() calls SMap_Layer::cacheStatus() in order to set this value.

API Tags:
Access:  protected


[ Top ]
object   $canvas [line 139]

A canvas

API Tags:
Access:  protected


[ Top ]
boolean   $constrained = false [line 199]

Have we constrained this tile yet?

API Tags:
Usedby:  SMap_Tile::constrain()
Access:  protected


[ Top ]
boolean   $flattened = false [line 192]

Have we flattened this tile yet?

API Tags:
Usedby:  SMap_Tile::addObject()
Usedby:  SMap_Tile::constrain()
Usedby:  SMap_Tile::flatten()
Access:  protected


[ Top ]
integer   $heightPx [line 132]

Tile height in pixels

API Tags:
Access:  protected


[ Top ]
string   $imgCache [line 146]

The raw image as retrieved from cache

API Tags:
Usedby:  SMap_Tile::addObject()
Usedby:  SMap_Tile::constrain()
Access:  protected


[ Top ]
integer   $imgFmt = IMAGETYPE_PNG [line 178]

View format

API Tags:
Usedby:  SMap_Tile::flatten()
Usedby:  SMap_Tile::display()
Access:  protected


[ Top ]
array   $imgMap [line 153]

Image map for this image

API Tags:
Usedby:  SMap_Tile::getImageMap()
Access:  protected


[ Top ]
integer   $lastModified = 0 [line 171]

Last modified time for this tile

API Tags:
Usedby:  SMap_Tile::setLastModified()
Access:  protected


[ Top ]
array   $layerObjs = array() [line 216]

Each layer's objects

Seperate each layer into groups of objects. Once constrain() is called, the objects are placed in $objs.

API Tags:
Usedby:  SMap_Tile::constrain()
Access:  protected


[ Top ]
array   $layers = array() [line 89]

List of layers that have been applied to this tile

API Tags:
Usedby:  SMap_Tile::flattenImg()
Usedby:  SMap_Tile::flatten()
Access:  protected


[ Top ]
object   $map [line 75]

The map that contains this tile

API Tags:
Access:  protected


[ Top ]
array   $objs = array() [line 226]

Objects that need to be rendered

Objects are constrained and dumped in here (in order) via addObject().

API Tags:
Usedby:  SMap_Tile::addObject()
Access:  protected


[ Top ]
boolean   $rendered = false [line 206]

Have we rendered this tile yet?

API Tags:
Usedby:  SMap_Tile::addObject()
Access:  protected


[ Top ]
array   $tileGrid = array() [line 108]

This tile's position relative to other tiles

The tile grid marks the position of this tile in the rest of the view. This should be used sparingly in order to allow caching. The grid also won't be available if we have some sort of dynamic Google Maps thing going on.

API Tags:
Access:  protected


[ Top ]
boolean   $tileGridNeeded = false [line 118]

Is the tile grid needed to draw this tile?

If not, then we shouldn't pass those vars to the form. Not placing the grid for every tile will allow more effective caching.

API Tags:
Usedby:  SMap_Tile::needGrid()
Usedby:  SMap_Tile::getImageGET()
Access:  protected


[ Top ]
object   $view [line 82]

View that this tile is in

API Tags:
Access:  protected


[ Top ]
integer   $widthPx [line 125]

Tile width in pixels

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 236]

  SMap_Tile __construct( SMap $map, SMap_View $view, array $bounds, array $grid  )

Set the properties of this tile

Parameters:
object The   $map:  map that contains this tile
object The   $view:  view that contains this tile
array   $bounds:  The real bounds of the tile
array   $grid:  Where this tile is in relation to the others


[ Top ]
addLayer  [line 333]

  void addLayer( SMap_Layer $layer  )

Add a layer to this tile.

Adding the layer is the first step in getting it rendered. Each layer can only be added once. After all layers are added, flatten() must be called.

The creation of layers should use few resources. Use SMap_Layer::applyTile() to do any major setup. If there is a cache hit, it will not be called.

Parameters:
object SMap_Layer   $layer: 

API Tags:
Access:  public


[ Top ]
addObject  [line 693]

  void addObject( SMap_Object $obj  )

Apply an object to this tile

Applies a tile to an object, and adds said object to the $objs array.

Parameters:
object Object   $obj:  to draw

API Tags:
Uses:  SMap_Object::applyTile()
Access:  public
Usedby:  SMap_Tile::constrain()
Uses:  SMap_ImgCache::isLoaded()
Uses:  SMap_Tile::$rendered
Uses:  SMap_Tile::$imgCache
Uses:  SMap_Tile::$objs
Uses:  SMap_Tile::$flattened


[ Top ]
constrain  [line 659]

  void constrain( integer $lid  )

Constrain each obect to this tile

Calls addObject() for each object of the designated layer. addObject() then calls SMap_Object::applyTile() to apply this tile to each object.

Constrain should be called on all tiles for each layer at a time. This ensures that layers are properly handled even if an object calls addObject() on a neighboring tile via SMap_View::sendObj().

Parameters:
integer   $lid:  Constrain this layer's objects

API Tags:
Uses:  SMap_ImgCache::isLoaded()
Access:  public
Uses:  SMap_Tile::addObject()
Uses:  SMap_Tile::$layerObjs
Uses:  SMap_Tile::$flattened
Uses:  SMap_Tile::$imgCache
Uses:  SMap_Tile::$constrained


[ Top ]
createImage  [line 379]

  void createImage( )

Ensures that we have a rendered image

If the image doesn't already exist, create it. If layers have been added but not rendered, render them.


API Tags:
Usedby:  SMap_Tile::display()
Access:  protected
Uses:  SMap_Object_Area_Label::drawLabels()
Uses:  SMap_Object::draw()


[ Top ]
display  [line 275]

  void display( )

Display the current image

Also produces the appropriate headers.


API Tags:
Access:  public
Uses:  SMap_Tile::createImage()
Uses:  SMap_Tile::$imgFmt


[ Top ]
flatten  [line 513]

  void flatten( boolean $isImg  )

Flattens the layers by reducing them to objects

This is the second step in the process of rendering. The first is adding the layers. Here we take care of reducing each layer to objects, or retrieving the cached image.

Flattening is done after all layers are added so background labels can avoid foreground objects (such as the panning graphic). This is done before the final render is done so that labels have a chance to organize and send themselves to corrisponding tiles.

Image format selection is also decided here. We hope that photo realistic images (such as satellite) can be compressed as JPEG, just because it's more efficient compression. If a single layer requests PNG compression, though, we'll have to use PNG. This will ensure that we aren't forcing lossy compression where there shouldn't be any.

If all layers can agree on a different format (not PNG or JPEG), that format will be used. Ensure that the chosen format is enabled in SMap_Object_CachedImage::cache(), SMap_Object_CachedImage::getCachedFName(), and display().

If applicable, we are also handling caching here. SMap_Layer::cacheStatus() is called, and we figure out which layers should be cached, and which we can't cache at all. If the tile is cacheable and we have a cached tile, we retrieve it and use it. Otherwise we need to break it down to layers. Is each layer cacheable? Use a SMap_Object_CachedImage in place of rendering it.

Parameters:
boolean   $isImg:  Are we rendering an image or image map?

API Tags:
Uses:  SMap_Layer::getMapObjs()
Access:  public
Uses:  SMap_Layer::getImageFmt()
Uses:  SMap_Tile::$layers
Uses:  SMap_Tile::$imgFmt
Uses:  SMap_Tile::$flattened


[ Top ]
flattenImg  [line 560]

  void flattenImg( )

The image specific part of flattening


API Tags:
Access:  protected
Uses:  SMap_Object_CachedImage
Uses:  SMap_Layer::cacheStatus()
Uses:  SMap_Canvas_Cache
Uses:  SMap_Tile::$layers


[ Top ]
genMapKey  [line 782]

  string genMapKey( )

Generate a 'map key'

This key is different than SMap::$key because it only uses the layers enabled in this tile. It can also only be used after flatten() is called.


API Tags:
Access:  public
Uses:  SMap_Util::genMapKey()


[ Top ]
getImageGET  [line 417]

  array getImageGET( )

Get GET request vars to create an image URL

Returns the variables that need to be passed to this tile in order to generate the image.


API Tags:
Return:  GET variables
Access:  public
Uses:  SMap_Tile::getImageMap()
Uses:  SMap_Tile::$tileGridNeeded


[ Top ]
getImageMap  [line 454]

  array getImageMap( )

Return the parameters for an image map (links)

If we are returning a server side image map, one of the returned objects will be of shape 'ismap'. The form should be able to handle this case. If a user clicks on a server side image map, {@SMap::handleImageMap()} should be called, which will return the appropriate URL the user should be redirected to.

If we are returning a client side image map, returned set of arrays represent the "area" of the image map. They have indexes at ['alt'], ['coords'], ['shape'], and ['href'].

If there is no link here, we will return an empty array.


API Tags:
Return:  All image map parameters.
Usedby:  SMap_Tile::getImageGET()
Usedby:  SMap::handleImageMap()
Access:  public
Uses:  SMap_Object::map()
Uses:  SMap_Tile::$imgMap


[ Top ]
needGrid  [line 760]

  void needGrid( SMap_Layer $layer, [ $mask = null]  )

Marks the tile grid as in use

If the tile grid is needed, it will be passed via the URL to render the final image properly. It is suggested that the grid is only used when you really need it to allow for better caching. The grid also won't be available if we have some sort of dynamic Google Maps thing going on.

A layer that calls this must not be cached, or an exception will be thrown.

Parameters:
integer   $layer:  Mask of the needed parts of the grid
   $mask: 

API Tags:
Access:  public
Uses:  SMap_Layer::cacheStatus()
Uses:  SMap_Tile::$tileGridNeeded
See:  SMap_Tile::$tileGrid


[ Top ]
setLastModified  [line 737]

  void setLastModified( integer $time  )

Sets the last modified time for this tile

If no last modified time is set, then the current time is used. If there is already a modified time, then the more recent one is used.

Parameters:
integer   $time:  Unix timestamp

API Tags:
Access:  public
Uses:  SMap_Tile::$lastModified


[ Top ]
__get  [line 259]

  mixed __get( string $nm  )

Access useful vars read-only

Parameters:
string   $nm:  Name of member

API Tags:
Return:  Value of member
Access:  public


[ Top ]
Constants
POSX = 1 [line 63]

Array indicies for tile position

POSX,POSY are the position of the current tile in the grid. VIEWX,VIEWY are the dimensions of the view. TILESX,TILESY are the dimensions of the current map. VIEWX,VIEWY normaly equals TILESX,TILESY, except when a tile is being rendered. TILESX,TILESY are the only indicies that always are set.

API Tags:
Usedby:  SMap_Form::decodeTileGrid()
Usedby:  SMap_Form::encodeTileGrid()


[ Top ]
POSY = 4 [line 65]
API Tags:
Usedby:  SMap_Form::decodeTileGrid()
Usedby:  SMap_Form::encodeTileGrid()


[ Top ]
TILESX = 16 [line 67]

[ Top ]
TILESY = 32 [line 68]

[ Top ]
VIEWX = 2 [line 64]
API Tags:
Usedby:  SMap_Form::decodeTileGrid()
Usedby:  SMap_Form::encodeTileGrid()


[ Top ]
VIEWY = 8 [line 66]
API Tags:
Usedby:  SMap_Form::decodeTileGrid()
Usedby:  SMap_Form::encodeTileGrid()


[ Top ]

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