[Mapbender-commits] r1132 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Feb 22 11:55:53 EST 2007


Author: christoph
Date: 2007-02-22 11:55:53 -0500 (Thu, 22 Feb 2007)
New Revision: 1132

Removed:
   trunk/mapbender/http/javascripts/geometry.js
Log:
* improved modularity
* inheritance (new class List)
* separation of public, privileged and private member data
* moved code to map.php

Deleted: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js	2007-02-22 16:54:09 UTC (rev 1131)
+++ trunk/mapbender/http/javascripts/geometry.js	2007-02-22 16:55:53 UTC (rev 1132)
@@ -1,898 +0,0 @@
-/* 
-* $Id: mod_geometryArray.js 776 2006-09-29 08:14:28Z christoph $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
-// http://www.mapbender.org/index.php/GeometryArray.js
-
-
-var nameGeometryArray = "GeometryArray";
-var nameMultiGeometry = "MultiGeometry";
-var nameGeometry = "Geometry";
-
-var geomType = (
-	function () {
-		function constructorFunction(){
-			this.polygon = "polygon";
-			this.line = "line";
-			this.point = "point";
-		}
-		return new constructorFunction();
-	}
-) ();
-
-// ----------------------------------------------------------------------------------------------------
-// GeometryArray
-// ----------------------------------------------------------------------------------------------------
-
-function GeometryArray(){
-
-	this.count = function(){ // public
-		return this.m.length;
-	}
-
-	this.union = function(geomArray){ // public
-		for (var i=0; i < geomArray.count(); i++) this.appendMember(geomArray.get(i));
-	}
-	
-	this.get = function(i){ // public
-		i = this.getIndex(i);
-		if (i != null) return this.m[i];
-		return false;
-	}
-
-	this.getGeometry = function(i,j){ // public
-		return this.get(i).get(j);
-	}
-
-	this.getPoint = function(i,j,k){ // public
-		return this.get(i).get(j).get(k);
-	}
-
-	this.addMember = function(geomType){ // public
-		this.m[this.m.length] = new MultiGeometry(geomType);   
-	}
-	
-	this.appendMember = function(aMember){ // public
-		this.m[this.m.length] = cloneObject(aMember);
-	}
-
-	this.del = function(i){ // public
-		i = this.getIndex(i);
-		for(var z = i; z < this.m.length - 1; z++){
-			this.m[z] = this.m[z+1];
-		}
-		this.m.length -= 1;
-	}
-
-	this.findMultiGeometry = function(m) { // public
-		var a = [];
-		for (var i=0; i < this.count(); i++) {
-			if (this.get(i).equals(m)) a.push(i);
-		}
-		return a;
-	}
-	
-	this.delGeometry = function(i,j){ // public
-		var res = this.get(i).del(j);
-		if (res == false) this.del(i);
-	}
-	
-	this.delPoint = function (i,j,k){ // public
-		var res = this.get(i).delPoint(j,k);
-		if (res == false) this.del(i);
-	}
-	
-	this.close = function(){ // public
-		this.get(-1).get(-1).close();
-		if (this.get(-1).get(-1).count() == 0) {this.get(-1).del(-1);}
-		if (this.get(-1).count() == 0) {this.del(-1);}
-	}
-
-	this.combineToMultiGeometry = function(){
-		if (this.count() == 0) return true;
-		var geomType = this.get(0).geomType;
-		for (var i = 1 ; i < this.count() ; i++) {
-			if (geomType != this.get(i).geomType) return false;
-		}
-		// TODO:combine geometries
-		return true;
-	}
-
-	this.delAllPointsLike = function(point){ // public
-		var finished = false;
-		while (finished==false){
-			finished = true;
-			for (var i = 0 ; finished == true && i < this.count() ; i++){
-				for (var j = 0 ; finished == true && j < this.get(i).count() ; j++){
-					for (var k = 0 ; finished == true && k < this.get(i).get(j).count() ; k++){
-						if (this.getPoint(i,j,k).equals(point)){
-							this.delPoint(i,j,k);
-							finished = false;
-						}
-					}
-				} 
-			}
-		}
-	}
-	
-	this.updateAllPointsLike = function(oldP, newP){ // public
-		for (var i = 0; i < this.count(); i++){
-			this.get(i).updateAllPointsLike(oldP, newP);
-		}
-	}
-	
-	this.toString = function(){ // public
-		var str = "";
-		for (var i =0 ; i < this.count() ; i++){
-			str += this.get(i).toString();
-		}
-		return str;	
-	}
-
-	this.getIndex = function(i){ //private
-		if ((i >= 0 && i < this.m.length) || (i*(-1)>0 && i*(-1) <=this.m.length)){
-			if (i >= 0) return i; else return this.m.length+i;
-		}
-		else {
-			alert("exception: member index " + i + " is not valid");
-			return null;
-		}
-	}
-	this.name = nameGeometryArray;
-	this.m = [];
-}
-
-// ----------------------------------------------------------------------------------------------------
-// MultiGeometry
-// ----------------------------------------------------------------------------------------------------
-
-function MultiGeometry(geomType){
-
-	this.count = function(){ // public
-		return this.g.length;
-	}
-
-	this.get = function(i){ // public
-		i = this.getIndex(i);
-		if (i != null) return this.g[i];
-		return false;
-	}
-
-	this.getPoint = function(j,k){ // public
-		return this.get(j).get(k);
-	}
-	
-	this.addGeometry = function(){ // public
-		this.g[this.g.length] = new Geometry(this.geomType);
-	}
-	
-	this.equals = function(multigeom) { // public
-		if (this.geomType != multigeom.geomType) return false;
-		if (this.count() != multigeom.count()) return false;
-		if (this.getTotalPointCount() != multigeom.getTotalPointCount()) return false;
-		for (var i=0; i<this.count(); i++) {
-			if (!this.get(i).equals(multigeom.get(i))) return false;
-		}
-		return true;
-	}
-	
-	this.del = function(i){ // public
-		i = this.getIndex(i);
-		if (i != null){
-			var tmpLength = this.count() - 1;
-			for (var z = i; z < tmpLength ; z ++){
-				this.g[z] = this.g[z+1];
-				this.e[z] = this.e[z+1];
-			}
-			this.g.length -= 1;
-			if (this.g.length == 0)	return false;
-		}
-		return true;
-	}
-
-	this.delPoint = function(i,j){ // public
-		var res = this.get(i).del(j);
-		if (res == false) {return this.del(i);}
-		return true;
-	}
-
-	this.emptyMember = function(){ // public
-		this.g = [];
-	}
-	
-	this.updateAllPointsLike = function(oldP, newP){ // public
-		for (var i = 0; i < this.count(); i++) this.get(i).updateAllPointsLike(oldP, newP);
-	}
-
-	this.getBBox = function(){ // public
-		var q = this.get(0).get(0);
-		var min = cloneObject(q);
-		var max = cloneObject(q);
-		for(var i=0; i<this.count();i++){
-			var pos = this.get(i).getBBox();
-			if (pos[0].x < min.x) {min.x = pos[0].x;}
-			if (pos[1].x > max.x) {max.x = pos[1].x;}
-			if (pos[1].y > max.y) {max.y = pos[1].y;}
-			if (pos[0].y < min.y) {min.y = pos[0].y;}
-		}
-		return new Array(min, max);
-	}
-	
-	this.getCenter = function(){ // public
-		var tmp = this.getBBox();
-		var x = parseFloat(tmp[0].x) + parseFloat((tmp[1].x - tmp[0].x)/2);
-		var y = parseFloat(tmp[0].y) + parseFloat((tmp[1].y - tmp[0].y)/2);
-		return new Point(x,y);
-	}
-
-	this.getTotalPointCount = function(){ // public
-		var c = 0;
-		for (var i = 0 ; i < this.count(); i++)	c += this.get(i).count();
-		return c;
-	}
-
-	this.toString = function(){ // public
-		var str = "";
-		for (var i = 0 ; i < this.count(); i++)	str += this.get(i).toString();
-		return str;
-	}
-	
-	this.getIndex = function(i){ //private
-		if ((i >= 0 && i < this.g.length) || (i*(-1)>0 && i*(-1) <=this.g.length)){
-			if (i >= 0) {return i;}	else {return this.g.length+i;}
-		}
-		else {
-			alert("exception: geometry index is not valid");
-			return null;
-		}
-	}
-
-	this.g = [];
-	this.e = new Wfs_element();
-	this.geomType = geomType;
-	this.name = nameMultiGeometry;
-}
-
-// ----------------------------------------------------------------------------------------------------
-// Geometry
-// ----------------------------------------------------------------------------------------------------
-
-function Geometry(aGeomtype){
-
-	this.count = function(){ // public
-		return this.v.length;
-	}
-
-	this.get = function(i){ // public
-		i = this.getIndex(i);
-		if (i != null){return this.v[i];}
-		return false;
-	}
-
-	this.getBBox = function(){ // public
-		var q = this.get(0);
-		var min = cloneObject(q);
-		var max = cloneObject(q);
-		
-		for (var j=0; j<this.count(); j++){
-			var pos = this.get(j);
-			if (pos.x < min.x) {min.x = pos.x;}
-			else if (pos.x > max.x) {max.x = pos.x;}
-			if (pos.y < min.y) {min.y = pos.y;}
-			else if (pos.y > max.y) {max.y = pos.y;}
-		}
-		return new Array(min, max);
-	}
-	
-	this.close = function(){
-		this.complete = true;
-		if (this.geomType == geomType.polygon){
-			if (this.count() > 0){
-				if (!this.get(0).equals(this.get(-1))) {
-					this.addPoint(this.get(0));
-				}
-			}
-		}
-	}
-	
-	this.addPointByCoordinates = function(x,y){ // public
-		this.v[this.v.length] = new Point(x,y);
-		this.updateDist();
-	}
-
-	this.addPoint = function(aPoint){ // public
-		this.v[this.v.length] = new Point(aPoint.x, aPoint.y);
-		this.updateDist();
-	}
-
-	this.addPointAtIndex = function(p,i){ // public
-		i = this.getIndex(i);
-		if (i != null){
-			for(var z = this.v.length; z > i; z--){
-				this.v[z] = this.v[z-1];
-			}
-			this.v[i] = new Point(p.x, p.y);
-			this.updateDist();
-		}
-	}
-	
-	this.del = function(i){ // public
-		i = this.getIndex(i);
-		if (i != null) {
-			var tmpLength = this.count()-1;
-			
-			for (var z = i; z < tmpLength ; z ++){
-				this.v[z] = this.v[z+1];
-			}
-			this.v.length -= 1;
-		
-			if (this.geomType == geomType.polygon){
-				if (i == tmpLength) {this.v[0] = this.v[tmpLength-1];}
-				else if (i == 0) {this.v[tmpLength-1] = this.v[0];}
-				if (this.v.length == 1){return false;}
-			}
-			this.updateDist();
-			if(this.v.length == 0) {return false;}
-			return true;
-		}
-		return false;
-	}
-	
-	this.updateGeometry = function(p, i){ // public
-		i = this.getIndex(i);
-		if ((i == 0 || i == this.count()-1) && this.geomType == geomType.polygon){
-			this.v[0] = p;
-			this.v[this.count()-1] = p;
-		}
-		else {this.v[i] = p;}
-		this.updateDist();
-	}
-	
-	this.updateAllPointsLike = function(oldP, newP){ // public
-		var len = this.count();
-		for (var i = 0; i < len ; i++){
-			if (oldP.equals(this.get(i))){
-				if (i>0 && newP.equals(this.get(i-1))){
-					this.del(i);
-					len--;
-					i--;
-				}
-				else this.updateGeometry(newP, i);
-			}
-		}
-	}
-
-	this.isComplete = function() { // public
-		return this.complete;
-	}
-	
-	this.toString = function(){ // public
-		var str = "";
-		for (var i = 0 ; i < this.count(); i++)	str += this.get(i).toString();
-		return str;
-	}
-	
-	this.equals = function(geom) { // public
-		if (this.geomType != geom.geomType) return false;
-		if (this.count() != geom.count()) return false;
-		for (var i=0; i < this.count(); i++) {
-			if (!this.get(i).equals(geom.get(i))) return false;
-		}
-		return true;
-	}
-	
-	this.getIndex = function(i){ //private
-		if ((i >= 0 && i < this.v.length) || (i*(-1)>0 && i*(-1) <=this.v.length)){
-			if (i >= 0) {return i;}	else {return this.v.length+i;}
-		}
-		else {
-			alert("exception: point index is not valid");
-			return null;
-		}
-	}
-
-	this.updateDist = function(){ //private
-		this.dist[0] = 0;		
-		this.totaldist[0] = 0;		
-		for (var i = 1 ; i < this.count(); i++){
-			this.dist[i] = this.get(i-1).dist(this.get(i));
-			this.totaldist[i] = this.totaldist[i-1] + this.dist[i];
-		}
-	}
-	this.getCurrentDist = function(numberOfDigits) { //public
-		if (typeof(numberOfDigits) == "number") {
-			return roundToDigits(this.dist[this.count()-1], numberOfDigits);
-		}
-		return this.dist[this.count()-1];
-		
-	}
-	this.getTotalDist = function(numberOfDigits) { //public
-		if (typeof(numberOfDigits) == "number") {
-			return roundToDigits(this.totaldist[this.count()-1], numberOfDigits);
-		}
-		return this.totaldist[this.count()-1];
-	}
-	
-	this.geomType = aGeomtype;
-	this.complete = false;
-	this.v = [];
-	this.dist = [];
-	this.totaldist = [];
-	this.name = nameGeometry;
-}
-
-// ----------------------------------------------------------------------------------------------------
-// Wfs_element (FIXME)
-// ----------------------------------------------------------------------------------------------------
-
-function Wfs_element(){
-
-	this.count = function(){ // public
-		return this.name.length;
-	}
-
-	this.getElementValueByName = function(elementName){ // public
-		var i = this.getElementIndexByName(elementName);
-		if (i == -1) {return false;}
-		return this.value[i];
-	}
-
-	this.getName = function(i){ // public
-		if (this.isValidElementIndex(i)) {return this.name[i];}
-		return false;
-	}
-	
-	this.getValue = function(i){ // public
-		if (this.isValidElementIndex(i)) {return this.value[i];}
-		return false;
-	}
-
-	this.setElement = function(aName, aValue){ // public
-		var i = this.getElementIndexByName(aName);
-		if (i == -1) i = this.name.length;
-		this.name[i] = aName;
-		this.value[i] = aValue;
-		return true;
-	}
-
-	this.getElementIndexByName = function(elementName){ // private
-		var arrayLength = this.name.length;
-		for (var j = 0 ; j < arrayLength ; j++){
-			if (this.name[j] == elementName) {return j;}
-		}
-		return -1;
-	}
-
-	this.isValidElementIndex = function(i){ //private
-		if (i>=0 && i<this.name.length) {return true;}
-		alert("exception: illegal element index");
-		return false;
-	}
-	
-	this.name  = [];
-	this.value = [];
-}
-
-
-// ----------------------------------------------------------------------------------------------------
-// DivTag
-// ----------------------------------------------------------------------------------------------------
-
-function DivTag (tagName, frameName, style) {
-	this.write = function (someText) {
-		if (this.exists()) {
-			this.rootNode.getElementById(this.tagName).innerHTML = someText;
-		}
-	}
-	this.clean = function () {
-		if (this.exists()) {
-			this.rootNode.getElementById(this.tagName).innerHTML = "";
-		}
-	}
-	this.exists = function () { 
-		return (this.rootNode.getElementById(this.tagName))?true:false;
-	}
-	this.create = function () {
-		if (!this.exists()) {
-			var divTag = this.rootNode.createElement("div");
-			var divTagAppended = this.rootNode.getElementsByTagName("body")[0].appendChild(divTag);
-			divTagAppended.setAttribute("id",this.tagName);
-			divTagAppended.setAttribute("style",this.style);
-		}
-		else {
-			this.clean();
-		}
-	}
-	this.checkFrame = function () {
-		if (this.frameName != "") {
-			return (typeof(window.frames[this.frameName]) != 'undefined')
-		}
-		return true;
-	}
-	
-	this.tagName = tagName;
-	this.frameName = frameName;
-	this.style = style;
-	this.rootNode = document;
-	
-
-	if (this.frameName != "") {
-		if (this.checkFrame()) {
-			this.rootNode = window.frames[this.frameName].document;
-		}
-		else {
-			// throw exception
-			alert("frame "+this.frameName+" doesn't exist.");
-		}
-	}
-
-	this.create();
-}
-
-
-// ----------------------------------------------------------------------------------------------------
-// Canvas
-// ----------------------------------------------------------------------------------------------------
-
-
-function Canvas(mapframe, tagname, style, lineWidth) {
-	
-	this.paint = function(gA) { // public
-		if (this.checkTag()) {
-			for (var q = 0; q < gA.count(); q++) {
-				var m = gA.get(q);
-				var t = m.geomType;
-				var col = m.color;
-				if (t == geomType.point)	this.drawGeometry(t,m,col);
-				else {
-					if (this.isTooSmall(m)){
-						var newMember = new MultiGeometry(geomType.point);
-						newMember.addGeometry();
-						newMember.get(-1).addPoint(m.getCenter());
-						this.drawGeometry(geomType.point,newMember,col);
-					}
-					else{
-						if(t == geomType.line) this.drawGeometry(t,m, col);
-						else if(t == geomType.polygon) this.drawGeometry(t,m,col);
-						else alert("unknown geomType");
-					}
-				}
-			}
-			this.canvas.paint();
-		}
-		else {
-			alert('div tag doesnt exist');
-		}
-	}
-	
-	this.drawGeometry = function(t,g,col){ // private
-		var mapObjInd = getMapObjIndexByName(this.mapframe);
-		width = mb_mapObj[mapObjInd].width;
-		height = mb_mapObj[mapObjInd].height;
-		for(var i=0; i < g.count(); i++){
-			if(t==geomType.point) {
-				var p = realToMap(this.mapframe,g.get(i).get(0));
-				if (p.x + this.diameter < mb_mapObj[mapObjInd].width && p.x - this.diameter > 0 &&
-					p.y + this.diameter < mb_mapObj[mapObjInd].height && p.y - this.diameter > 0) {
-					this.drawCircle(p.x-1,p.y-1,this.diameter,col);
-				}
-			}
-			else if(t==geomType.line) {
-				for (var j=0; j<g.get(i).count()-1; j++) {
-					var pq = calculateVisibleDash(realToMap(this.mapframe,g.get(i).get(j)), realToMap(this.mapframe,g.get(i).get(j+1)), width, height);
-					if (pq) {
-						this.drawLine(new Array(pq[0].x-1, pq[1].x-1),new Array(pq[0].y-1, pq[1].y-1),col);
-					}
-				}
-			}
-			else if(t==geomType.polygon) {
-				for (var j=0; j<g.get(i).count()-1; j++) {
-					var pq = calculateVisibleDash(realToMap(this.mapframe,g.get(i).get(j)), realToMap(this.mapframe,g.get(i).get(j+1)), width, height);
-					if (pq) {
-						this.drawLine(new Array(pq[0].x-1, pq[1].x-1),new Array(pq[0].y-1, pq[1].y-1),col);
-					}
-				}
-			}
-			else {
-				alert('unknown geomType ' + t);
-			}
-		}
-		var el = window.frames[this.mapframe].document.getElementById(this.tagname);
-	}
-	
-	this.isTooSmall = function(g){ // private
-		var tmp = g.getBBox();
-		var min = realToMap(this.mapframe,tmp[0]);
-		var max = realToMap(this.mapframe,tmp[1]);
-		if((Math.abs(max.x - min.x) < this.minWidth) && (Math.abs(max.y - min.y) < this.minWidth)) return true;
-		return false;
-	}
-	
-	this.clean = function () { // private
-		var el = window.frames[this.mapframe].document.getElementById(this.tagname);
-		if (el) el.innerHTML = "";
-	}
-
-	this.drawCircle = function(x, y, diameter, color) { // private
-		this.canvas.setColor(color);
-		this.canvas.drawEllipse(x-diameter/2,y-diameter/2,diameter,diameter);
-	}
-
-	this.drawLine = function(x_array, y_array, color) { // private
-		this.canvas.setColor(color);
-		this.canvas.drawPolyline(x_array, y_array);
-	}
-
-	this.drawPolygon = function(x_array, y_array, color) { // private
-		this.canvas.setColor(color);
-		this.canvas.drawPolygon(x_array, y_array);
-	}
-	this.checkTag = function () { // private
-		if (typeof(window.frames[this.mapframe]) != 'undefined') {
-			var isTag = (window.frames[this.mapframe].document.getElementById(this.tagname))?1:0;
-			if(isTag == 0){
-				var draw = window.frames[this.mapframe].document.createElement("div");
-				var tmp = window.frames[this.mapframe].document.getElementsByTagName("body")[0].appendChild(draw);
-				tmp.setAttribute("id",this.tagname);
-//				tmp.setAttribute("style",this.style);
-				tmp.style.cssText = this.style;
-			}
-			else this.clean();
-			return true;
-		}
-		else {
-			alert('invalid mapframe ' + this.mapframe);
-		}
-		return false;
-	}
-	this.diameter = 8;
-	this.minWidth = 8;
-	this.lineWidth = lineWidth;
-	this.mapframe = mapframe;
-	this.tagname = tagname;
-	this.style = style;
-//	this.canvasDivTag = new DivTag(this.tagname, this.mapframe, this.style);
-	if (this.checkTag()) {
-		this.canvas = new jsGraphics(this.tagname, window.frames[this.mapframe]);
-		this.canvas.setStroke(this.lineWidth);
-		mb_registerPanSubElement(this.tagname);
-	}
-}
-
-// ----------------------------------------------------------------------------------------------------
-// Highlight
-// ----------------------------------------------------------------------------------------------------
-
-function Highlight(target_array, tagname, style, lineWidth) {
-
-	this.del = function(m, color) { // public
-		var a = this.gA.findMultiGeometry(m);
-		var del = false;
-		for (var i=0; i<a.length && del == false; i++) {
-			if (this.gA.get(a[i]).color == color) {
-				this.gA.del(a[i]);
-				del = true;
-			}
-		}
-		this.paint();
-	}
-
-	this.add = function(m, color) { // public
-		this.gA.appendMember(m);
-		if (typeof(color) != 'undefined') this.gA.get(-1).color = color; else this.gA.get(-1).color = this.lineColor;
-		this.paint();
-	}
-	
-	this.clean = function() { // public
-		if (this.gA.count() > 0) {
-			this.gA = new GeometryArray();
-			this.paint();
-		}
-	}
-
-	this.paint = function() { // public
-		for (i=0; i < this.canvas.length; i++) {
-			if (typeof(this.canvas[i]) == "object") this.canvas[i].clean();
-		}
-		for(var i=0; i<this.targets.length; i++){
-			if (typeof(this.canvas[this.targets[i]]) == 'undefined') {
-				this.canvas[this.targets[i]] = new Canvas(this.targets[i], this.tagname, this.style, this.lineWidth);
-			}
-			this.canvas[this.targets[i]].paint(this.gA);
-		}
-	}
-
-	this.lineWidth = lineWidth;
-	this.tagname = 'mod_gaz_draw'+tagname; // private
-	this.style = style;
-	this.targets = target_array; // private
-	this.canvas = []; // private
-	this.gA = new GeometryArray(); // private
-	this.lineColor = "#ff0000";
-
-	this.paint();
-}
-
-// ----------------------------------------------------------------------------------------------------
-// Snapping
-// ----------------------------------------------------------------------------------------------------
-
-function Snapping(aTarget, tolerance, color, zIndex){
-
-	this.check = function(currPoint){ // public
-		var minDist = false;
-		for (var i = 0 ; i < this.coord.length ; i++) {
-			var aDist = currPoint.dist(realToMap(this.target, this.coord[i]['coord']));
-			if (minDist == false || aDist < minDist) {
-				minDist = aDist;
-				if (minDist < this.tolerance) {this.min_i = i;}
-			}
-		}
-		if (this.coord.length>0 && minDist > this.tolerance) {this.min_i = -1;}
-		this.clean();
-		if (this.min_i != -1) this.draw(this.coord[this.min_i]['coord'], this.tolerance, 3);
-	}
-
-	this.store = function(geom, point){ // public
-		this.coord = [];
-		this.min_i = -1;
-	
-		for (var i = 0 ; i < geom.count(); i++){
-			if (geom.name == nameGeometryArray || geom.name == nameMultiGeometry){
-				for (var j = 0 ; j < geom.get(i).count() ; j++){
-					if (geom.get(i).name == nameMultiGeometry){
-						for (var k = 0 ; k < geom.get(i).get(j).count() ; k++){
-							if ((geom.get(i).get(j).isComplete() == true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point))){
-								this.add(geom, k, j, i);
-							}
-						}
-					}
-					else {
-						if ((geom.get(i).get(j).isComplete() == true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point))){
-							this.add(geom, j, i);
-						}
-					}
-				}
-			}
-			else {
-				if ((geom.get(i).get(j).isComplete() == true && typeof(point) == 'undefined') || (typeof(point) != 'undefined' && !geom.get(i).get(j).get(k).equals(point))){
-					this.add(geom, i);
-				}
-			}
-		}
-	}
-	
-	this.isSnapped = function(){ // private
-		if (this.min_i != -1) {return true;}
-		return false;
-	}
-	
-	this.getSnappedPoint = function(geom){ // private
-		var point;
-		var i = this.coord[this.min_i]['member'];
-		var j = this.coord[this.min_i]['geometry'];
-		var k = this.coord[this.min_i]['point']; 
-		if (geom.name == nameGeometryArray) {point = geom.getPoint(i,j,k);}
-		else if (geom.name == nameMultiGeometry) {point = geom.getPoint(j,k);}
-		else if (geom.name == nameGeometry) {point = geom.get(k);}
-		return point;
-	}
-	
-	this.add = function(geom, k, j, i){ // private
-		var cnt = this.coord.length;
-		this.coord[cnt] = [];
-
-		if (typeof(j) != 'undefined'){
-			if (typeof(i) != 'undefined') this.coord[cnt]['coord'] = geom.getPoint(i,j,k);
-			else this.coord[cnt]['coord'] = geom.getPoint(j,k);
-		}
-		else this.coord[cnt]['coord'] = geom.get(k);
-		
-		this.coord[cnt]['member'] = i;
-		this.coord[cnt]['geometry'] = j;
-		this.coord[cnt]['point'] = k;
-	}
-
-	this.draw = function(center,radius,size){ //private
-		mG = new MultiGeometry(geomType.point);
-		mG.addGeometry();
-		mG.get(-1).addPoint(center);
-		this.highlight.add(mG);
-	}
-	
-	this.clean = function(){ // private
-		this.highlight.clean();
-	}
-
-	this.tolerance = (typeof(tolerance) == 'undefined') ? 10 : tolerance;
-	this.lineWidth = 2;
-	this.target = aTarget;
-	this.style = "position:absolute; top:0px; left:0px; z-index:"+zIndex;
-	this.coord = []; // private
-	this.min_i = -1; //private
-	this.highlight = new Highlight(new Array(this.target), "snapping"+Math.round(Math.random()*Math.pow(10,10)), this.style, this.lineWidth);
-}
-
-// ----------------------------------------------------------------------------------------------------
-// misc. functions
-// ----------------------------------------------------------------------------------------------------
-
-function calculateVisibleDash (p0, p1, width, height) {
-	if (p0.x > p1.x) {var p_temp = p0; p0 = p1; p1 = p_temp; p_temp = null;}
-	var p = p0; var q = p1; var m; 
-	if (p1.x != p0.x) {
-		m = -(p1.y-p0.y)/(p1.x-p0.x); 
-		if (p0.x < width && p1.x > 0 && !(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height) ) {
-			if (p0.x < 0) {
-				var iy = p0.y - m*(0-p0.x);
-				if (iy > 0 && iy < height) p = new Point(0, iy);
-				else if (iy > height) {
-				    var ix = p0.x+((p0.y - height)/m);
-				    if (ix > 0 && ix < width) p = new Point(ix, height); else return false;
-				}
-				else if (iy < 0) {
-				    var ix = p0.x+(p0.y/m);
-				    if (ix > 0 && ix < width) p = new Point(ix, 0); else return false;
-				}
-				else return false;
-			}
-			else if (p0.y >= 0 && p0.y <= height) {p = p0;}
-			else if (p0.y < 0) {
-			    var ix = p0.x+(p0.y/m);
-			    if (ix > 0 && ix < width) p = new Point(ix, 0); else return false;
-			}
-			else if (p0.y > height && m > 0) {
-			    var ix = p0.x+((p0.y - height)/m);
-			    if (ix > 0 && ix < width) p = new Point(ix, height); else return false;
-			}
-			else return false;
-			if (p1.x > width) {
-				var iy = p1.y - m*(width-p1.x);
-				if (iy > 0 && iy < height) {q = new Point(width, iy);}
-				else if (iy < 0) {
-				    var ix = p0.x+(p0.y/m);
-				    if (ix > 0 && ix < width) q = new Point(ix, 0); else return false;
-				}
-				else if (iy > height) {
-				    var ix = p0.x+((p0.y - height)/m);
-				    if (ix > 0 && ix < width) q = new Point(ix, height); else return false;
-				}
-				else return false;
-			}
-			else if (p1.y >= 0 && p1.y <= height) {q = p1;}
-			else if (p1.y < 0) {
-			    var ix = p1.x+(p1.y/m);
-			    if (ix > 0 && ix < width) q = new Point(ix, 0); else return false;
-			}
-			else if (p1.y > height) {
-			    var ix = p1.x+((p1.y- height)/m);
-			    if (ix > 0 && ix < width) q = new Point(ix, height); else return false;
-			}
-		}
-		else return false;
-	}
-	else {
-		if (!(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height)) {
-			if (p0.y < 0) {p = new Point(p0.x, 0);}
-			else if (p0.y > height) {p = new Point(p0.x, height);}
-			else p = p0;
-			if (p1.y < 0) {q = new Point(p0.x, 0);}
-			else if (p1.y > height) {q = new Point(p0.x, height);}
-			else q = p1;
-		}
-		else return false;
-	}
-	return new Array(new Point(Math.round(q.x), Math.round(q.y)), new Point(Math.round(p.x), Math.round(p.y)));
-}
-
-function cloneObject(a){
-	var z = [];
-	
-	for (attr in a) {
-		var b = a[attr];
-		if (typeof(b) == "object") {z[attr] = cloneObject(b);}
-		else z[attr] = b;
-	}	
-	return z;
-}



More information about the Mapbender_commits mailing list