svn commit: r778 - trunk/mapbender/http/javascripts/mod_highlight.php
christoph at osgeo.org
christoph at osgeo.org
Fri Sep 29 04:23:00 EDT 2006
Author: christoph
Date: 2006-09-29 08:23:00+0000
New Revision: 778
Added:
trunk/mapbender/http/javascripts/mod_highlight.php
Log:
new class for highlighting
Added: trunk/mapbender/http/javascripts/mod_highlight.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_highlight.php?view=auto&rev=778
==============================================================================
--- (empty file)
+++ trunk/mapbender/http/javascripts/mod_highlight.php 2006-09-29 08:23:00+0000
@@ -0,0 +1,127 @@
+<?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
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
+*/
+require_once("mod_geometryArray.js");
+?>
+function Canvas(mapframe, tagname) {
+ this.paint = function(gA) {
+ 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){
+ for(var i=0; i < g.count(); i++){
+ var a = this.mb_wfs_toPix(g.get(i));
+ if(t==geomTypePoint) this.drawCircle(a['x'][0],a['y'][0],this.diameter,this.lineColor);
+ else if(t==geomTypeLine) this.drawLine(a['x'],a['y'],this.lineColor);
+ else if(t==geomTypePolygon) this.drawPolygon(a['x'],a['y'],this.lineColor);
+ }
+ }
+
+ this.mb_wfs_toPix = function(g){
+ var r = new Array();
+ r['x'] = new Array();
+ r['y'] = new Array();
+ for(var i=0; i < g.count(); i++){
+ var currentV = realToMap(this.mapframe,g.get(i));
+ r['x'][i] = currentV.x;
+ r['y'][i] = currentV.y;
+ }
+ return r;
+ }
+
+ 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 () {
+ 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");
+ }
+ }
+
+ this.mapframe = mapframe;
+ this.tagname = tagname;
+ this.checkTag();
+ this.canvas = new jsGraphics(this.tagname, window.frames[this.mapframe]);
+ this.canvas.setStroke(3);
+ this.diameter = 8;
+ this.minWidth = 8;
+ this.lineColor = "#ff0000";
+}
+
+function Highlight(target_array) {
+ this.tagname = 'mod_gaz_draw';
+ this.targets = target_array;
+ this.canvas = new Array();
+ this.gA = new GeometryArray();
+
+ mb_registerPanSubElement(this.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);
+ }
+ }
+}
More information about the Mapbender_commits
mailing list