[Mapbender-commits] r1701 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Oct 2 09:00:38 EDT 2007


Author: christoph
Date: 2007-10-02 09:00:37 -0400 (Tue, 02 Oct 2007)
New Revision: 1701

Removed:
   trunk/mapbender/http/classes/class_gml.php
Log:
obsolete version of gml class; use class_gml2.php instead

Deleted: trunk/mapbender/http/classes/class_gml.php
===================================================================
--- trunk/mapbender/http/classes/class_gml.php	2007-10-02 12:58:38 UTC (rev 1700)
+++ trunk/mapbender/http/classes/class_gml.php	2007-10-02 13:00:37 UTC (rev 1701)
@@ -1,356 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/class_gml.php
-# 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.
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
-require_once(dirname(__FILE__)."/class_mb_exception.php");
-require_once(dirname(__FILE__)."/class_gmlMember.php");
-require_once(dirname(__FILE__)."/class_geomObj.php");
-require_once(dirname(__FILE__)."/class_geomColl.php");
-
-class gml{
-	/*
-	* Class variables:
-	*/
-	var $bbox = array();		
-	var $width;
-	var $height;
-	var $gml;
-	var $lineColor = array(255, 0, 0);
-	var $lineThickness = 3;
-	var $textColor = array(0, 0, 0);
-
-	var $cnt_gml;
-	var $geomColl = array();	
-
-	var $pointSingle = array("GML:POINT");
-	var $lineSingle = array("GML:LINESTRING");
-	var $polygonSingle = array("GML:POLYGON");
-	var $multi = array("GML:MULTIPOINT", "GML:MULTILINESTRING", "GML:MULTIPOLYGON");
-	var $tagList = array();
-	
-	
-	function setImageWidth($w) {
-		$this->width = $w;
-	}
-	function setImageHeight($h) {
-		$this->height = $h;
-	}
-	function setLineThickness($t) {
-		$this->lineThickness = $t;
-	}
-	function setLineColor($c) {
-		$this->lineColor = $c;
-	}
-	function setTextColor($c) {
-		$this->textColor = $c;
-	}
-	function setBBox($gmlIndex, $b) {
- 		$this->bbox[$gmlIndex] = explode(",", $b);
-	}
-	
-	function gml() {
- 		$this->cnt_gml = -1;
-		$this->linethickness = 1;
-	}
-
-	function addGmlList($gmlString, $separator) {
-		$gmlArray = explode($separator, $gmlString);
-
-		$this->addGml($gmlArray);
-	}
-
-	function addGml($gmlArray){
-		
-		for ($i=0; $i<count($gmlArray); $i++) {
- 			$this->cnt_gml++;
- 			$this->gml[$this->cnt_gml] = $gmlArray[$i];
-		
-			#parseBbox will calculate a bbox that delivers 
-			#some output for testing.
-			#uncomment the following line if there is no bbox 
-			#and you want to test png output
-			#otherwise, you have to set a bbox with setBbox
-			#$this->parseBbox($i, $gmlArray[$i]);
-		
-			$this->geomColl[$this->cnt_gml] = new geomColl();
-			$this->parseGml($i);
-		}
-	}
-	
-
-	function getBBox($i) {
-		return $this->bbox[$i];
-	}
-	
-	function getGml($i) {
-		return $this->gml[$i];
-	}
-	
-	
-	function getAllGeomColl(){
- 		return $this->geomColl;
-	}
-
-	function getGeomColl($gmlIndex){
- 		return $this->geomColl[$gmlIndex];
-	}
-
-
-	function parseGml($index){
-		$data = preg_replace("/&/", "&amp;", $this->gml[$index]);
-
-		$this->tagList = array_merge($this->multi, $this->pointSingle, $this->lineSingle, $this->polygonSingle);
-		
-		$parser = xml_parser_create();
-		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
-		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
-		xml_parser_set_option($parser,XML_OPTION_TARGET_ENCODING,CHARSET);
-		xml_parse_into_struct($parser,$data,$values,$tags);
-			$code = xml_get_error_code ($parser);
-		if ($code) {
-			$line = xml_get_current_line_number($parser); 
-			$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
-		}
-		xml_parser_free($parser);
-
-		$item = -1;
-		$cnt_el = 1;
-		$geom = false;
-		$foundGeom = false;
-		$typeset=false;
-		$member=false;
-		
-	
-		foreach ($values as $element) {
-			if(mb_strtoupper($element['tag']) == mb_strtoupper("gml:featureMember") && $element['type'] == "open"){
-				$member = true;
-			}
-			
-			if (in_array(mb_strtoupper($element['tag']),$this->tagList) && $element['type'] == "open" && $member==true && $geom==false && $typeset==false) {
-				$this->geomColl[$index]->addGeometryMember($element['tag']);
-				$typeset=true;
-			}
-
-			if(in_array(mb_strtoupper($element['tag']),$this->pointSingle) && $element['type'] == "open" && $typeset==true){
-				$foundGeom = true;
-				$geom = true;
-				$this->geomColl[$index]->addPoint();
-			}
-			if(in_array(mb_strtoupper($element['tag']),$this->lineSingle) && $element['type'] == "open" && $typeset==true){
-				$foundGeom = true;
-				$geom = true;
-				$this->geomColl[$index]->addLine();
-			}
-			if(in_array(mb_strtoupper($element['tag']),$this->polygonSingle) && $element['type'] == "open" && $typeset==true){
-				$foundGeom = true;
-				$geom = true;
-				$this->geomColl[$index]->addPolygon();
-			}
-
-			if(mb_strtoupper($element['tag']) == mb_strtoupper("gml:coordinates") && $geom == true){
-				$myGeom = $this->prepareCoordinates($element['value']);
-				$coord = explode(",",$myGeom);
-				for($i=0;$i<count($coord)-1; $i += 2){
-					$coordinates = array($coord[$i], $coord[$i+1]);
-					$this->geomColl[$index]->addCoordinates($coordinates);
-				}
-				
-			}
-			if(mb_strtoupper($element['tag']) == mb_strtoupper("label")){
-				$this->geomColl[$index]->addLabel($element['value']);
-			}
-			
-			if ($foundGeom == true && $geom == false && mb_substr($element['tag'], 0, 4) != "gml:" && isset($element['value'])) {
-				$this->geomColl[$index]->addAttribute($element['tag'], $element['value']);
-			}
-			
-			if((in_array(mb_strtoupper($element['tag']),$this->pointSingle) 
-					|| in_array(mb_strtoupper($element['tag']),$this->lineSingle) 
-					|| in_array(mb_strtoupper($element['tag']),$this->polygonSingle)) 
-				&& $element['type'] == "close"){
-				
-				$geom = false;
-			}
-			if(mb_strtoupper($element['tag']) == mb_strtoupper("gml:featureMember") && $element['type'] == "close"){
-				$member = false;
-				$foundGeom = false;
-				$typeset=false;
-			}
-		}
-			 
-	}
-	
-
-	// if there is no bbox given by setbbox, this funtion finds lowest and highest x- & y-coordinates 
-	// and sets the bbox according to these values 
-	// if found it very useful for testing the png output, but now it may be obsolete
-	function parseBbox($gmlIndex, $gml){
-		$data = preg_replace("/&/", "&amp;", $gml);
-
-		$parser = xml_parser_create();
-		xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
-		xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
-		xml_parse_into_struct($parser,$data,$values,$tags);
-			$code = xml_get_error_code ($parser);
-		if ($code) {
-			$line = xml_get_current_line_number($parser); 			
-			$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
-		}
-		xml_parser_free($parser);
-
-		$boundingbox = false;
-		$cnt_member = false;
-		$min_x = "";
-		$min_y = "";
-		$max_x = "";
-		$max_y = "";
-		
-		foreach ($values as $element) {
-			if(mb_strtoupper($element['tag']) == mb_strtoupper("gml:featureMember") && $element['type'] == "open"){
-				$cnt_member=true;
-			}
-			if((in_array(mb_strtoupper($element['tag']),$this->pointSingle) 
-				|| in_array(mb_strtoupper($element['tag']),$this->lineSingle) 
-				|| in_array(mb_strtoupper($element['tag']),$this->polygonSingle)) && $element['type'] == "open"){
-				$boundingbox=true;
-			}
-
-			if(mb_strtoupper($element['tag']) == mb_strtoupper("gml:coordinates") && $boundingbox == true){
-				$myGeom = $this->prepareCoordinates($element['value']);
-				$coord = explode(",",$myGeom);
-				for($i=0;$i<count($coord)-1; $i += 2){
-					if ($coord[$i] < $min_x || !$min_x) {
-						$min_x = $coord[$i];
-					}
-					if ($coord[$i] > $max_x || !$max_x) {
-						$max_x = $coord[$i]; 
-					}
-					if ($coord[$i+1] < $min_y || !$min_y) {
-						$min_y = $coord[$i+1]; 
-					}
-					if ($coord[$i+1] > $max_y || !$max_y) {
-						$max_y = $coord[$i+1]; 
-					}
-				}
-			}
-
-			if((in_array(mb_strtoupper($element['tag']),$this->pointSingle) 
-				|| in_array(mb_strtoupper($element['tag']),$this->lineSingle) 
-				|| in_array(mb_strtoupper($element['tag']),$this->polygonSingle)) && $element['type'] == "close"){
-				$boundingbox = false;
-			}
-			if(mb_strtoupper($element['tag']) == mb_strtoupper("gml:featureMember") && $element['type'] == "close"){
-				$cnt_member=false;
-			}
-		}
-		$this->bbox[$gmlIndex][0] = $min_x;
-		$this->bbox[$gmlIndex][1] = $min_y;
-		$this->bbox[$gmlIndex][2] = $max_x;
-		$this->bbox[$gmlIndex][3] = $max_y;
-	}
-	
-	function prepareCoordinates($strCoords){	
-		$ret = preg_replace("/\s/i", ",", trim($strCoords));		
-		return $ret;
-	}
-	
-	function png ($gmlIndex, $label){
-		$image = imagecreate($this->width,$this->height);
-		$transparent = ImageColorAllocate($image,255,255,255);
-		ImageFilledRectangle($image,0,0,$this->width,$this->height,$transparent);
-		ImageColorTransparent ($image , $transparent);
-		
-		$line = imagecolorallocate($image, $this->lineColor[0], $this->lineColor[1], $this->lineColor[2]);
-		if($this->lineColor != $this->textColor){
-			$text = imagecolorallocate($image, $this->textColor[0], $this->textColor[1], $this->textColor[2]);
-		} else{
-			$text = $line;	
-		}
-		imagesetthickness($image, $this->lineThickness);
-		
-		$image = $this->geomColl[$gmlIndex]->addToPng($image, $this->bbox[$gmlIndex], $this->width, $this->height, $line, $text, $label);
-		 
-		return $image;
-	}
-	
-	function gml2JavaObj($gmlIndex) {
-		$javaObjStr = "";
-		$javaObjStr .= $this->geomColl[$gmlIndex]->getJavaObjStr($this->bbox[$gmlIndex], $this->width, $this->height);
-		return $javaObjStr;
-	}
-
-	
-}
-
-
-#so far, this class has only been tested with gmls generated by UMN map server
-
-#load gml files like this
-#$data[0] = implode("", file("fluesse.xml"));
-#$data[1] = implode("", file("staedte.xml"));
-#$data[2] = implode("", file("plz.xml"));
-
-#initiate gml object like this
-#$D = new gml();
-#$D->parseGml();
-#you can add gml objects by passing a string of gmls...  
-#$separator = "___";
-#$list = $data[0] . $separator . $data[1] . $separator . $data[2];
-#$D->addGmlList($list, $separator);
- 
-# .. or alternatively by passing an array of gmls
-#$D->addGml($data);
-
-#print_r($D->getBBox(0));
-
-# you have to set a bbox for each gml
-# if no bbox is set, png output will not work
-#$D->setBBox(0, "3399409.885263,5566197.180021,3410613.307859,5573006.265254");
-
-#you can set the parameters for graphical output like this
-#$D->setImageWidth(640);
-#$D->setImageHeight(480);
-#$D->setLineThickness(1);
-#$D->setLineColor(array(125, 40, 25));
-
-#retrieve all geometries of all gmls like this
-#$data = $D->getAllGeomColl();
-
-#this is the way to get a single feature member
-#$data = $D->getGeomColl(2)->getMember(3)->getGeomObj(2);
-
-#if you want the data structure of a single gml, try this
-#$data = $D->getGeomColl(1);
-
-#this is how the data structure looks like (view source)
-#print_r($data);
-
-# if your gmls have points, you can add labels 
-# from the attributes of the gml for png output  
-#$data = $D->getGeomColl(2);
-#$member = $data->getMember(0);
-#$keys = $member->getAllAttributeKeys();
-#header("Content-type: image/png");
-#imagepng($D->png(2, $keys[3]));
-
-#alternatively, you can display the png without labels
-#imagepng($D->png(0, ""));
-#imagepng($D->png(1, ""));
-#check the subclasses for further documentation
-
-?>
\ No newline at end of file



More information about the Mapbender_commits mailing list