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

Class: SMap_Canvas_Cache

Source Location: /SMap.php

Class SMap_Canvas_Cache

Class Overview

A class for caching tiles

This class is used to cache tile images to disk. If you are caching the layered tile, pass the image type to load() and an optimized version of the tile will be saved when display() is called. For optimization, ensure that you have the command line utilites jpegtran and optipng installed.

If you have image caching disabled, I expect that you will enable it eventually, so I enable a "debug mode" in cache() which reads the images back after saving them to help ensure that there is no image corruption.

If you are caching an individual layer, you should use IMAGETYPE_GD2 for the format. Then embed this cache in SMap_Object_CachedImage.

Located in /SMap.php [line 1912]

SMap_Canvas
   |
   --SMap_Canvas_Cache
Author(s):
API Tags:
Usedby:  SMap_Tile::flattenImg()

Properties

Methods

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From SMap_Canvas

SMap_Canvas::$img
SMap_Canvas::$imgRefCount
SMap_Canvas::$tile

Inherited From SMap_Canvas

SMap_Canvas::__construct()
Create a canvas which fits the current tile
SMap_Canvas::allocColor()
Allocate a color for an image
SMap_Canvas::allocImage()
Allocate an image
SMap_Canvas::composite()
Composite another canvas atop this one
SMap_Canvas::compositeRes()
Composite an image resource
SMap_Canvas::display()
Display an image
SMap_Canvas::filledPolygon()
Draw a filled polygon
SMap_Canvas::filledRectangle()
Draw a filled rectangle
SMap_Canvas::fontHeight()
Find a font height in pixels
SMap_Canvas::fontWidth()
Find a font width in pixels
SMap_Canvas::line()
Draw a line
SMap_Canvas::load()
Load an image from file
SMap_Canvas::loadRaw()
Load an image from file
SMap_Canvas::polygon()
Draw a polygon
SMap_Canvas::rectangle()
Draw a rectangle
SMap_Canvas::setPixel()
Set a single pixel
SMap_Canvas::str()
Draw a string
SMap_Canvas::__destruct()
Destroy image also
SMap_Canvas::__get()
Access useful vars read-only

[ Top ]
Property Summary
integer   $imgBytes   The size of the retrieved image
string   $imgRaw   The retrieved image data
integer   $imgType   The type of image
array   $layers   The cached layers

[ Top ]
Method Summary
SMap_Canvas_Cache   __construct()   Create a cache object
void   cache()   Caches the image
boolean   display()   Displays the image
void   fileErr()   Checks a cache file for oddness
void   getCachedFName()   Creates the filename for a cached tile
boolean   isLoaded()   Was a cached image loaded?
mixed   loadFromCache()   Loads a cached tile image

[ Top ]
Properties
integer   $imgBytes [line 1926]

The size of the retrieved image

API Tags:
Access:  protected


[ Top ]
string   $imgRaw [line 1919]

The retrieved image data

API Tags:
Access:  protected


[ Top ]
integer   $imgType [line 1933]

The type of image

API Tags:
Access:  protected


[ Top ]
array   $layers [line 1940]

The cached layers

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 1958]

  SMap_Canvas_Cache __construct( SMap_Tile $tile, array $layers, integer $fType  )

Create a cache object

The layers parameter

Parameters:
object The   $tile:  tile
array   $layers:  Layers contained in this cache
integer   $fType:  Image format


Redefinition of:
SMap_Canvas::__construct()
Create a canvas which fits the current tile

[ Top ]
cache  [line 2090]

  void cache( $fmt  )

Caches the image

Parameters:
   $fmt: 

API Tags:
Access:  public
Uses:  SMap_Canvas_Cache::getCachedFName()


[ Top ]
display  [line 2233]

  boolean display( integer $fmt  )

Displays the image

If the image was cached, display it. Otherwise, take the passed image and cache it (then display it).

Parameters:
integer   $fmt:  Image format

API Tags:
Return:  Was the image sucessfuly cached and displayed?
Access:  public


Redefinition of:
SMap_Canvas::display()
Display an image

[ Top ]
fileErr  [line 2211]

  void fileErr( string $fname  )

Checks a cache file for oddness

And throws an appropriate error

Parameters:
string   $fname:  File name

API Tags:
Access:  protected


[ Top ]
getCachedFName  [line 1970]

  void getCachedFName( )

Creates the filename for a cached tile

We will need the identity of the map, which is passed in as a string. We will also need the identity of this tile, which we will be generating.


API Tags:
Usedby:  SMap_Canvas_Cache::cache()
Usedby:  SMap_Canvas_Cache::loadFromCache()
Access:  protected


[ Top ]
isLoaded  [line 2005]

  boolean isLoaded( )

Was a cached image loaded?


API Tags:
Access:  public


[ Top ]
loadFromCache  [line 2029]

  mixed loadFromCache( integer $mtime  )

Loads a cached tile image

If a cached version of this tile exists, load it, but respect the cache time. If the file exists, but the age of the file is greater than the modification time, no image is loaded.

The expected filetype is one of the IMAGETYPE_* constants.

The last modified time is set as the modified time of the file using setLastModified(). The size of file read is limited to 4 MB. I can't think of a good reason for your tile to be larger than that anyway, so this may signal an error.

Parameters:
integer   $mtime:  Minimum file modification time.

API Tags:
Return:  False if not found, GD resource, or file contents
Access:  public
Uses:  setLastModified()
Uses:  SMap_Canvas_Cache::getCachedFName()
Uses:  $loaded


[ Top ]

Documentation generated on Mon, 09 Apr 2007 18:55:59 -0500 by phpDocumentor 1.3.0