Skip to content
Browse files

Merge fix for bug #1179.

git-svn-id: http://svn.php.net/repository/pear/packages/Image_GIS2/trunk@167238 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 671a26e commit 647d5ccdbe8aba3303342e693076c0174f4a4fae @sebastianbergmann sebastianbergmann committed Aug 25, 2004
Showing with 26 additions and 28 deletions.
  1. +13 −12 GIS2/LineSet.php
  2. +2 −2 GIS2/Parser/E00.php
  3. +11 −14 GIS2/Renderer.php
View
25 GIS2/LineSet.php
@@ -39,18 +39,12 @@ class Image_GIS2_LineSet {
/**
* @var array $min
*/
- public $min = array(
- 'x' => 0,
- 'y' => 0
- );
+ public $min = false;
/**
* @var array $max
*/
- public $max = array(
- 'x' => 0,
- 'y' => 0
- );
+ public $max = false;
/**
* Constructor.
@@ -74,10 +68,17 @@ public function Image_GIS2_LineSet($color = 'black') {
public function addLine($x1, $y1, $x2, $y2) {
$this->lines[] = array($x1, $y1, $x2, $y2);
- $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);
+ if ($this->min == false) {
+ $this->min['x'] = min($x1, $x2);
+ $this->min['y'] = min($y1, $y2);
+ $this->max['x'] = max($x1, $x2);
+ $this->max['y'] = max($y1, $y2);
+ } else {
+ $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);
+ }
}
}
?>
View
4 GIS2/Parser/E00.php
@@ -68,7 +68,7 @@ public function parseFile($dataFile, $color) {
}
else if ($numRecords &&
- 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)) {
+ 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)) {
if ($this->debug) {
echo $a[0] . '<br />';
}
@@ -89,7 +89,7 @@ public function parseFile($dataFile, $color) {
}
else if ($numRecords &&
- preg_match("#^[ -]([0-9]\.[0-9]{7}E[-+][0-9]{2})[ -]([0-9]\.[0-9]{7}E[-+][0-9]{2})#", $line, $a)) {
+ 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) {
$lineSet->addLine($pl['x'], $pl['y'], $a[1], $a[2]);
View
25 GIS2/Renderer.php
@@ -195,21 +195,18 @@ public function polar2image($polarCoordinate, $direction) {
*/
public function render($lineSets) {
if ($this->min == false || $this->max == false) {
- $this->min = array(
- 'x' => 0,
- 'y' => 0
- );
-
- $this->max = array(
- 'x' => 0,
- 'y' => 0
- );
-
foreach ($lineSets as $lineSet) {
- $this->min['x'] = min($this->min['x'], $lineSet->min['x']);
- $this->min['y'] = min($this->min['y'], $lineSet->min['y']);
- $this->max['x'] = max($this->max['x'], $lineSet->max['x']);
- $this->max['y'] = max($this->max['y'], $lineSet->max['y']);
+ if ($this->min == false) {
+ $this->min['x'] = $lineSet->min['x'];
+ $this->min['y'] = $lineSet->min['y'];
+ $this->max['x'] = $lineSet->max['x'];
+ $this->max['y'] = $lineSet->max['y'];
+ } else {
+ $this->min['x'] = min($this->min['x'], $lineSet->min['x']);
+ $this->min['y'] = min($this->min['y'], $lineSet->min['y']);
+ $this->max['x'] = max($this->max['x'], $lineSet->max['x']);
+ $this->max['y'] = max($this->max['y'], $lineSet->max['y']);
+ }
}
}

0 comments on commit 647d5cc

Please sign in to comment.
Something went wrong with that request. Please try again.