[Mapbender-commits] r6271 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jun 15 09:15:02 EDT 2010
Author: verenadiewald
Date: 2010-06-15 13:15:02 +0000 (Tue, 15 Jun 2010)
New Revision: 6271
Modified:
trunk/mapbender/http/classes/class_bbox.php
trunk/mapbender/http/classes/class_gml.php
trunk/mapbender/http/classes/class_gml_factory.php
trunk/mapbender/http/classes/class_gml_feature.php
trunk/mapbender/http/classes/class_gml_feature_collection.php
trunk/mapbender/http/classes/class_gml_geometry.php
trunk/mapbender/http/classes/class_gml_line.php
trunk/mapbender/http/classes/class_gml_point.php
trunk/mapbender/http/classes/class_point.php
Log:
added new functionality for getting bbox of a featureCollection
Modified: trunk/mapbender/http/classes/class_bbox.php
===================================================================
--- trunk/mapbender/http/classes/class_bbox.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_bbox.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -55,7 +55,7 @@
$max = $param1; // is a Mapbender_point
$epsg = $param2; // is an EPSG code like "EPSG:4326"
- if ($min->isWestOf($max) && $min->isSouthOf($max)) {
+ if (($min->isWestOf($max) && $min->isSouthOf($max)) || $min->equals($max)) {
if ($min->epsg == $max->epsg && $min->epsg == $epsg) {
$this->min = $min;
$this->max = $max;
@@ -167,5 +167,9 @@
function __toString() {
return (string) "[" . $this->min . $this->max . " " . $this->epsg . "]";
}
+
+ function toJson() {
+ return (string) "[" . $this->min->x . ",". $this->min->y . "," . $this->max->x . "," . $this->max->y . "]";
+ }
}
?>
Modified: trunk/mapbender/http/classes/class_gml.php
===================================================================
--- trunk/mapbender/http/classes/class_gml.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_gml.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -46,6 +46,20 @@
$myGmlObj = $gmlFactory->createFromGeoJson($geoJson);
return $myGmlObj->toGml();
}
+
+ /**
+ *
+ *
+ *
+ *
+ *
+ */
+ public function getBbox () {
+ if (is_null($this->featureCollection)) {
+ return null;
+ }
+ return $this->featureCollection->getBbox();
+ }
}
?>
\ No newline at end of file
Modified: trunk/mapbender/http/classes/class_gml_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_factory.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_gml_factory.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -277,6 +277,6 @@
$e = new mb_exception($e);
return null;
}
- }
+ }
}
?>
Modified: trunk/mapbender/http/classes/class_gml_feature.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_feature.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_gml_feature.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -73,6 +73,13 @@
return $str;
}
+
+ public function getBbox () {
+ if (is_null($this->geometry) || $this->geometry === false) {
+ return null;
+ }
+ return $this->geometry->getBbox();
+ }
}
?>
\ No newline at end of file
Modified: trunk/mapbender/http/classes/class_gml_feature_collection.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_feature_collection.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_gml_feature_collection.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -20,6 +20,7 @@
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
require_once(dirname(__FILE__)."/../classes/class_gml_feature.php");
+require_once(dirname(__FILE__)."/../classes/class_bbox.php");
class FeatureCollection {
@@ -51,5 +52,26 @@
$str .= "]}";
return $str;
}
+
+ /**
+ *
+ *
+ *
+ *
+ *
+ */
+ public function getBbox () {
+ if (!is_array($this->featureArray) || count($this->featureArray) === 0) {
+ return null;
+ }
+ $bBoxArray = array();
+ for ($i = 0; $i < count($this->featureArray);$i++) {
+ $currentBbox = $this->featureArray[$i]->getBbox();
+ if(!is_null($currentBbox)) {
+ $bBoxArray[] = $currentBbox;
+ }
+ }
+ return Mapbender_bbox::union($bBoxArray);
+ }
}
?>
\ No newline at end of file
Modified: trunk/mapbender/http/classes/class_gml_geometry.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_geometry.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_gml_geometry.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -30,6 +30,8 @@
abstract public function toGeoJSON ();
+ //abstract public function getBbox ();
+
public $srs;
public $latLonSrs = array(
Modified: trunk/mapbender/http/classes/class_gml_line.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_line.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_gml_line.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -20,6 +20,7 @@
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
require_once(dirname(__FILE__)."/../classes/class_gml_geometry.php");
+require_once(dirname(__FILE__)."/../classes/class_bbox.php");
class GMLLine extends GmlGeometry {
@@ -91,5 +92,18 @@
}
return $str;
}
+
+ public function getBbox () {
+ $bboxArray = array();
+ for ($i = 0; $i < count($pointArray); $i++) {
+ $p = new Mapbender_point(
+ $this->pointArray[$i]["x"],
+ $this->pointArray[$i]["y"],
+ $this->srs
+ );
+ $bboxArray[]= new Mapbender_bbox($p, $p, $this->srs);
+ }
+ return Mapbender_bbox::union($bboxArray);
+ }
}
?>
\ No newline at end of file
Modified: trunk/mapbender/http/classes/class_gml_point.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_point.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_gml_point.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -20,6 +20,7 @@
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
require_once(dirname(__FILE__)."/../classes/class_json.php");
require_once(dirname(__FILE__)."/../classes/class_gml_geometry.php");
+require_once(dirname(__FILE__)."/../classes/class_bbox.php");
class GMLPoint extends GmlGeometry {
@@ -69,5 +70,14 @@
}
return $str;
}
+
+ public function getBbox () {
+ $p = new Mapbender_point(
+ $this->point["x"],
+ $this->point["y"],
+ $this->srs
+ );
+ return new Mapbender_bbox($p, $p, $this->srs);
+ }
}
?>
\ No newline at end of file
Modified: trunk/mapbender/http/classes/class_point.php
===================================================================
--- trunk/mapbender/http/classes/class_point.php 2010-06-15 12:10:51 UTC (rev 6270)
+++ trunk/mapbender/http/classes/class_point.php 2010-06-15 13:15:02 UTC (rev 6271)
@@ -105,6 +105,16 @@
}
}
+ function equals($point) {
+ if ($this->x === $point->x &&
+ $this->y === $point->y &&
+ $this->z === $point->z &&
+ $this->epsg === $point->epsg
+ ) {
+ return true;
+ }
+ }
+
function isWestOf($point) {
if ($this->x < $point->x) {
return true;
More information about the Mapbender_commits
mailing list