[Mapbender-commits] r1636 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Aug 8 11:32:31 EDT 2007
Author: christoph
Date: 2007-08-08 11:32:31 -0400 (Wed, 08 Aug 2007)
New Revision: 1636
Modified:
trunk/mapbender/http/classes/class_bbox.php
Log:
php5 oo approach
Modified: trunk/mapbender/http/classes/class_bbox.php
===================================================================
--- trunk/mapbender/http/classes/class_bbox.php 2007-08-08 14:26:34 UTC (rev 1635)
+++ trunk/mapbender/http/classes/class_bbox.php 2007-08-08 15:32:31 UTC (rev 1636)
@@ -1,6 +1,6 @@
<?php
# $Id$
-# http://www.mapbender.org/index.php/Mod_treefolder2.php
+# http://www.mapbender.org/index.php/
# Copyright (C) 2002 CCGIS
#
# This program is free software; you can redistribute it and/or modify
@@ -45,21 +45,21 @@
/**
* computes a new point with the minimal coordinates of this point and $point
*/
- function min ($point) {
- if ($this->epsg == $point->epsg) {
- if ($this->isWestOf($point)) {
- $minx = $this->x;
+ static function min ($point1, $point2) {
+ if ($point1->epsg == $point2->epsg) {
+ if ($point1->isWestOf($point2)) {
+ $minx = $point1->x;
}
else {
- $minx = $point->x;
+ $minx = $point2->x;
}
- if ($this->isSouthOf($point)) {
- $miny = $this->y;
+ if ($point1->isSouthOf($point2)) {
+ $miny = $point1->y;
}
else {
- $miny = $point->y;
+ $miny = $point2->y;
}
- return new Mapbender_point($minx, $miny, $this->epsg);
+ return new Mapbender_point($minx, $miny, $point1->epsg);
}
else {
$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
@@ -69,21 +69,21 @@
/**
* computes a new point with the maximal coordinates of this point and $point
*/
- function max ($point) {
- if ($this->epsg == $point->epsg) {
- if ($this->isWestOf($point)) {
- $maxx = $point->x;
+ static function max ($point1, $point2) {
+ if ($point1->epsg == $point2->epsg) {
+ if ($point1->isWestOf($point2)) {
+ $maxx = $point2->x;
}
else {
- $maxx = $this->x;
+ $maxx = $point1->x;
}
- if ($this->isSouthOf($point)) {
- $maxy = $point->y;
+ if ($point1->isSouthOf($point2)) {
+ $maxy = $point2->y;
}
else {
- $maxy = $this->y;
+ $maxy = $point1->y;
}
- return new Mapbender_point($maxx, $maxy, $this->epsg);
+ return new Mapbender_point($maxx, $maxy, $point1->epsg);
}
else {
$e = new mb_exception("Mapbender_point: cannot process min with different EPSG codes");
@@ -122,8 +122,8 @@
}
}
- function toString() {
- return "(" . $this->x . "," . $this->y . "," . $this->epsg . ")";
+ function __toString() {
+ return (string) "(" . $this->x . "," . $this->y . "," . $this->epsg . ")";
}
}
@@ -155,26 +155,40 @@
}
/**
- * Computes a new bounding box, this bbox UNION $bbox
+ * Computes a new bounding box, bbox1 UNION bbox2
*/
- function union ($bbox) {
- if ($this->isValid()) {
- if ($bbox != null && $bbox->isValid()) {
- if ($this->epsg == $bbox->epsg) {
- return new Mapbender_bbox($this->min->min($bbox->min), $this->max->max($bbox->max), $this->epsg);
+ static function union ($bboxArray) {
+ if (count($bboxArray) == 1) {
+ return array_pop($bboxArray);
+ }
+ elseif (count($bboxArray) >= 2) {
+
+ $bbox1 = array_pop($bboxArray);
+ $bbox2 = Mapbender_bbox::union($bboxArray);
+
+ if (!($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
+ $e = new mb_notice("Mapbender_bbox: union: both parameters invalid!");
+ return null;
+ }
+ elseif (!($bbox1 != null && $bbox1->isValid()) && ($bbox2 != null && $bbox2->isValid())) {
+ $e = new mb_notice("Mapbender_bbox: union: first parameter invalid!");
+ return $bbox2;
+ }
+ elseif (($bbox1 != null && $bbox1->isValid()) && !($bbox2 != null && $bbox2->isValid())) {
+ $e = new mb_notice("Mapbender_bbox: union: second parameter invalid!");
+ return $bbox1;
+ }
+ else {
+ if ($bbox1->epsg == $bbox2->epsg) {
+ return new Mapbender_bbox(Mapbender_point::min($bbox1->min, $bbox2->min), Mapbender_point::max($bbox1->max, $bbox2->max), $bbox1->epsg);
}
else {
- $e = new mb_exception("mapbender_bbox: cannot process union with different EPSG codes");
+ $e = new mb_exception("Mapbender_bbox: cannot process union with different EPSG codes");
}
}
- else {
- $e = new mb_notice("mapbender_bbox: union: second parameter not a bbox, returning first bbox");
- return new Mapbender_bbox($this->min, $this->max, $this->epsg);
- }
}
- if ($bbox != null && $bbox->isValid()) {
- $e = new mb_notice("mapbender_bbox: union: first parameter not a bbox, returning second bbox");
- return $bbox;
+ else {
+ $e = new mb_exception("Mapbender_bbox: Invalid parameter (Not an array)!");
}
return null;
}
@@ -203,8 +217,8 @@
return false;
}
- function toString() {
- return "[" . $this->min->toString() . $this->max->toString() . " " . $this->epsg . "]";
+ function __toString() {
+ return (string) "[" . $this->min . $this->max . " " . $this->epsg . "]";
}
}
?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list