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

Source for file E00.php

Documentation is available at E00.php

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | PEAR :: Image :: GIS :: E00 Parser                                     |
  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$
  17. //
  18.  
  19. require_once 'Image/GIS2/LineSet.php';
  20. require_once 'Image/GIS2/Parser.php';
  21.  
  22. /**
  23.  * E00 Parser.
  24.  *
  25.  * @author      Jan Kneschke <jan@kneschke.de>
  26.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  27.  * @copyright   Copyright &copy; 2002-2005 Jan Kneschke <jan@kneschke.de> and Sebastian Bergmann <sb@sebastian-bergmann.de>
  28.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  29.  * @category    Image
  30.  * @package     Image_GIS2
  31.  */
  32.     /**
  33.     * Constructor.
  34.     *
  35.     * @param  boolean $cache 
  36.     * @param  boolean $debug 
  37.     * @access public
  38.     */
  39.     public function Image_GIS2_Parser_E00($cache$debug{
  40.         $this->Image_GIS2_Parser($cache$debug);
  41.     }
  42.  
  43.     /**
  44.     * Parses a data file.
  45.     *
  46.     * @param  string  $dataFile 
  47.     * @param  mixed   $color 
  48.     * @return mixed 
  49.     * @access public
  50.     */
  51.     public function parseFile($dataFile$color{
  52.         $lineSet = new Image_GIS2_LineSet($color);
  53.  
  54.         if ($fp @fopen($dataFile'r')) {
  55.             $numRecords = 0;
  56.             $lineNum    = 0;
  57.  
  58.             while(0 || $line fgets($fp1024)) {
  59.                 $lineNum++;
  60.  
  61.                 if ($numRecords == 0 && 
  62.                     preg_match("#^\s+([0-9]+)\s+([-0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)#"$line$a)) {
  63.                     $numRecords $a[7];
  64.  
  65.                     $pl['x'= -1;
  66.                     $pl['y'= -1;
  67.                 }
  68.  
  69.                 else if ($numRecords &&
  70.                          preg_match("#^([ -][0-9]\.[0-9]{7}E[-+][0-9]{2})([ -][0-9]\.[0-9]{7}E[-+][0-9]{2})([ -][0-9]\.[0-9]{7}E[-+][0-9]{2})([ -][0-9]\.[0-9]{7}E[-+][0-9]{2})#"$line$a)) {
  71.                     if ($this->debug{
  72.                         echo $a[0'<br />';
  73.                     }
  74.  
  75.                     if ($pl['x'!= -1 &&
  76.                         $pl['y'!= -1{
  77.                         $lineSet->addLine($pl['x']$pl['y']$a[1]$a[2]);
  78.                     }
  79.  
  80.                     $numRecords--;
  81.  
  82.                     $lineSet->addLine($a[1]$a[2]$a[3]$a[4]);
  83.  
  84.                     $pl['x'$a[3];
  85.                     $pl['y'$a[4];
  86.  
  87.                     $numRecords--;
  88.                 }
  89.  
  90.                 else if ($numRecords &&
  91.                          preg_match("#^([ -][0-9]\.[0-9]{7}E[-+][0-9]{2})([ -][0-9]\.[0-9]{7}E[-+][0-9]{2})#"$line$a)) {
  92.                     if ($pl['x'!= -1 &&
  93.                         $pl['y'!= -1{
  94.                         $lineSet->addLine($pl['x']$pl['y']$a[1]$a[2]);
  95.  
  96.                         $pl['x'$a[1];
  97.                         $pl['y'$a[2];
  98.                     }
  99.  
  100.                     $numRecords--;
  101.                 }
  102.  
  103.                 else if ($lineNum > 2{
  104.                     if ($this->debug{
  105.                         printf(
  106.                           'Died at: %s<br />',
  107.                           $lineNum
  108.                         );
  109.                     }
  110.  
  111.                     break;
  112.                 }
  113.  
  114.                 else if ($this->debug{
  115.                     echo $line '<br />';
  116.                 }
  117.             }
  118.  
  119.             @fclose($fp);
  120.  
  121.             return $lineSet;
  122.         }
  123.  
  124.         return false;
  125.     }
  126. }
  127. ?>

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