cvs: pear /Image_GIS GIS.php /Image_GIS/GIS Parser.php Renderer.php /Image_GIS/GIS/Parser E00.php

From: Date: Mon, 30 Dec 2002 15:53:34 +0000
Subject: cvs: pear /Image_GIS GIS.php /Image_GIS/GIS Parser.php Renderer.php /Image_GIS/GIS/Parser E00.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7996@lists.php.net to get a copy of this message
sebastian Mon Dec 30 10:53:34 2002 EDT Modified files: /pear/Image_GIS GIS.php /pear/Image_GIS/GIS Parser.php Renderer.php /pear/Image_GIS/GIS/Parser E00.php Log: Add range detection. Index: pear/Image_GIS/GIS.php diff -u pear/Image_GIS/GIS.php:1.3 pear/Image_GIS/GIS.php:1.4 --- pear/Image_GIS/GIS.php:1.3 Mon Dec 30 06:46:58 2002 +++ pear/Image_GIS/GIS.php Mon Dec 30 10:53:31 2002 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: GIS.php,v 1.3 2002/12/30 11:46:58 sebastian Exp $ +// $Id: GIS.php,v 1.4 2002/12/30 15:53:31 sebastian Exp $ // require_once 'Image/Color.php'; @@ -50,7 +50,7 @@ * $map->saveImage('kiel.png'); * ?> * -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * @since Image_GIS 1.0.0 */ class Image_GIS { @@ -110,7 +110,15 @@ * @access public */ function render() { - $this->renderer->render($this->parser->parse()); + list($lines, $min, $max) = $this->parser->parse(); + + if ($this->renderer->min == false || + $this->renderer->max == false) { + $this->renderer->min = $min; + $this->renderer->max = $max; + } + + $this->renderer->render($lines); } /** Index: pear/Image_GIS/GIS/Parser.php diff -u pear/Image_GIS/GIS/Parser.php:1.1 pear/Image_GIS/GIS/Parser.php:1.2 --- pear/Image_GIS/GIS/Parser.php:1.1 Mon Dec 30 06:36:50 2002 +++ pear/Image_GIS/GIS/Parser.php Mon Dec 30 10:53:33 2002 @@ -13,13 +13,13 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: Parser.php,v 1.1 2002/12/30 11:36:50 sebastian Exp $ +// $Id: Parser.php,v 1.2 2002/12/30 15:53:33 sebastian Exp $ // /** * Parser Base Class. * -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @since Image_GIS 1.0.0 */ class Image_GIS_Parser { @@ -45,6 +45,22 @@ var $lines = array(); /** + * @var array $min + */ + var $min = array( + 'x' => 0, + 'y' => 0 + ); + + /** + * @var array $max + */ + var $max = array( + 'x' => 0, + 'y' => 0 + ); + + /** * Constructor. * * @param boolean $debug @@ -70,6 +86,25 @@ } /** + * Adds a line to the map. + * + * @param float $x1 + * @param float $y1 + * @param float $x2 + * @param float $y2 + * @param mixed $color + * @access public + */ + function addLine($x1, $y1, $x2, $y2, $color) { + $this->lines[] = array($x1, $y1, $x2, $y2, $color); + + $this->min['x'] = min($this->min['x'], $x1, $x2); + $this->min['y'] = min($this->min['y'], $y1, $y2); + $this->max['x'] = max($this->max['x'], $x1, $x2); + $this->max['y'] = max($this->max['y'], $y1, $y2); + } + + /** * Adds a datafile to the map. * * @param string $dataFile @@ -91,7 +126,7 @@ $this->parseFile($dataFile, $color); } - return $this->lines; + return array($this->lines, $this->min, $this->max); } /** Index: pear/Image_GIS/GIS/Renderer.php diff -u pear/Image_GIS/GIS/Renderer.php:1.1 pear/Image_GIS/GIS/Renderer.php:1.2 --- pear/Image_GIS/GIS/Renderer.php:1.1 Mon Dec 30 06:36:50 2002 +++ pear/Image_GIS/GIS/Renderer.php Mon Dec 30 10:53:33 2002 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: Renderer.php,v 1.1 2002/12/30 11:36:50 sebastian Exp $ +// $Id: Renderer.php,v 1.2 2002/12/30 15:53:33 sebastian Exp $ // require_once 'Image/Color.php'; @@ -21,7 +21,7 @@ /** * Renderer Base Class. * -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @since Image_GIS 1.0.0 */ class Image_GIS_Renderer { @@ -35,12 +35,12 @@ /** * @var array $min */ - var $min; + var $min = false; /** * @var array $max */ - var $max; + var $max = false; /** * Width of the image. Index: pear/Image_GIS/GIS/Parser/E00.php diff -u pear/Image_GIS/GIS/Parser/E00.php:1.1 pear/Image_GIS/GIS/Parser/E00.php:1.2 --- pear/Image_GIS/GIS/Parser/E00.php:1.1 Mon Dec 30 06:36:50 2002 +++ pear/Image_GIS/GIS/Parser/E00.php Mon Dec 30 10:53:33 2002 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +------------------------------------------------------------------------+ // -// $Id: E00.php,v 1.1 2002/12/30 11:36:50 sebastian Exp $ +// $Id: E00.php,v 1.2 2002/12/30 15:53:33 sebastian Exp $ // require_once 'Image/GIS/Parser.php'; @@ -21,7 +21,7 @@ /** * E00 Parser. * -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @since Image_GIS 1.0.0 */ class Image_GIS_Parser_E00 extends Image_GIS_Parser { @@ -67,12 +67,12 @@ if ($pl['x'] != -1 && $pl['y'] != -1) { - $this->lines[] = array($pl['x'], $pl['y'], $a[1], $a[2], $color); + $this->addLine($pl['x'], $pl['y'], $a[1], $a[2], $color); } $numRecords--; - $this->lines[] = array($a[1], $a[2], $a[3], $a[4], $color); + $this->addLine($a[1], $a[2], $a[3], $a[4], $color); $pl['x'] = $a[3]; $pl['y'] = $a[4]; @@ -84,7 +84,7 @@ preg_match("#^ ([0-9]\.[0-9]{7}E[-+][0-9]{2}) ([0-9]\.[0-9]{7}E[-+][0-9]{2})#", $line, $a)) { if ($pl['x'] != -1 && $pl['y'] != -1) { - $this->lines[] = array($pl['x'], $pl['y'], $a[1], $a[2], $color); + $this->addLine($pl['x'], $pl['y'], $a[1], $a[2], $color); $pl['x'] = $a[1]; $pl['y'] = $a[2];

« previous php.pear.cvs (#7996) next »