svn commit: r47 - trunk/mapbender/http/classes/class_gmlMember.php

uli at osgeo.org uli at osgeo.org
Thu Apr 13 16:58:31 EDT 2006


Author: uli
Date: 2006-04-13 20:58:30+0000
New Revision: 47

Added:
   trunk/mapbender/http/classes/class_gmlMember.php

Log:
import Mapbender source without history

Added: trunk/mapbender/http/classes/class_gmlMember.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_gmlMember.php?view=auto&rev=47
==============================================================================
--- (empty file)
+++ trunk/mapbender/http/classes/class_gmlMember.php	2006-04-13 20:58:30+0000
@@ -0,0 +1,175 @@
+<?php
+# $Id: class_gmlMember.php,v 1.7 2005/09/13 16:23:31 c_baudson Exp $
+# $Header: /cvsroot/mapbender/mapbender/http/classes/class_gmlMember.php,v 1.7 2005/09/13 16:23:31 c_baudson Exp $
+# Copyright (C) 2002 CCGIS 
+#
+# 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.
+
+class gmlMember { 
+	var $cnt_item;
+	var $memberType;
+	var $attributes = array();
+	var $geometry = array();
+	
+	function gmlMember ($type) {
+		$this->cnt_item = -1;
+		$this->setMemberType($type);
+	}
+
+	function setAttribute($attribTag, $attrib) {
+		$this->attributes[$attribTag] = $attrib;
+	}
+
+	function setMemberType($type) {
+		$this->memberType = $type;
+	}
+
+	function addPolygon () {
+		$this->cnt_item++;
+		$this->geometry[$this->cnt_item] = new _polygon();
+	}
+
+	function addLine () {
+		$this->cnt_item++;
+		$this->geometry[$this->cnt_item] = new _line();
+	}
+	
+	function addPoint () {
+		$this->cnt_item++;
+		$this->geometry[$this->cnt_item] = new _point();
+	}
+	
+#	function addCoordinates ($coord, $pos) {
+#		$this->geometry[$this->cnt_item]->addCoordinates($coord, $pos);
+#	}
+
+	function addCoordinates ($coord) {
+		$this->geometry[$this->cnt_item]->addCoordinates($coord);
+	}
+
+	function addLabel($label) {
+		$this->geometry[$this->cnt_item]->setLabel($label);
+	}
+
+	function addToPng($image, $bbox, $width, $height, $line, $text, $label) {
+		$pos = array();
+		$pos_next = array();
+
+		for ($j=0; $j < count($this->geometry); $j++) {
+				
+				$coord = $this->geometry[$j]->getCoordinates();
+
+				if ($this->geometry[$j]->getType() == "point") {
+				$topOffset = imagefontheight(2);
+				$pos = $this->makeRealWorld2mapPos($bbox, $width, $height, $coord["x"][0],$coord["y"][0]);
+				imagestring ($image, 2,$pos["x"], ($pos["y"] - $topOffset), $this->getAttribute($label), $text);
+				imageellipse($image, $pos["x"], $pos["y"], 5, 5, $line);
+				}
+				else { 
+				for($k=0; $k < count($coord["x"])-1; $k++){
+					$pos = $this->makeRealWorld2mapPos($bbox, $width, $height, $coord["x"][$k],$coord["y"][$k]);
+					$pos_next = $this->makeRealWorld2mapPos($bbox, $width, $height, $coord["x"][$k+1],$coord["y"][$k+1]);			  		
+					imageline($image,$pos["x"],$pos["y"],$pos_next["x"],$pos_next["y"],$line);
+
+				} 
+		} 
+		return $image;
+	}
+	}
+
+	function getAllGeom() {
+		return $this->geometry;
+	}
+
+	function getAllAttributes() {
+		return $this->attributes;
+	}
+
+	function getAllAttributeKeys() {
+		return array_keys($this->attributes);
+	}
+
+	function getAttribute($name) {
+		if (array_key_exists($name, $this->attributes)) {
+			return $this->attributes["$name"];
+		}
+		else {
+			return "";
+		}
+	}
+
+	function getGeomObj($index) {
+		return $this->geometry[$index];
+	}
+
+	function getMemberType() {
+		return $this->memberType;
+	}	
+
+	function getMemberSize() {
+		return count($this->geometry);
+	}	
+
+	function getGeomSize($i) {
+		return count($this->geometry[$i]);
+	}	
+
+
+	function getJavaObjStr($bbox, $width, $height) {
+		$str = "";
+		for ($j=0; $j < count($this->geometry); $j++) {
+			
+			$coord = $this->geometry[$j]->getCoordinates();
+
+			$str .= "register_D('" . $this->geometry[$j]->getType() . "');";
+			
+			if ($this->geometry[$j]->getType() == "point" && $this->geometry[$j]->getLabel()) {
+				$str .= "D[D.length-1].label = '" . $this->geometry[$j]->getLabel() . "';";
+			}		
+		
+			for($k=0; $k < count($coord["x"]); $k++){
+				$pos = $this->makeRealWorld2mapPos($bbox, $width, $height,$coord["x"][$k],$coord["y"][$k]);				
+				$str .= "D[D.length-1].x[D[D.length-1].x.length] = Math.round(" . $coord["x"][$k] . " * 100)/100;";
+				$str .= "D[D.length-1].y[D[D.length-1].y.length] = Math.round(" . $coord["y"][$k] . " * 100)/100;";				
+			}
+			$str .= "D[D.length-1].complete = true;";
+		}
+		return $str;
+	}
+
+	function makeRealWorld2mapPos($bbox, $width, $height, $x,$y){
+		$minx = $bbox[0];
+		$miny = $bbox[1];
+		$maxx = $bbox[2];
+		$maxy = $bbox[3];
+		$xtentx = $maxx - $minx;
+		$xtenty = $maxy - $miny;
+		if ($xtenty != 0 && $xtentx != 0) {
+			
+			$posx = (($x - $minx) / $xtentx) * $width;
+			$posy = (($maxy - $y) / $xtenty) * $height;
+
+			$pos = array("x" => $posx, "y" => $posy);
+			return $pos;
+		}
+		if ($xtenty == 0 || $xtentx == 0) {
+			$mb_exception = new mb_exception("Division by zero in makeRealWorld2mapPos");
+			return 0;
+		}
+	}
+
+
+}
+?>
\ No newline at end of file




More information about the Mapbender_commits mailing list