[Mapbender-commits] r1946 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Jan 3 11:33:07 EST 2008
Author: christoph
Date: 2008-01-03 11:33:07 -0500 (Thu, 03 Jan 2008)
New Revision: 1946
Added:
trunk/mapbender/http/classes/class_kml_point.php
Log:
another different header
Added: trunk/mapbender/http/classes/class_kml_point.php
===================================================================
--- trunk/mapbender/http/classes/class_kml_point.php (rev 0)
+++ trunk/mapbender/http/classes/class_kml_point.php 2008-01-03 16:33:07 UTC (rev 1946)
@@ -0,0 +1,77 @@
+<?php
+/**
+ * @link http://www.mapbender.org/index.php/class_wmc.php
+ * @copyright 2002 CCGIS
+ * @license http://opensource.org/licenses/gpl-license.php
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+require_once("../classes/class_mb_exception.php");
+require_once("../classes/class_kml_geometry.php");
+
+/**
+ * Represents a point, consisting of a single point geometry.
+ *
+ * @package KML
+ */
+class KMLPoint extends KMLGeometry {
+
+ /**
+ * @param string the content of the geometry tag of a KML. Note: KML 2.2 uses a
+ * comma separated list, while KML OWS uses the GML syntax with
+ * blanks as separators
+ */
+ public function __construct ($geometryString) {
+ //TODO: parameter validation and exception handling
+
+ // KML 2.2
+ if (preg_match("/,/", $geometryString)) {
+ $aPoint = explode(",", $geometryString);
+ // ignore altitude
+ $this->point = array("x" => $aPoint[0], "y" => $aPoint[1]);
+ }
+ else {
+ $aPoint = explode(" ", $geometryString);
+ // ignore altitude
+ $this->point = array("x" => $aPoint[0], "y" => $aPoint[1]);
+ }
+ }
+
+ /**
+ * @return string a string representation of the object, currently geoJSON.
+ */
+ public function __toString() {
+ return $this->toGeoJSON();
+ }
+
+ /**
+ * @return string a geoJSON string representation of the object.
+ */
+ public function toGeoJSON () {
+ $str = "";
+ if ($this->point !== null) {
+ $str .= "{\"type\": \"Point\", \"coordinates\": [".$this->point["x"].",".$this->point["y"]."]}";
+ }
+ else {
+ $e = new mb_exception("KMLPoint: toGeoJSON: this point is null.");
+ }
+ return $str;
+ }
+
+ /**
+ * @var float[] an associative array, with "x", and "y" being float values.
+ */
+ private $point;
+}
+?>
\ No newline at end of file
Property changes on: trunk/mapbender/http/classes/class_kml_point.php
___________________________________________________________________
Name: svn:keywords
+ HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
More information about the Mapbender_commits
mailing list