Image_GIS
[ class tree: Image_GIS ] [ index: Image_GIS ] [ all elements ]

Source for file Parser.php

Documentation is available at Parser.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: Image :: GIS :: Parser Base Class                              |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2005 Jan Kneschke <jan@kneschke.de> and             |
  7. // |                         Sebastian Bergmann <sb@sebastian-bergmann.de>. |
  8. // +------------------------------------------------------------------------+
  9. // | This source file is subject to version 3.00 of the PHP License,        |
  10. // | that is available at http://www.php.net/license/3_0.txt.               |
  11. // | If you did not receive a copy of the PHP license and are unable to     |
  12. // | obtain it through the world-wide-web, please send a note to            |
  13. // | license@php.net so we can mail you a copy immediately.                 |
  14. // +------------------------------------------------------------------------+
  15. //
  16. // $Id: Parser.php 299207 2010-05-10 10:21:58Z clockwerx $
  17. //
  18.  
  19. require_once 'Cache/Lite.php';
  20. require_once 'Image/GIS/LineSet.php';
  21.  
  22. /**
  23.  * Parser Base Class.
  24.  *
  25.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  26.  * @copyright   Copyright &copy; 2002-2005 Jan Kneschke <jan@kneschke.de> and Sebastian Bergmann <sb@sebastian-bergmann.de>
  27.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  28.  * @category    Image
  29.  * @package     Image_GIS
  30.  */
  31.     /**
  32.     * Cache.
  33.     *
  34.     * @var Cache_Lite $cache 
  35.     */
  36.     var $cache = NULL;
  37.  
  38.     /**
  39.     * Data Files.
  40.     *
  41.     * @var array $dataFiles 
  42.     */
  43.     var $dataFiles = array();
  44.  
  45.     /**
  46.     * Set to TRUE to enable debugging.
  47.     *
  48.     * @var boolean $debug 
  49.     */
  50.     var $debug;
  51.  
  52.     /**
  53.     * Line Set.
  54.     *
  55.     * @var array $lineSets 
  56.     */
  57.     var $lineSets = array();
  58.  
  59.     /**
  60.     * Constructor.
  61.     *
  62.     * @param  boolean $cache 
  63.     * @param  boolean $debug 
  64.     * @access public
  65.     */
  66.     function Image_GIS_Parser($cache$debug{
  67.         if ($cache{
  68.             $this->cache = new Cache_Lite;
  69.         }
  70.  
  71.         $this->debug = $debug;
  72.     }
  73.  
  74.     /**
  75.     * Factory.
  76.     *
  77.     * @param  string  $parser 
  78.     * @param  boolean $cache 
  79.     * @param  boolean $debug 
  80.     * @return object 
  81.     * @access public
  82.     */
  83.     function &factory($parser$cache$debug{
  84.         include_once 'Image/GIS/Parser/' $parser '.php';
  85.  
  86.         $class  'Image_GIS_Parser_' $parser;
  87.         $object = new $class($cache$debug);
  88.  
  89.         return $object;
  90.     }
  91.  
  92.     /**
  93.     * Adds a datafile to the map.
  94.     *
  95.     * @param  string  $dataFile 
  96.     * @param  mixed   $color 
  97.     * @access public
  98.     */
  99.     function addDataFile($dataFile$color{
  100.         $this->dataFiles[$dataFile$color;
  101.     }
  102.  
  103.     /**
  104.     * Parses the data files of the map.
  105.     *
  106.     * @access public
  107.     * @return array 
  108.     */
  109.     function parse({
  110.         foreach ($this->dataFiles as $dataFile => $color{
  111.             $cacheID md5($dataFile '_' $color);
  112.             $lineSet = false;
  113.  
  114.             if (is_object($this->cache&&
  115.                 $lineSet $this->cache->get($cacheID'Image_GIS')) {
  116.                 $lineSet unserialize($lineSet);
  117.             }
  118.  
  119.             if ($lineSet === false{
  120.                 $lineSet $this->parseFile($dataFile$color);
  121.  
  122.                 if (is_object($this->cache)) {
  123.                     $this->cache->save(serialize($lineSet)$cacheID'Image_GIS');
  124.                 }
  125.             }
  126.  
  127.             $this->lineSets[$lineSet;
  128.         }
  129.  
  130.         return $this->lineSets;
  131.     }
  132.  
  133.     /**
  134.     * Parses a data file.
  135.     *
  136.     * @param  string  $dataFile 
  137.     * @param  mixed   $color 
  138.     * @return mixed 
  139.     * @access public
  140.     * @abstract
  141.     */
  142.     function parseFile($dataFile$color/* abstract */ }
  143. }
  144. ?>

Documentation generated on Mon, 11 Mar 2019 15:39:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.