[Mapbender-commits] r1106 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Feb 8 10:33:32 EST 2007
Author: christoph
Date: 2007-02-08 10:33:21 -0500 (Thu, 08 Feb 2007)
New Revision: 1106
Removed:
trunk/mapbender/http/javascripts/mod_highlight.php
Log:
now part of geometry.js
Deleted: trunk/mapbender/http/javascripts/mod_highlight.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_highlight.php 2007-02-08 15:29:41 UTC (rev 1105)
+++ trunk/mapbender/http/javascripts/mod_highlight.php 2007-02-08 15:33:21 UTC (rev 1106)
@@ -1,219 +0,0 @@
-<?php
-/*
-* $Id: mod_geometryArray.js 608 2006-06-22 08:57:02Z uli $
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* http://www.mapbender.org/index.php/Mod_highlight.php
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
-*/
-require_once(dirname(__FILE__)."/point.js");
-require_once(dirname(__FILE__)."/mod_geometryArray.js");
-?>
-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 Canvas(mapframe, tagname) {
- this.paint = function(gA) {
- if (this.checkTag()) {
- for (var q = 0; q < gA.count(); q++) {
- var m = gA.get(q);
- var t = m.geomtype;
- if (t == geomTypePoint) this.drawGeometry(t,m);
- else {
- if (this.isTooSmall(m)){
- var newMember = new MultiGeometry(geomTypePoint);
- newMember.addGeometry();
- newMember.get(-1).addPoint(m.getCenter());
- this.drawGeometry(geomTypePoint,newMember);
- }
- else{
- if(t == geomTypeLine) this.drawGeometry(t,m);
- else if(t == geomTypePolygon) this.drawGeometry(t,m);
- else alert("unknown geomtype");
- }
- }
- }
- this.canvas.paint();
- }
- }
-
- this.drawGeometry = function(t,g){
- 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==geomTypePoint) {
- 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,this.lineColor);
- }
- }
- else if(t==geomTypeLine) {
- 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, pq[1].x),new Array(pq[0].y, pq[1].y),this.lineColor);
- }
- }
- }
- else if(t==geomTypePolygon) {
- 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, pq[1].x),new Array(pq[0].y, pq[1].y),this.lineColor);
- }
- }
- }
- }
- }
-
- this.isTooSmall = function(g){
- var tmp = g.getBBox();
- var min = realToMap(this.mapframe,tmp[0]);
- var max = realToMap(this.mapframe,tmp[1]);
- if((max.x - min.x < this.minWidth) && (max.y - min.y < this.minWidth)) return true;
- return false;
- }
-
- this.clean = function () {
- var el = window.frames[mapframe].document.getElementById(tagname);
- if (el) el.innerHTML = "";
- }
-
- this.drawCircle = function(x, y, diameter, color) {
- this.canvas.setColor(color);
- this.canvas.drawEllipse(x-diameter/2,y-diameter/2,diameter,diameter);
- }
-
- this.drawLine = function(x_array, y_array, color) {
- this.canvas.setColor(color);
- this.canvas.drawPolyline(x_array, y_array);
- }
-
- this.drawPolygon = function(x_array, y_array, color) {
- this.canvas.setColor(color);
- this.canvas.drawPolygon(x_array, y_array);
- }
-
- this.checkTag = function () {
- 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","position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:100");
- //prompt("",window.frames[this.mapframe].document.getElementById(this.tagname).innerHTML);
- }
- else {
- this.clean();
- }
- return true;
- }
- return false;
- }
-
- this.mapframe = mapframe;
- this.tagname = tagname;
- if (this.checkTag()) {
- this.canvas = new jsGraphics(this.tagname, window.frames[this.mapframe]);
- this.canvas.setStroke(3);
- mb_registerPanSubElement(this.tagname);
- }
- this.diameter = 8;
- this.minWidth = 8;
- this.lineColor = "#ff0000";
-}
-
-function Highlight(target_array, tagname) {
- this.del = function(m) {
- this.gA.removeMultiGeometry(m);
- this.paint();
- }
-
- this.add = function(m) {
- this.gA.appendMember(m);
- this.paint();
- }
-
- this.paint = function() {
- for (q in this.canvas) this.canvas[q].clean();
- for(var i=0; i<this.targets.length; i++){
- this.canvas[this.targets[i]] = new Canvas(this.targets[i], this.tagname);
- this.canvas[this.targets[i]].paint(this.gA);
- }
- }
-
- this.tagname = 'mod_gaz_draw'+tagname;
- this.targets = target_array;
- this.canvas = new Array();
- this.gA = new GeometryArray();
-
-
- this.paint();
-}
More information about the Mapbender_commits
mailing list