svn commit: r974 - trunk/mapbender/http/javascripts/geometry.js
christoph at osgeo.org
christoph at osgeo.org
Mon Dec 11 06:00:46 EST 2006
Author: christoph
Date: 2006-12-11 11:00:46+0000
New Revision: 974
Modified:
trunk/mapbender/http/javascripts/geometry.js
Log:
* function findMultiGeometry now returns an array of indices (previously the index of the first match)
* added colour to class Highlight
Modified: trunk/mapbender/http/javascripts/geometry.js
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/geometry.js?view=diff&rev=974&p1=trunk/mapbender/http/javascripts/geometry.js&p2=trunk/mapbender/http/javascripts/geometry.js&r1=973&r2=974
==============================================================================
--- trunk/mapbender/http/javascripts/geometry.js (original)
+++ trunk/mapbender/http/javascripts/geometry.js 2006-12-11 11:00:46+0000
@@ -59,16 +59,11 @@
}
this.findMultiGeometry = function(m) { // public
+ var a = new Array();
for (var i=0; i < this.count(); i++) {
- if (this.get(i).equals(m)) return i;
+ if (this.get(i).equals(m)) a.push(i);
}
- return null;
- }
-
- this.removeMultiGeometry = function(m) { // public
- var i = true;
- i = this.findMultiGeometry(m);
- if (i != null) this.del(i);
+ return a;
}
this.delGeometry = function(i,j){ // public
@@ -462,17 +457,18 @@
for (var q = 0; q < gA.count(); q++) {
var m = gA.get(q);
var t = m.geomtype;
- if (t == geomTypePoint) this.drawGeometry(t,m);
+ var col = m.color;
+ if (t == geomTypePoint) this.drawGeometry(t,m,col);
else {
if (this.isTooSmall(m)){
var newMember = new MultiGeometry(geomTypePoint);
newMember.addGeometry();
newMember.get(-1).addPoint(m.getCenter());
- this.drawGeometry(geomTypePoint,newMember);
+ this.drawGeometry(geomTypePoint,newMember,col);
}
else{
- if(t == geomTypeLine) this.drawGeometry(t,m);
- else if(t == geomTypePolygon) this.drawGeometry(t,m);
+ if(t == geomTypeLine) this.drawGeometry(t,m, col);
+ else if(t == geomTypePolygon) this.drawGeometry(t,m,col);
else alert("unknown geomtype");
}
}
@@ -481,7 +477,7 @@
}
}
- this.drawGeometry = function(t,g){ // private
+ this.drawGeometry = function(t,g,col){ // private
var mapObjInd = getMapObjIndexByName(this.mapframe);
width = mb_mapObj[mapObjInd].width;
height = mb_mapObj[mapObjInd].height;
@@ -490,14 +486,14 @@
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);
+ this.drawCircle(p.x-1,p.y-1,this.diameter,col);
}
}
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);
+ this.drawLine(new Array(pq[0].x-1, pq[1].x-1),new Array(pq[0].y-1, pq[1].y-1),col);
}
}
}
@@ -505,7 +501,7 @@
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.drawLine(new Array(pq[0].x-1, pq[1].x-1),new Array(pq[0].y-1, pq[1].y-1),col);
}
}
}
@@ -569,7 +565,6 @@
}
this.diameter = 8;
this.minWidth = 8;
- this.lineColor = "#ff0000";
}
// ----------------------------------------------------------------------------------------------------
@@ -577,13 +572,21 @@
// ----------------------------------------------------------------------------------------------------
function Highlight(target_array, tagname) {
- this.del = function(m) { // public
- this.gA.removeMultiGeometry(m);
+ 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) { // public
+ 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();
}
@@ -606,6 +609,7 @@
this.targets = target_array; // private
this.canvas = new Array(); // private
this.gA = new GeometryArray(); // private
+ this.lineColor = "#ff0000";
mb_registerPanSubElement(this.tagname);
this.paint();
More information about the Mapbender_commits
mailing list