svn commit: r356 - trunk/mapbender/http/javascripts/mod_digitize_tab.php
christoph at osgeo.org
christoph at osgeo.org
Mon May 29 10:19:37 EDT 2006
Author: christoph
Date: 2006-05-29 14:19:37+0000
New Revision: 356
Modified:
trunk/mapbender/http/javascripts/mod_digitize_tab.php
Log:
new, see wiki for details
Modified: trunk/mapbender/http/javascripts/mod_digitize_tab.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_digitize_tab.php?view=diff&rev=356&p1=trunk/mapbender/http/javascripts/mod_digitize_tab.php&p2=trunk/mapbender/http/javascripts/mod_digitize_tab.php&r1=355&r2=356
==============================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php (original)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php 2006-05-29 14:19:37+0000
@@ -1,3 +1,4 @@
+<?php
# $Id$
# http://www.mapbender.org/index.php/mod_digitize_tab.php
# Copyright (C) 2002 CCGIS
@@ -16,7 +17,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-<?php
session_start();
import_request_variables("PG");
require_once("../php/mb_validateSession.php");
@@ -59,773 +59,566 @@
echo "<script language='JavaScript'>";
echo "var mod_digitize_target = '".$e_target[0]."';";
echo "var mod_digitize_frame = '".$e_target[1]."';";
+ require_once("mod_geometryArray.js");
?>
-//var mod_digitize_status = 0;
-//public
-
-var mod_digitize_color1 = "white";
-var mod_digitize_color2 = "black";
-var mod_digitize_font = "Arial, Helvetica, sans-serif";
-var mod_digitize_fontsize = "9px";
-var mod_digitize_basepoint = "#8a2be2";
-var mod_digitize_linepoint = "#ff00ff";
-var mod_digitize_bg = "";
-
-var mod_digitize_elName = "digitize";
-var mod_digitize_frameName = "";
-
var wfsWindow;
-
-var snappingCoordinates = new Array();
-var snappingTolerance = 12;
-var snappedMember = -1;
-var snappedGeometry = -1;
-var snappedPoint = -1;
-var snapped = false;
-
-// canvas contains circles around snapping target
-var canvas = new Array();
-
+var dwin = null;
var wfs_conf = new Array();
-
-var D = new Array();
-
-var activeButton = null; // contains id of active button
-var isOn = true;
+var d = new GeometryArray();
var mod_digitize_width;
var mod_digitize_height;
-var mod_digitize_Dist = new Array();
-var mod_digitize_TotalDist = new Array();
-var mod_digitizeSubFunctions = new Array();
var mod_digitizeEvent = false;
-
-//currently selected basepoint
-var basepointObject = false;
-
-// stores the number of geometries in the geometry list
-var numberOfGeometries = 0;
-//indices of the geometry associated with a certain basepoint
-var basepointMemberIndex = false;
-var basepointGeometryIndex = false;
-var basepointPointIndex = false;
+try {if(mod_digitize_elName){}}catch(e) {mod_digitize_elName = "digitize";}
-//when a basepoint is being dragged, the coordinates are stored
-var basepointDragActive = false;
-var basepointDragStartX = false;
-var basepointDragStartY = false;
-var basepointDragEndX = false;
-var basepointDragEndY = false;
-
-//indices of the geometry that is currently built
-var currentMemberIndex = -1;
-var currentGeometryIndex = -1;
+// ------------------------------------------------------------------------------------------------------------------------
+// --- polygon, line, point insertion (begin) ----------------------------------------------------------------------------------------------
-function registerFunctions(){
- parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].setStyleForTargetFrame()");
- parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].checkTag()");
- parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].drawDashedLine()");
+function appendGeometry(obj) {
+ executeDigitizePreFunctions();
+ d.appendMember(obj);
+ executeDigitizeSubFunctions();
}
-function checkTag(){
- var attributes = new Array();
- attributes[0] = new Array();
- attributes[0][0] = "style";
- attributes[0][1] = "position:absolute; top:0px; left:0px; z-index:26; font-size:10px";
- node = parent.mb_checkTag(mod_digitize_target, "div", "digitize", "body", attributes);
- if (node == false) {
- alert("Fatal error: Element id 'digitize' is already taken!");
- }
-}
+function mod_digitize_go(e){
+ parent.mb_registerGML(mod_digitize_target,d);
+
+ executeDigitizePreFunctions();
-function setStyleForTargetFrame(){
- var cssLink = parent.window.frames[mod_digitize_target].document.createElement("link");
- cssLink.setAttribute("href", cssUrl);
- cssLink.setAttribute("type", "text/css");
- cssLink.setAttribute("rel", "stylesheet");
- var cssTmp = parent.window.frames[mod_digitize_target].document.getElementsByTagName("head")[0];
- cssTmp.appendChild(cssLink);
+ // ie workaround
+ if (e == undefined) {
+ e = parent.frames[mod_digitize_target].event;
+ }
+ if (e) {
+ // track mouse position
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var currentPos = new Point(parent.clickX, parent.clickY);
+ s.check(currentPos);
+ }
+ else {
+ s.clean();
+ }
+
+ var el = parent.frames[mod_digitize_target].document;
+ el.onmousedown = mod_digitize_start;
}
-/*
-function const_D(id,type){
- this.id = id;
- this.type = type;
- this.x = new Array();
- this.y = new Array();
- this.label = "";
-
- var ind = parent.getMapObjIndexByName(mod_digitize_target);
- this.epsg = parent.mb_mapObj[ind].epsg;
- this.units = "";
- this.dist = new Array();
- this.totaldist = new Array();
- this.complete = false;
+function mod_digitize_timeout(){
+ //parent.document.getElementById(mod_digitize_elName).style.visibility = 'hidden';
+ var el = parent.frames[mod_digitize_target].document;
+ el.onmousedown = null;
+ el.onmouseup = null;
+ el.onmousemove = null;
}
-*/
-function displayButtons(){
- if (parseInt(buttonPoint)==1){
- var tagContent = "<img name=\""+buttonPointId+"\" onmouseover=\"registerButton('initButtonPoint')\" id=\""+buttonPointId+"\" title=\""+buttonPointTitleUp+"\" src=\""+buttonPointSrcUp+"\">";
- parent.writeTag(mod_digitize_elName,"divButtonPoint",tagContent);
- }
- if (parseInt(buttonLine)==1){
- var tagContent = "<img name=\""+buttonLineId+"\" onmouseover=\"registerButton('initButtonLine')\" id=\""+buttonLineId+"\" title=\""+buttonLineTitleUp+"\" src=\""+buttonLineSrcUp+"\">";
- parent.writeTag(mod_digitize_elName,"divButtonLine",tagContent);
+function mod_digitize_start(e){
+ // check if a proper geometry is selected
+ if (d.getGeometry(-1,-1).complete == true || d.count() == 0){
+
+ if (mod_digitizeEvent != false) {
+ alert("No geometry selected!");
+ }
+ return false;
}
- if (parseInt(buttonPolygon)==1){
- var tagContent = "<img name=\""+buttonPolygonId+"\" onmouseover=\"registerButton('initButtonPolygon')\" id=\""+buttonPolygonId+"\" title=\""+buttonPolygonTitleUp+"\" src=\""+buttonPolygonSrcUp+"\">";
- parent.writeTag(mod_digitize_elName,"divButtonPolygon",tagContent);
+
+ var realWorldPos;
+ if (s.isSnapped() == true) {
+ realWorldPos = s.getSnappedPoint(d);
+ s.clean();
}
- if (parseInt(buttonMove)==1){
- var tagContent = "<img name=\""+buttonMoveId+"\" onmouseover=\"registerButton('initButtonMove')\" id=\""+buttonMoveId+"\" title=\""+buttonMoveTitleUp+"\" src=\""+buttonMoveSrcUp+"\">";
- parent.writeTag(mod_digitize_elName,"divButtonMove",tagContent);
+ else {
+ parent.mb_getMousePos(e,mod_digitize_target);
+ realWorldPos = parent.mapToReal(mod_digitize_target,new Point(parent.clickX,parent.clickY));
}
- if (parseInt(buttonInsert)==1){
- var tagContent = "<img name=\""+buttonInsertId+"\" onmouseover=\"registerButton('initButtonInsert')\" id=\""+buttonInsertId+"\" title=\""+buttonInsertTitleUp+"\" src=\""+buttonInsertSrcUp+"\">";
- parent.writeTag(mod_digitize_elName,"divButtonInsert",tagContent);
+
+ if (d.get(-1).geomtype == geomTypePolygon && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(0).equals(realWorldPos)) {
+
+ // close the polygon
+ parent.mb_disableThisButton(button_polygon);
}
- if (parseInt(buttonDelete)==1){
- var tagContent = "<img name=\""+buttonDeleteId+"\" onmouseover=\"registerButton('initButtonDelete')\" id=\""+buttonDeleteId+"\" title=\""+buttonDeleteTitleUp+"\" src=\""+buttonDeleteSrcUp+"\">";
- parent.writeTag(mod_digitize_elName,"divButtonDelete",tagContent);
+ else if (d.get(-1).geomtype == geomTypeLine && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(-1).equals(realWorldPos)) {
+ // close the line
+ parent.mb_disableThisButton(button_line);
}
-}
-
-function registerButton(functionName){
- parent.mb_regButton_frame(functionName, mod_digitize_elName);
-}
-
-function initButtonPoint(ind){
- initButton(ind, buttonPointSrcUp, buttonPointSrcDown, buttonPointSrcUp, buttonPointTitleUp, buttonPointTitleDown, buttonPointId);
-}
-
-function initButtonLine(ind){
- initButton(ind, buttonLineSrcUp, buttonLineSrcDown, buttonLineSrcUp, buttonLineTitleUp, buttonLineTitleDown, buttonLineId);
-}
-
-function initButtonPolygon(ind){
- initButton(ind, buttonPolygonSrcUp, buttonPolygonSrcDown, buttonPolygonSrcUp, buttonPolygonTitleUp, buttonPolygonTitleDown, buttonPolygonId);
-}
-
-function initButtonMove(ind){
- initButton(ind, buttonMoveSrcUp, buttonMoveSrcDown, buttonMoveSrcUp, buttonMoveTitleUp, buttonMoveTitleDown, buttonMoveId);
-}
+ else {
+ // set the calculated real world position as point of the geometry
+ d.getGeometry(-1,-1).addPoint(realWorldPos);
+
+ if(d.get(-1).geomtype == geomTypePoint){
+ parent.mb_disableThisButton(button_point);
+ }
+
+ // add first point of polygon to snapping list (if three points have been inserted).
+ else if (d.get(-1).geomtype == geomTypePolygon && d.getGeometry(-1,-1).count() == 3) {
+ s.add(d, 0, -1, -1)
+ }
-function initButtonInsert(ind){
- initButton(ind, buttonInsertSrcUp, buttonInsertSrcDown, buttonInsertSrcUp, buttonInsertTitleUp, buttonInsertTitleDown, buttonInsertId);
+ // add last point of line to snapping list (if at least two points have been inserted).
+ else if (d.get(-1).geomtype == geomTypeLine && d.getGeometry(-1,-1).count() >= 2) {
+ s.store(d, mod_digitizeEvent);
+ s.add(d, -1, -1, -1)
+ }
+ }
+ executeDigitizeSubFunctions();
+ return true;
}
+// --- polygon, line, point insertion (begin) ----------------------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------------------------------------------------
-function initButtonDelete(ind){
- initButton(ind, buttonDeleteSrcUp, buttonDeleteSrcDown, buttonDeleteSrcUp, buttonDeleteTitleUp, buttonDeleteTitleDown, buttonDeleteId);
-}
+// ------------------------------------------------------------------------------------------------------------------------
+// --- basepoint handling (begin) -----------------------------------------------------------------------------------------
-function initButton(ind, srcOver, srcDown, srcUp, titleUp, titleDown, id){
- parent.mb_button[ind] = document.getElementById(id);
- parent.mb_button[ind].img_over = srcOver;
- parent.mb_button[ind].img_on = srcDown;
- parent.mb_button[ind].img_off = srcUp;
- parent.mb_button[ind].title_on = titleUp;
- parent.mb_button[ind].title_off = titleDown;
- parent.mb_button[ind].status = 0;
- parent.mb_button[ind].elName = id;
- parent.mb_button[ind].fName = "";
- parent.mb_button[ind].go = new Function ("digitizeEnable(parent.mb_button["+ind+"])");
- parent.mb_button[ind].stop = new Function ("digitizeDisable(parent.mb_button["+ind+"])");
-}
+var basepointObject = false;
+var basepointMemberIndex = null;
+var basepointGeometryIndex = null;
+var basepointPointIndex = null;
+var basepointDragActive = false;
-function digitizeEnable(obj){
- if (obj.id == buttonMoveId || obj.id == buttonInsertId || obj.id == buttonDeleteId){
- activeButton = obj.id;
- setEvent(obj);
+function handleBasepoint(obj,memberIndex,geometryIndex,pointIndex){
+ if(!(mod_digitizeEvent == button_move || mod_digitizeEvent == button_insert || mod_digitizeEvent == button_delete)){ return false; };
+
+ basepointObject = obj;
+ basepointMemberIndex = memberIndex;
+ basepointGeometryIndex = geometryIndex;
+ basepointPointIndex = pointIndex;
+
+ if(mod_digitizeEvent == button_move){
+ mod_digitize_timeout();
+ basepointObject.style.cursor = 'move';
+ basepointObject.onmousedown = parent.window.frames[mod_digitize_elName].selectBasepoint;
}
- else if (obj.id == buttonPointId || obj.id == buttonLineId || obj.id == buttonPolygonId){
- activeButton = obj.id;
- obj.title = obj.title_off;
- currentMemberIndex = -1;
- registerGeometry(obj);
- storeSnappingCoordinates();
- var el = parent.frames[mod_digitize_target].document;
- el.onmousemove = mod_digitize_go;
+
+ if(mod_digitizeEvent == button_delete){
+ mod_digitize_timeout();
+ basepointObject.style.cursor = 'crosshair';
+ basepointObject.onmousedown = parent.window.frames[mod_digitize_elName].deleteBasepoint;
}
}
-function digitizeDisable(obj){
- if (obj.id == buttonPointId || obj.id == buttonLineId || obj.id == buttonPolygonId){
- activeButton = null;
- obj.title = obj.title_on;
- closeGeometry(obj.id);
+function convertLinepointToBasepoint(obj, memberIndex, geomIndex, pointIndex){
+ if(!(mod_digitizeEvent == button_insert)){ return false; };
+
+ if(mod_digitizeEvent == button_insert){
mod_digitize_timeout();
+ obj.style.cursor = 'crosshair';
+ obj.onclick = insertBasepoint;
+
+ basepointObject = obj;
+ basepointMemberIndex = memberIndex;
+ basepointGeometryIndex = geomIndex;
+ basepointPointIndex = pointIndex;
}
}
+function insertBasepoint(e){
+ var i = basepointMemberIndex;
+ var j = basepointGeometryIndex;
+ var k = basepointPointIndex;
+
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var pos = parent.makeClickPos2RealWorldPos(mod_digitize_target,parent.clickX, parent.clickY);
+ var p = new Point(pos[0], pos[1]);
+ d.getGeometry(i,j).addPointAtIndex(p, k);
-var dwin = null;
-
-function mod_saveGeom(){
- dwin = window.open("../php/mod_wfs_save.php","dwin","width=300,height=200");
+ executeDigitizeSubFunctions();
}
+function deleteBasepoint(){
+ var i = basepointMemberIndex
+ var j = basepointGeometryIndex;
+ var k = basepointPointIndex;
+ d.delAllPointsLike(d.getPoint(i,j,k));
-function cleanCanvas(){
- var el = parent.window.frames[mod_digitize_target].document.getElementById('mod_digi_draw');
- if (el) el.innerHTML = "";
-}
-
-function checkCanvasTag(){
- var isTag = (parent.window.frames[mod_digitize_target].document.getElementById('mod_digi_draw'))?1:0;
- if(isTag == 0){
- var draw = parent.window.frames[mod_digitize_target].document.createElement("div");
- var tmp = parent.window.frames[mod_digitize_target].document.getElementsByTagName("body")[0].appendChild(draw);
- tmp.setAttribute("id","mod_digi_draw");
- tmp.setAttribute("style","position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:100");
- }
- canvas[mod_digitize_target] = new parent.jsGraphics('mod_digi_draw', parent.window.frames[mod_digitize_target]);
- canvas[mod_digitize_target].setStroke(3);
-}
-
-function drawSnappingArea (centerX,centerY,radius,size){
- canvas[mod_digitize_target].setColor("#ff0000");
- canvas[mod_digitize_target].drawEllipse(centerX-(size/2)*radius,centerY-(size/2)*radius,size*radius,size*radius);
- canvas[mod_digitize_target].paint();
-}
-
-function storeSnappingCoordinates(){
- snappingCoordinates = new Array();
- // copy coordinates of other geometries in another array
- var im = -1;
- var cnt = 0;
- for (var i = 0; i < D.length ; i++){
- for (var j = 0 ; j < D[i]['geometry'].length ; j++){
- for (var k = 0 ; k < D[i]['geometry'][j]['x'].length ; k++){
- var pos = parent.makeRealWorld2mapPos(mod_digitize_target, D[i]['geometry'][j]['x'][k], D[i]['geometry'][j]['y'][k]);
- // snap only if the two points have different coordinates
- if (basepointDragActive == false || basepointDragActive == true && (D[i]['geometry'][j]['x'][k] != D[basepointMemberIndex]['geometry'][basepointGeometryIndex]['x'][basepointPointIndex] || D[i]['geometry'][j]['y'][k] != D[basepointMemberIndex]['geometry'][basepointGeometryIndex]['y'][basepointPointIndex])){
- snappingCoordinates[cnt] = new Array();
- snappingCoordinates[cnt]['map_x'] = pos[0];
- snappingCoordinates[cnt]['map_y'] = pos[1];
- snappingCoordinates[cnt]['member'] = i;
- snappingCoordinates[cnt]['geometry'] = j;
- snappingCoordinates[cnt]['point'] = k;
- cnt++;
- }
- }
- }
- }
- return false;
+ executeDigitizeSubFunctions();
}
-function checkSnapped (basepointDragEndX, basepointDragEndY, defaultMouseCursor){
- var minDist = false;
- var min_i = -1;
- for (var i = 0 ; i < snappingCoordinates.length ; i++){
- var aDist = dist(basepointDragEndX, basepointDragEndY, snappingCoordinates[i]['map_x'], snappingCoordinates[i]['map_y']);
- if (aDist < snappingTolerance){
- if (minDist == false || aDist < minDist){
- minDist = aDist;
- snappedMember = snappingCoordinates[i]['member'];
- snappedGeometry = snappingCoordinates[i]['geometry'];
- snappedPoint = snappingCoordinates[i]['point'];
- min_i = i;
- }
- }
+function selectBasepoint(e){
+ if(basepointDragActive == false && mod_digitizeEvent == button_move){
+ basepointDragActive = true;
+ s.store(d, mod_digitizeEvent, d.getPoint(basepointMemberIndex, basepointGeometryIndex, basepointPointIndex));
+ basepointObject.onmouseup = releaseBasepoint;
+ basepointObject.onmousemove = dragBasepoint;
}
+}
- if (minDist == false || minDist > snappingTolerance){
- snapped = false;
- var el = parent.window.frames[mod_digitize_target].document.getElementById('mod_digi_draw');
- if (el) el.innerHTML = "";
- }
- else{
- snapped = true;
-
- checkCanvasTag();
- cleanCanvas();
- drawSnappingArea(snappingCoordinates[min_i]['map_x'], snappingCoordinates[min_i]['map_y'], snappingTolerance, 3);
- }
+function dragBasepoint(e){
+ if(basepointDragActive){
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var currentPos = new Point(parent.clickX, parent.clickY);
+ var res = s.check(currentPos);
- if (basepointObject != false){
- if (snapped == true){
- basepointObject.style.cursor = 'crosshair';
+ // replace basepoint by transparent blob
+ basepointObject.style.width = mod_digitize_width;
+ basepointObject.style.height = mod_digitize_height;
+ basepointObject.style.left = 0;
+ basepointObject.style.top = 0;
+
+ if (parent.ie) {
+ // ie cannot handle backgroundColor = 'transparent'
+ basepointObject.style.background = "url(/../img/button_digitize/trans.png)";
}
else{
- basepointObject.style.cursor = defaultMouseCursor;
- }
-
- if (defaultMouseCursor == 'move'){
- // replace basepoint by transparent blob
- basepointObject.style.width = mod_digitize_width;
- basepointObject.style.height = mod_digitize_height;
- basepointObject.style.left = 0;
- basepointObject.style.top = 0;
-
- if (parent.ie){
- // ie cannot handle backgroundColor = 'transparent'
- basepointObject.style.background = "url(/../img/button_digitize/trans.png)";
- }
- else{
- basepointObject.style.backgroundColor = 'transparent';
- }
+ basepointObject.style.backgroundColor = 'transparent';
}
}
}
+
+function releaseBasepoint(e){
+
+ var i = basepointMemberIndex;
+ var j = basepointGeometryIndex;
+ var k = basepointPointIndex;
+ basepointDragActive = false;
+
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var basepointDragEnd = new Point(parent.clickX, parent.clickY);
+ basepointObject.onmousedown = null;
+ var p = parent.makeClickPos2RealWorldPos(mod_digitize_target, basepointDragEnd.x, basepointDragEnd.y);
-function mod_digitize_go(e){
- parent.mb_registerGML(mod_digitize_target,D);
- parent.document.getElementById(mod_digitize_elName).style.visibility = 'visible';
-
- // ie workaround
- if (e == undefined){
- e = parent.frames[mod_digitize_target].event;
+ var oldPoint = cloneObject(d.getPoint(i,j,k));
+ if (s.isSnapped() == true) {
+ var snappedPoint = cloneObject(s.getSnappedPoint(d));
+ d.updateAllPointsLike(oldPoint, snappedPoint);
+ s.clean();
}
-
- if(e){
- // track mouse position
- parent.mb_getMousePos(e, mod_digitize_target);
- checkSnapped(parent.clickX, parent.clickY, 'default');
+ else {
+ var newPoint = new Point(p[0],p[1]);
+ d.updateAllPointsLike(oldPoint, newPoint);
}
+ basepointMemberIndex = null;
+ basepointGeometryIndex = null;
+ basepointPointIndex = null;
- var el = parent.frames[mod_digitize_target].document;
- el.onmousedown = mod_digitize_start;
- //el.onmousemove = mod_digitize_run;
-
- var ind = parent.getMapObjIndexByName(mod_digitize_target);
- mod_digitize_width = parent.mb_mapObj[ind].width;
- mod_digitize_height = parent.mb_mapObj[ind].height;
- mod_digitize_epsg = parent.mb_mapObj[ind].epsg;
+ executeDigitizeSubFunctions();
}
+// --- basepoint handling (end) -----------------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------------------------------------------------
-
-function mod_digitize_timeout(){
- //isOn = false;
- //parent.document.getElementById(mod_digitize_elName).style.visibility = 'hidden';
- var el = parent.frames[mod_digitize_target].document;
- el.onmousedown = null;
- el.onmouseup = null;
- el.onmousemove = null;
- //drawDashedLine();
+// ------------------------------------------------------------------------------------------------------------------------
+// --- registered functions (begin) ---------------------------------------------------------------------------------------
+
+function registerDigitizePreFunctions(stringFunction){
+ mod_digitizePreFunctions[mod_digitizePreFunctions.length] = stringFunction;
}
-
-function registerGeometry(type){
- // a new geometry will be inserted
- if (currentMemberIndex == -1){
- currentMemberIndex = D.length;
-
- // generates a new member
- D[currentMemberIndex] = new Array();
- D[currentMemberIndex]['geometry'] = new Array();
- D[currentMemberIndex]['element'] = new Array();
- D[currentMemberIndex]['wfs_conf'] = -1;
- D[currentMemberIndex]['geomtype'] = type.id;
-
- // attach a new geometry
- var geomInd = D[currentMemberIndex]['geometry'].length;
- D[currentMemberIndex]['geometry'][geomInd] = new Array();
- D[currentMemberIndex]['geometry'][geomInd]['x'] = new Array();
- D[currentMemberIndex]['geometry'][geomInd]['y'] = new Array();
- D[currentMemberIndex]['geometry'][geomInd]['complete'] = false;
-
- currentGeometryIndex = 0;
+
+function registerDigitizeSubFunctions(stringFunction){
+ mod_digitizeSubFunctions[mod_digitizeSubFunctions.length] = stringFunction;
+}
+
+function executeDigitizeSubFunctions(){
+ for(var i=0; i<mod_digitizeSubFunctions.length; i++){
+ eval(mod_digitizeSubFunctions[i]);
}
- // a geometry will be added to an existing geometry
- else{
+}
- // FIXME: check if geometry types match
- // attach a new geometry
- var geomInd = D[currentMemberIndex]['geometry'].length;
- D[currentMemberIndex]['geometry'][geomInd] = new Array();
- D[currentMemberIndex]['geometry'][geomInd]['x'] = new Array();
- D[currentMemberIndex]['geometry'][geomInd]['y'] = new Array();
- D[currentMemberIndex]['geometry'][geomInd]['complete'] = false;
-
- currentGeometryIndex = geomInd;
+function executeDigitizePreFunctions(){
+ for(var i=0; i<mod_digitizePreFunctions.length; i++){
+ eval(mod_digitizePreFunctions[i]);
}
}
-function mod_digitize_start(e){
- isOn = true;
- if (currentMemberIndex != -1){
- // select the last geometry of the current member
- var geomInd = D[currentMemberIndex]['geometry'].length - 1;
-
- // check if a proper geometry is selected
- if(D[currentMemberIndex]['geometry'][geomInd]['complete'] == true || (D.length == 0)){
-
- if (activeButton != null){
- alert("No geometry selected!");
- }
- return true;
- }
-
- // get the mouse position and calculate real world position
- if (snapped == true){
- cleanCanvas();
-
- var realWorldPos = new Array();
- realWorldPos[0] = D[snappedMember]['geometry'][snappedGeometry]['x'][snappedPoint];
- realWorldPos[1] = D[snappedMember]['geometry'][snappedGeometry]['y'][snappedPoint];
- }
- else{
- parent.mb_getMousePos(e,mod_digitize_target);
- var realWorldPos = parent.makeClickPos2RealWorldPos(mod_digitize_target,parent.clickX,parent.clickY);
- }
- snapped = false;
-
- if (D[currentMemberIndex]['geomtype'].toLowerCase() == 'polygon'
- && D[currentMemberIndex]['geometry'][geomInd]['x'].length > 1
- && D[currentMemberIndex]['geometry'][geomInd]['x'][0] == realWorldPos[0]
- && D[currentMemberIndex]['geometry'][geomInd]['y'][0] == realWorldPos[1]){
-
- // close the polygon
- parent.mb_disableThisButton('Polygon');
- }
- else{
- // set the calculated real world position as point of the geometry
- xInd = D[currentMemberIndex]['geometry'][geomInd]['x'].length;
- yInd = D[currentMemberIndex]['geometry'][geomInd]['y'].length;
- D[currentMemberIndex]['geometry'][geomInd]['x'][xInd] = realWorldPos[0];
- D[currentMemberIndex]['geometry'][geomInd]['y'][yInd] = realWorldPos[1];
-
- // if the current geometry is a point, attach a label to it
- if(D[currentMemberIndex]['geomtype'].toLowerCase() == 'point'){
- parent.mb_disableThisButton('Point');
- }
-
- // add first point of polygon to snapping list (if three points have been inserted).
- if (D[currentMemberIndex]['geomtype'].toLowerCase() == 'polygon'
- && D[currentMemberIndex]['geometry'][geomInd]['x'].length == 3){
- var tempInd = snappingCoordinates.length;
- var pos = parent.makeRealWorld2mapPos(mod_digitize_target, D[currentMemberIndex]['geometry'][geomInd]['x'][0], D[currentMemberIndex]['geometry'][geomInd]['y'][0]);
- snappingCoordinates[tempInd] = new Array();
- snappingCoordinates[tempInd]['map_x'] = pos[0];
- snappingCoordinates[tempInd]['map_y'] = pos[1];
- snappingCoordinates[tempInd]['member'] = currentMemberIndex;
- snappingCoordinates[tempInd]['geometry'] = geomInd;
- snappingCoordinates[tempInd]['point'] = 0;
- }
- }
- drawDashedLine();
+function registerFunctions(){
+ mod_digitizePreFunctions = new Array();
+ mod_digitizeSubFunctions = new Array();
+ registerDigitizePreFunctions("updateExtent()");
+ registerDigitizePreFunctions("drawDashedLine()");
+ registerDigitizeSubFunctions("updateListOfGeometries()");
+ registerDigitizeSubFunctions("drawDashedLine()");
+ parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].setStyleForTargetFrame()");
+ parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].checkDigitizeTag()");
+ parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].initialiseSnapping()");
+ parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].drawDashedLine()");
+}
+
+function checkDigitizeTag(){
+ var attributes = new Array();
+ attributes[0] = new Array();
+ attributes[0][0] = "style";
+ attributes[0][1] = "position:absolute; top:0px; left:0px; z-index:26; font-size:10px";
+ node = parent.mb_checkTag(mod_digitize_target, "div", "digitize", "body", attributes);
+ if (node == false) {
+ alert("Fatal error: Element id 'digitize' is already taken!");
}
-
- return true;
}
-//
-// finishes a geometry by labelling it complete.
-// if no coordinates have been added, the geometry is discarded.
-//
-// when a polygon is built and the polygon button is clicked again, the
-// polygon will be closed by connecting the last to the first point.
-// Actually, the first point is stored twice at index '0' and index 'length'
-//
-function closeGeometry(obj_id){
- var i = currentMemberIndex;
- var j = currentGeometryIndex;
-
- if(!isOn){
- return;
- };
+function setStyleForTargetFrame(){
+ var cssLink = parent.window.frames[mod_digitize_target].document.createElement("link");
+ cssLink.setAttribute("href", cssUrl);
+ cssLink.setAttribute("type", "text/css");
+ cssLink.setAttribute("rel", "stylesheet");
+ var cssTmp = parent.window.frames[mod_digitize_target].document.getElementsByTagName("head")[0];
+ cssTmp.appendChild(cssLink);
+}
- D[i]['geometry'][j]['complete'] = true;
-
- var tmpLength = D[i]['geometry'][j]['x'].length;
-
- // if no geometries have been inserted, delete the geometry or member
- if (tmpLength == 0){
- if (j == 0){
- D.length--;
- }
- else{
- D[i]['geometry'].length--;
+function initialiseSnapping(){
+// try {if(snappingTolerance){}}catch(e) {var snappingTolerance;}
+// try {if(snappingColor){}}catch(e) {var snappingColor;}
+ s = new Snapping(mod_digitize_target, snappingTolerance, snappingColor, true);
+}
+// --- registered functions (end) -----------------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------------------------------------------------
+
+// ------------------------------------------------------------------------------------------------------------------------
+// --- button handling (begin) --------------------------------------------------------------------------------------------
+
+function displayButtons(){
+// try {if(geomList_x){}}catch(e) {var geomList_x = 10;}
+// try {if(geomList_y){}}catch(e) {var geomList_y = 10;}
+// try {if(buttonDig_id.length){}}catch(e) {var buttonDig_id = new Array();alert("exception: no digitisation buttons found in element vars.")}
+ document.getElementById("listOfGeometries").setAttribute("style", "position:absolute; top:"+geomList_y+"; left:"+geomList_x+";");
+ for (var i = 0 ; i < buttonDig_id.length ; i ++) {
+ if (parseInt(buttonDig_on[i])==1) {
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", "div_" + buttonDig_id[i]);
+ divTag.setAttribute("style", "position:absolute; top:"+buttonDig_y[i]+"; left:"+buttonDig_x[i]+";");
+ document.getElementById("digButtons").appendChild(divTag);
+ var tagContent = "<img name=\""+buttonDig_id[i]+"\" onmouseover=\"parent.mb_regButton_frame('initDigButton', mod_digitize_elName, "+i+");\" id=\""+buttonDig_id[i]+"\" title=\""+buttonDig_titleUp[i]+"\" src=\""+buttonDig_srcUp[i]+"\">";
+ parent.writeTag(mod_digitize_elName,"div_" + buttonDig_id[i],tagContent);
}
}
- if (obj_id == "Polygon"){
- if (tmpLength > 0){
- D[i]['geometry'][j]['x'][tmpLength] = D[i]['geometry'][j]['x'][0];
- D[i]['geometry'][j]['y'][tmpLength] = D[i]['geometry'][j]['y'][0];
+}
+
+function initDigButton(ind, pos){
+ parent.mb_button[ind] = document.getElementById(buttonDig_id[pos]);
+ parent.mb_button[ind].img_over = buttonDig_srcUp[pos];
+ parent.mb_button[ind].img_on = buttonDig_srcDown[pos];
+ parent.mb_button[ind].img_off = buttonDig_srcUp[pos];
+ parent.mb_button[ind].title_on = buttonDig_titleUp[pos];
+ parent.mb_button[ind].title_off = buttonDig_titleDown[pos];
+ parent.mb_button[ind].status = 0;
+ parent.mb_button[ind].elName = buttonDig_id[pos];
+ parent.mb_button[ind].fName = "";
+ parent.mb_button[ind].go = new Function ("digitizeEnable(parent.mb_button["+ind+"])");
+ parent.mb_button[ind].stop = new Function ("digitizeDisable(parent.mb_button["+ind+"])");
+}
+
+function digitizeEnable(obj) {
+ if (obj.id == button_move || obj.id == button_insert || obj.id == button_delete) {
+ mod_digitizeEvent = obj.id;
+ executeDigitizePreFunctions();
+ }
+ else if (obj.id == button_point || obj.id == button_line || obj.id == button_polygon){
+ executeDigitizePreFunctions();
+ mod_digitizeEvent = obj.id;
+ obj.title = obj.title_off;
+ if (obj.id == button_point) {
+ d.addMember(geomTypePoint);
+ d.get(-1).addGeometry();
+ }
+ else if (obj.id == button_polygon) {
+ d.addMember(geomTypePolygon);
+ d.get(-1).addGeometry();
+ }
+ else if (obj.id == button_line) {
+ d.addMember(geomTypeLine);
+ d.get(-1).addGeometry();
}
+ s.store(d, mod_digitizeEvent);
+ var el = parent.frames[mod_digitize_target].document;
+ el.onmousemove = mod_digitize_go;
}
- drawDashedLine();
}
-function calculateDashes(pos0, pos1){
- // pos0 is leftmost point
- if (pos0[0] > pos1[0]){
- var pos_temp = new Array();
- pos_temp = pos0;
- pos0 = pos1;
- pos1 = pos_temp;
+function digitizeDisable(obj) {
+ if (obj.id == button_point || obj.id == button_line || obj.id == button_polygon){
+ obj.title = obj.title_on;
+ d.close();
+ mod_digitize_timeout();
+ executeDigitizeSubFunctions();
}
-
- var p = pos0;
- var q = pos1;
+}
+// --- button handling (end) ----------------------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------------------------------------------------
- var m;
- var draw = true;
-
+// -----------------------------------------------------------------------------------------------------------
+// --- display (begin) -----------------------------------------------------------------------------------------
+
+function updateExtent() {
+ var anInd = parent.getMapObjIndexByName(mod_digitize_target);
+ mod_digitize_width = parent.mb_mapObj[anInd].width;
+ mod_digitize_height = parent.mb_mapObj[anInd].height;
+ mod_digitize_epsg = parent.mb_mapObj[anInd].epsg;
+}
+
+function calculateActualDash(p0, p1, width, height) {
+ // p0 is leftmost point
+ 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; var draw = true;
+
// if line is not vertical
- if (pos1[0] != pos0[0]){
+ if (p1.x != p0.x) {
// calculate slope
- m = -(pos1[1]-pos0[1])/(pos1[0]-pos0[0]);
+ m = -(p1.y-p0.y)/(p1.x-p0.x);
// check if p is left of the right vertical of the screen && the line is not above or below the screen
- if (pos0[0] < mod_digitize_width && pos1[0] > 0
- && !(pos0[1] < 0 && pos1[1] < 0) && !(pos0[1] > mod_digitize_height && pos1[1] > mod_digitize_height)){
-
+ if (p0.x < width && p1.x > 0 && !(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height) ) {
+
// if p is left of the screen
- if (pos0[0] < 0){
-
+ if (p0.x < 0) {
+
//calculate intersection of line with left vertical of screen
- var iy = pos0[1] - m*(0-pos0[0]);
+ var iy = p0.y - m*(0-p0.x);
// if intersection is visible
- if (iy > 0 && iy < mod_digitize_height){
- p[0] = 0;
- p[1] = iy;
- }
+ if (iy > 0 && iy < height) {p = new Point(0, iy);}
// if intersection is below the screen
- else if (iy > mod_digitize_height){
+ else if (iy > height) {
// calculate intersection with lower horizontal
- var ix = pos0[0]+((pos0[1] - mod_digitize_height)/m);
- if (ix > 0 && ix < mod_digitize_width){
- p[0] = ix;
- p[1] = mod_digitize_height;
- }
- else{
- draw = false;
- }
+ var ix = p0.x+((p0.y - height)/m);
+ if (ix > 0 && ix < width) {p = new Point(ix, height);}
+ else draw = false;
}
// if intersection is above the screen
- else if (iy < 0){
+ else if (iy < 0) {
// calculate intersection with upper horizontal
- var ix = pos0[0]+(pos0[1]/m);
- if (ix > 0 && ix < mod_digitize_width){
- p[0] = ix;
- p[1] = 0;
- }
- else{
- draw = false;
- }
+ var ix = p0.x+(p0.y/m);
+ if (ix > 0 && ix < width) {p = new Point(ix, 0);}
+ else draw = false;
}
- else{
- draw = false;
- }
- }
- else if (pos0[1] >= 0 && pos0[1] <= mod_digitize_height){
- p[0] = pos0[0];
- p[1] = pos0[1];
+ else draw = false;
}
- else if (pos0[1] < 0){
+ else if (p0.y >= 0 && p0.y <= height) {p = p0;}
+ else if (p0.y < 0) {
// calculate intersection with upper horizontal
- var ix = pos0[0]+(pos0[1]/m);
- if (ix > 0 && ix < mod_digitize_width){
- p[0] = ix;
- p[1] = 0;
- }
- else{
- draw = false;
- }
+ var ix = p0.x+(p0.y/m);
+ if (ix > 0 && ix < width) {p = new Point(ix, 0);}
+ else draw = false;
}
- else if (pos0[1] > mod_digitize_height && m > 0){
+ else if (p0.y > height && m > 0) {
// calculate intersection with lower horizontal
- var ix = pos0[0]+((pos0[1] - mod_digitize_height)/m);
- if (ix > 0 && ix < mod_digitize_width) {
- p[0] = ix;
- p[1] = mod_digitize_height;
- }
- else{
- draw = false;
- }
- }
- else{
- draw = false;
+ var ix = p0.x+((p0.y - height)/m);
+ if (ix > 0 && ix < width) {p = new Point(ix, height);}
+ else draw = false;
}
-
+ else draw = false;
+
// calculate q coordinates
- if (draw == true){
-
+ if (draw == true) {
+
// q is right of the screen
- if (pos1[0] > mod_digitize_width){
+ if (p1.x > width) {
// calculate intersection with right vertical of the screen
- var iy = pos1[1] - m*(mod_digitize_width-pos1[0]);
+ var iy = p1.y - m*(width-p1.x);
- if (iy > 0 && iy < mod_digitize_height){
- q[0] = mod_digitize_width;
- q[1] = iy;
- }
- else if (iy < 0){
+ if (iy > 0 && iy < height) {q = new Point(width, iy);}
+ else if (iy < 0) {
// calculate intersection with upper horizontal
- var ix = pos0[0]+(pos0[1]/m);
- if (ix > 0 && ix < mod_digitize_width){
- q[0] = ix;
- q[1] = 0;
- }
- else{
- draw = false;
- }
+ var ix = p0.x+(p0.y/m);
+ if (ix > 0 && ix < width) {q = new Point(ix, 0);}
+ else draw = false;
}
- else if (iy > mod_digitize_height){
+ else if (iy > height) {
// calculate intersection with lower horizontal
- var ix = pos0[0]+((pos0[1] - mod_digitize_height)/m);
- if (ix > 0 && ix < mod_digitize_width){
- q[0] = ix;
- q[1] = mod_digitize_height;
- }
- else{
- draw = false;
- }
+ var ix = p0.x+((p0.y - height)/m);
+ if (ix > 0 && ix < width) {q = new Point(ix, height);}
+ else draw = false;
}
- else{
- draw = false;
- }
- }
- else if (pos1[1] >= 0 && pos1[1] <= mod_digitize_height){
- q[0] = pos1[0];
- q[1] = pos1[1];
+ else draw = false;
}
- else if (pos1[1] < 0){
+ else if (p1.y >= 0 && p1.y <= height) {q = p1;}
+ else if (p1.y < 0) {
// calculate intersection with upper horizontal
- var ix = pos1[0]+(pos1[1]/m);
- if (ix > 0 && ix < mod_digitize_width){
- q[0] = ix;
- q[1] = 0;
- }
- else{
- draw = false;
- }
+ var ix = p1.x+(p1.y/m);
+ if (ix > 0 && ix < width) {q = new Point(ix, 0);}
+ else draw = false;
}
- else if (pos1[1] > mod_digitize_height){
+ else if (p1.y > height) {
// calculate intersection with lower horizontal
- var ix = pos1[0]+((pos1[1]- mod_digitize_height)/m) ;
- if (ix > 0 && ix < mod_digitize_width){
- q[0] = ix;
- q[1] = mod_digitize_height;
- }
- else{
- draw = false;
- }
+ var ix = p1.x+((p1.y- height)/m) ;
+ if (ix > 0 && ix < width) {q = new Point(ix, height);}
+ else draw = false;
}
}
}
- else{
- draw = false;
- }
+ else draw = false;
}
// the line is vertical
- else{
- // x-Coordinates remain
- p[0] = pos0[0];
- q[0] = pos0[0];
-
+ else {
// check if line is not above or below the screen
- if (!(pos0[1] < 0 && pos1[1] < 0) && !(pos0[1] > mod_digitize_height && pos1[1] > mod_digitize_height)){
- if (pos0[1] < 0){
- p[1] = 0;
- }
- else if (pos0[1] > mod_digitize_height){
- p[1] = mod_digitize_height;
- }
- else{
- p[1] = pos0[1];
- }
- if (pos1[1] < 0){
- q[1] = 0;
- }
- else if (pos1[1] > mod_digitize_height){
- q[1] = mod_digitize_height;
- }
- else{
- q[1] = pos1[1];
- }
- }
- else{
- draw = false;
+ 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 draw = false;
}
-
- if (draw == true){
+
+ if (draw == true) {
var points = new Array();
- points[0] = Math.round(q[0]);
- points[1] = Math.round(q[1]);
- points[2] = Math.round(p[0]);
- points[3] = Math.round(p[1]);
+ points[0] = new Point(Math.round(q.x), Math.round(q.y));
+ points[1] = new Point(Math.round(p.x), Math.round(p.y));
return points;
}
- else{
- return false;
- }
+ else return false;
}
function drawDashedLine(){
+
var smP = "";
smP += "<div class='t_img'>";
smP += "<img src='"+parent.mb_trans.src+"' width='"+mod_digitize_width+"' height='0'></div>";
smP += "<div class='t_img'>";
- smP += "<img src='"+parent.mb_trans.src+"' width='0' height='"+mod_digitize_height+"'></div>";
- // *all* members will be painted
- for(var i=0; i<D.length; i++){
-
- // paint all geometries of member i
- for(var j=0; j<D[i]['geometry'].length; j++){
- //
- // paint the basepoints
- //
- for(var k=0; k<D[i]['geometry'][j]['x'].length; k++){
- // calculate screen position from real world coordinates
- var pos = parent.makeRealWorld2mapPos(mod_digitize_target,D[i]['geometry'][j]['x'][k],D[i]['geometry'][j]['y'][k]);
-
- // if this geometry is a point
- if(D[i]['geomtype'].toLowerCase() == "point"){
- // smP += "<div class='label' style='top:"+(pos[1]-6)+"px;left:"+(pos[0])+"px;z-index:50;'>"+D[i]['label']+"</div>";
- }
+ smP += "<img src='"+parent.mb_trans.src+"' width='0' height='"+mod_digitize_height+"'></div>";
- smP += "<div class='bp' style='top:"+(pos[1]-2)+"px;left:"+(pos[0]-2)+"px;z-index:50;'";
- if(j==0 && D[i]['geomtype'].toLowerCase() == 'polygon' && D[i]['geometry'][j]['complete'] == false){
+ for(var i=0; i<d.count(); i++){
+ for(var j=0; j<d.get(i).count(); j++){
+ for(var k = 0; k < d.getGeometry(i,j).count(); k++){
+ var pos = parent.makeRealWorld2mapPos(mod_digitize_target,d.getPoint(i,j,k).x,d.getPoint(i,j,k).y);
+
+ if (!d.getGeometry(i,j).isComplete() &&
+ ( (k == 0 && d.get(i).geomtype == geomTypePolygon) || (k == d.getGeometry(i,j).count()-1 && d.get(i).geomtype == geomTypeLine))) {
+ smP += "<div class='bp' style='top:"+(pos[1]-2)+"px;left:"+(pos[0]-2)+"px;z-index:50;background-color:"+linepointColor+"'";
+ }
+ else {
+ smP += "<div class='bp' style='top:"+(pos[1]-2)+"px;left:"+(pos[0]-2)+"px;z-index:50;'";
+ }
+ if(j==0 && d.get(i).geomtype == geomTypePolygon && d.getGeometry(i,j).complete == false){
smP += " title='to close polygon, release the polygon button on the left' ";
}
- if(isOn){
+ if(mod_digitizeEvent == button_move || mod_digitizeEvent == button_insert || mod_digitizeEvent == button_delete) {
smP += " onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].handleBasepoint(this,"+i+","+j+","+k+")' ;";
}
smP += "></div>";
}
- //
- // paint the lines between basepoints
- //
- for(var k = 1; k < D[i]['geometry'][j]['x'].length; k++){
+ for(var k = 1; k < d.getGeometry(i,j).count(); k++){
+ var p0 = parent.realToMap(mod_digitize_target, d.getPoint(i,j,k));
+ var p1 = parent.realToMap(mod_digitize_target, d.getPoint(i,j,k-1));
- var pos0 = parent.makeRealWorld2mapPos(mod_digitize_target, D[i]['geometry'][j]['x'][k] , D[i]['geometry'][j]['y'][k]);
- var pos1 = parent.makeRealWorld2mapPos(mod_digitize_target, D[i]['geometry'][j]['x'][k-1], D[i]['geometry'][j]['y'][k-1]);
-
-
- points = calculateDashes(pos0, pos1);
- if (points != false){
- smP += evaluateDashes(points[0], points[1], points[2], points[3], i, j, k);
+ points = calculateActualDash(p0, p1, mod_digitize_width, mod_digitize_height);
+ if (points != false) {
+ smP += evaluateDashes(points[0], points[1], i, j, k);
}
}
}
}
parent.writeTag(mod_digitize_target,"digitize",smP);
- updateListOfGeometries();
}
-function evaluateDashes(startX, startY, endX, endY, memberIndex, geomIndex, pointIndex){
+function evaluateDashes(start, end, memberIndex, geomIndex, pointIndex){
var str_dashedLine = "";
- var deltaX = endX - startX;
- var deltaY = endY - startY;
-
- // s = distance between two linepoints
- var s = 10;
- var vecLength = dist(startX, startY, endX, endY);
- var n = Math.round(vecLength/s);
- var stepX = deltaX/n;
- var stepY = deltaY/n;
+ var delta = new Point(end.x - start.x, end.y - start.y);
+
+ var vecLength = start.dist(end);
+ var n = Math.round(vecLength/dotDistance);
+ var step = new Point(delta.x/n, delta.y/n);
for(var i=1; i<n; i++){
- var x = Math.round(startX + i * stepX) - 2;
- var y = Math.round(startY + i * stepY) - 2;
+ var x = Math.round(start.x + i * step.x) - 2;
+ var y = Math.round(start.y + i * step.y) - 2;
if(x >= 0 && x <= mod_digitize_width && y >= 0 && y <= mod_digitize_height){
- str_dashedLine += "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:50;' ";
- if(isOn){
+ if (memberIndex == d.count()-1 && !d.getGeometry(-1,-1).isComplete()) {
+ str_dashedLine += "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:50;background-color:"+linepointColor+"' ";
+ }
+ else {
+ str_dashedLine += "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:50;' ";
+ }
+ if(mod_digitizeEvent == button_insert) {
str_dashedLine += "onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].convertLinepointToBasepoint(this,"+memberIndex+","+geomIndex+","+pointIndex+")'>";
}
str_dashedLine += "</div>";
@@ -834,443 +627,125 @@
return str_dashedLine;
}
-function handleBasepoint(Obj,memberIndex,geometryIndex,pointIndex){
- if(!isOn){
- return false;
- };
-
- // set the global variables that will be used in deleteBasepoint etc.
- basepointObject = Obj;
- basepointMemberIndex = memberIndex;
- basepointGeometryIndex = geometryIndex;
- basepointPointIndex = pointIndex;
-
- if(mod_digitizeEvent == "dragBasePoint" && activeButton == 'dragBasePoint'){
- mod_digitize_timeout();
- basepointObject.style.cursor = 'move';
- basepointObject.onmousedown = parent.window.frames[mod_digitize_elName].selectBasepoint;
- }
-/*
- if(mod_digitizeEvent == false && D[memberIndex]['geomtype'].toLowerCase() == 'polygon' && D[memberIndex]['geometry'][geometryIndex].complete == false){
- basepointObject.onmousedown = parent.window.frames[mod_digitize_elName].closeGeometry("Polygon");
- }
-*/
- if(mod_digitizeEvent == "delBasePoint" && activeButton == 'delBasePoint'){
- mod_digitize_timeout();
- basepointObject.style.cursor = 'crosshair';
- basepointObject.onmousedown = parent.window.frames[mod_digitize_elName].deleteBasepoint;
- }
-}
-
-function deleteBasepoint(e){
-
- var i = basepointMemberIndex;
- var j = basepointGeometryIndex;
- var k = basepointPointIndex;
-
- var xCoord = D[i]['geometry'][j]['x'][k];
- var yCoord = D[i]['geometry'][j]['y'][k];
-
- var deleted = false;
-
- while (deleted == false){
- var continueFor = true;
- deleted = true;
-
- //find points of other geometries with the same coordinates and delete them as well
- for (var l = 0 ; l < D.length && continueFor == true; l ++){
- for (var m = 0; m < D[l]['geometry'].length && continueFor == true; m++){
- for (var n = 0; n < D[l]['geometry'][m]['x'].length && continueFor == true ; n++){
- if (D[l]['geometry'][m]['x'][n] == xCoord && D[l]['geometry'][m]['y'][n] == yCoord){
- deletePoint(l,m,n);
- continueFor = false;
- deleted = false;
- }
- }
- }
- }
- }
-}
+function updateListOfGeometries(){
+ var listOfGeom = "<table>\n";
+ for (var i = 0 ; i < d.count(); i ++) {
+ listOfGeom += "\t<tr>\n\t\t<td>\n";
+ listOfGeom += "\t\t\t<img src = '../img/button_digitize/geomInfo.png' title='WFS conf' onclick='showWfs("+i+")'>\n";
+ listOfGeom += "\t\t</td>\n\t\t<td>\n";
+ listOfGeom += "\t\t\t<img src = '../img/button_digitize/geomRemove.png' title='delete this " + d.get(i).geomtype + "' onclick='parent.mb_disableThisButton(mod_digitizeEvent);d.del("+i+");executeDigitizeSubFunctions();'>\n";
+ listOfGeom += "\t\t</td>\n\t\t<td style = 'color:blue;font-size:12px'>\n";
+ listOfGeom += "\t\t\t<div onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+"));' ";
+ listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+"))' ";
-function deletePoint(i,j,k){
- // the last point is being deleted...
- if ( (k == 0 || (D[i]['geometry'][j]['x'].length - k) == 1) && D[i]['geomtype'].toLowerCase() == 'polygon'){
- // if the last basepoint of a polygon is being deleted,
- // the first basepoint is now set to be the last but one as well,
- // in order to close the polygon
-
- // Shorten the array by one
- D[i]['geometry'][j]['x'].length = D[i]['geometry'][j]['x'].length - 1;
- D[i]['geometry'][j]['y'].length = D[i]['geometry'][j]['y'].length - 1;
-
- // if only one point is left (which has been stored twice), remove it as well
- if (D[i]['geometry'][j]['x'].length == 1){
- D[i]['geometry'][j]['x'].length = 0;
- D[i]['geometry'][j]['y'].length = 0;
+ if (d.get(i).wfs_conf != -1) {
+ listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+"));' ";
}
- // point that will be deleted is not the only point of the geometry
else{
-
- // place a copy of the last point at index 0
- var tmpIndex = D[i]['geometry'][j]['x'].length - 1;
- D[i]['geometry'][j]['x'][0] = D[i]['geometry'][j]['x'][tmpIndex];
- D[i]['geometry'][j]['y'][0] = D[i]['geometry'][j]['y'][tmpIndex];
- }
- }
- //
- // a point that is *not* the last point of a geometry is being deleted
- //
- else{
- // move basepoints behind deleted basepoints up by one...
- for(var z= k; z<D[i]['geometry'][j]['x'].length-1; z++){
- D[i]['geometry'][j]['x'][z] = D[i]['geometry'][j]['x'][z+1];
- D[i]['geometry'][j]['y'][z] = D[i]['geometry'][j]['y'][z+1];
- }
- // ...and adjust length of the array
- D[i]['geometry'][j]['x'].length = D[i]['geometry'][j]['x'].length - 1;
- D[i]['geometry'][j]['y'].length = D[i]['geometry'][j]['y'].length - 1;
- }
- // if all basepoints of this geometry have been deleted...
- if (D[i]['geometry'][j]['x'].length == 0){
- deleteGeometry(i, j);
- }
- else{
- drawDashedLine();
- //resetButtonsIfNoMembersLeft();
- }
-}
-
-function deleteGeometry (indexMember, indexGeometry){
- var i = indexMember;
- var j = indexGeometry;
- // check whether the deleted geometry is the only geometry of the member...
- if (D[i]['geometry'].length == 1){
- deleteMember(i);
- }
- // ...if not, move other geometries one spot up
- else{
- var tmpLength = D[i]['geometry'].length - 1;
- for (var z = j; z < tmpLength ; z ++){
- D[i]['geometry'][z] = D[i]['geometry'][z+1];
- D[i]['element'][z] = D[i]['element'][z+1];
- }
- D[i]['geometry'].length -= 1;
-
- drawDashedLine();
- resetButtonsIfNoMembersLeft();
- }
-}
-
-function deleteMember(index){
- // delete geometry itself...
- for(var z = index ; z < D.length - 1; z++){
- D[z] = D[z+1];
- }
- // ... and adjust length of geometry array
- D.length -= 1;
-
- drawDashedLine();
-}
-
-function convertLinepointToBasepoint(obj, memberIndex, geomIndex, pointIndex){
- if(!isOn){
- return false;
- };
-
- if(mod_digitizeEvent == "setBasePoint" && activeButton == 'setBasePoint'){
- mod_digitize_timeout();
- obj.style.cursor = 'crosshair';
- obj.onclick = insertBasepoint;
-
- basepointObject = obj;
- basepointMemberIndex = memberIndex;
- basepointGeometryIndex = geomIndex;
- basepointPointIndex = pointIndex;
- }
-}
-
-function insertBasepoint(e){
- var i = basepointMemberIndex;
- var j = basepointGeometryIndex;
- var k = basepointPointIndex;
-
- parent.mb_getMousePos(e, mod_digitize_target);
- var pos = parent.makeClickPos2RealWorldPos(mod_digitize_target,parent.clickX, parent.clickY);
-
- for(var z = D[i]['geometry'][j]['x'].length; z > k; z--){
- D[i]['geometry'][j]['x'][z] = D[i]['geometry'][j]['x'][z-1];
- D[i]['geometry'][j]['y'][z] = D[i]['geometry'][j]['y'][z-1];
- }
-
- D[i]['geometry'][j]['x'][k] = pos[0];
- D[i]['geometry'][j]['y'][k] = pos[1];
-
- drawDashedLine();
-}
-
-function selectBasepoint(e){
- if(basepointDragActive == false && mod_digitizeEvent == "dragBasePoint"){
- basepointDragActive = true;
- storeSnappingCoordinates();
- basepointObject.onmouseup = releaseBasepoint;
- basepointObject.onmousemove = dragBasepoint;
- }
-}
-
-function dist(startX, startY, endX, endY){
- var deltaX = endX - startX;
- var deltaY = endY - startY;
-
- return Math.sqrt(Math.pow(deltaY,2) + Math.pow(deltaX,2)) ;
-}
-
-function dragBasepoint(e){
- if(basepointDragActive){
- parent.mb_getMousePos(e, mod_digitize_target);
- checkSnapped(parent.clickX, parent.clickY, 'move');
- }
-}
-
-function removeDuplicates(i, j){
- var length1 = D[i]['geometry'][j]['x'].length;
- var continueFor = true;
- for (var k = 2; k < length1 && continueFor == true ; k++){
- if (D[i]['geometry'][j]['x'][k] == D[i]['geometry'][j]['x'][k-1] && D[i]['geometry'][j]['y'][k] == D[i]['geometry'][j]['y'][k-1]){
- deletePoint(i,j,k-1);
- continueFor = false;
- }
- }
-}
-
-function releaseBasepoint(e){
- var i = basepointMemberIndex;
- var j = basepointGeometryIndex;
- var k = basepointPointIndex;
-
- basepointDragActive = false;
-
- parent.mb_getMousePos(e, mod_digitize_target);
- basepointDragEndX = parent.clickX;
- basepointDragEndY = parent.clickY;
- basepointObject.onmousedown = null;
- var pos = parent.makeClickPos2RealWorldPos(mod_digitize_target, basepointDragEndX, basepointDragEndY);
-
- if (snapped == true){
- cleanCanvas();
-
- pos[0] = D[snappedMember]['geometry'][snappedGeometry]['x'][snappedPoint];
- pos[1] = D[snappedMember]['geometry'][snappedGeometry]['y'][snappedPoint];
- }
-
- if ((k == D[i]['geometry'][j]['x'].length - 1 || k == 0) && D[i]['geometry'][j]['complete'] == true && D[i]['geomtype'].toLowerCase() == 'polygon'){
- D[i]['geometry'][j]['x'][0] = pos[0];
- D[i]['geometry'][j]['y'][0] = pos[1];
- }
-
- // check if there are points in other geometries with the same coordinates
- for (var l = 0; l < D.length ; l++){
- for (var m = 0 ; m < D[l]['geometry'].length ; m++){
- for (n = 0 ; n < D[l]['geometry'][m]['x'].length ; n++){
- // this line would enable merging of snapped points of the same geometry
- // if ((l != i || m != j) && D[i]['geometry'][j]['x'][k] == D[l]['geometry'][m]['x'][n] && D[i]['geometry'][j]['y'][k] == D[l]['geometry'][m]['y'][n]){
- if (D[i]['geometry'][j]['x'][k] == D[l]['geometry'][m]['x'][n] && D[i]['geometry'][j]['y'][k] == D[l]['geometry'][m]['y'][n]){
- D[l]['geometry'][m]['x'][n] = pos[0];
- D[l]['geometry'][m]['y'][n] = pos[1];
- if (snapped == true){
- removeDuplicates(l,m);
- }
- }
- }
- }
- }
-
- D[i]['geometry'][j]['x'][k] = pos[0];
- D[i]['geometry'][j]['y'][k] = pos[1];
- if (snapped == true){
- removeDuplicates(i,j);
+ listOfGeom += " onclick='parent.zoom(mod_digitize_target,\"true\", 1.0, " + d.get(i).getCenter().x + ", " + d.get(i).getCenter().y + ");' ";
}
-
- snapped = false;
- drawDashedLine();
- }
-
-function cloneObject(someArray){
- var a = someArray;
- var z = new Array();
+ var geomName = d.get(i).e.getElementValueByName("name");
+ if (!geomName) {geomName = "new";}
+ if (d.get(i).geomtype == geomTypePolygon) {geomName += " (Py)";}
+ else if (d.get(i).geomtype == geomTypeLine) {geomName += " (Li)";}
+ else if (d.get(i).geomtype == geomTypePoint) {geomName += " (Pt)";}
- for (attr in a){
- var b = a[attr];
-
- if (typeof(b) == "object"){
- z[attr] = cloneObject(b);
- }
- else{
- z[attr] = b;
- }
- }
- return z;
-}
-
-function cloneGeometryArray(originalArray){
- z = cloneObject(originalArray);
-
- // add the attribute 'complete' for every geometry
- for (var i = 0 ; i < originalArray['geometry'].length ; i ++){
- z['geometry'][i]['complete'] = true;
+ listOfGeom += ">" + geomName +"</div>\t\t</td>\n";
}
- return z;
-}
-
-function addMember(newMember){
- var index = D.length;
- D[index] = new Array();
-
- D[index] = cloneGeometryArray(newMember);
-
- mod_digitize_go();
- drawDashedLine();
-}
-
-function setEvent(obj){
- mod_digitizeEvent = obj.id;
-}
-
-function delEvent(){
- mod_digitizeEvent = false;
- mod_digitize_go();
-}
-
-function displayObject(someArray){
- var a = someArray;
- var str = "";
-
- for (attr in a){
- b = a[attr];
-
- if (typeof(b) == "object"){
- str += "<br>" + attr + "<br>";
- str += displayObject(b);
- }
- else{
- str += attr + ": " + b + "<br>";
- }
- }
- return str;
+ listOfGeom += "</table>\n";
+ parent.writeTag(mod_digitize_elName,"listOfGeometries",listOfGeom);
}
+// --- display (end) -----------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------
+// returns a form with the elements of a selected wfs
+// (if the original wfs is the selected wfs, the values are set too)
function buildElementForm(wfsConfIndex, memberIndex){
var selMember = memberIndex;
- // if the selected wfs is not the original wfs,
- // the form template, updating and deleting are disabled.
- if (parseInt(D[memberIndex]['wfs_conf']) != parseInt(wfsConfIndex)){
- memberIndex = -1;
- }
+ if (parseInt(d.get(memberIndex).wfs_conf) != parseInt(wfsConfIndex)) {memberIndex=-1;}
var str = "";
-
- // the wfs conf needs to have a gid and a geom, otherwise saving does not work
var gid = false;
var geom = false;
-
var wfs = wfs_conf[wfsConfIndex];
-
var memEl;
- if (parseInt(memberIndex) != -1){
- memEl = D[memberIndex]['element'];
+
+ if (parseInt(memberIndex) != -1) {
+ memEl = d.get(memberIndex).e;
}
-
+
// search attribute 'element' in wfsConfArray
- for (attr in wfs){
- if (attr == "element"){
+ for (attr in wfs) {
+ if (attr == "element") {
str += "<form id='wfs_conf'>\n\t<table>\n";
-
b = wfs[attr];
-
- // get the 'element name' of wfsConfArray['element'][i]
- for (var i = 0 ; i < b.length ; i ++){
+
+ for (var i = 0 ; i < b.length ; i ++) {
var c = b[i];
-
var wfsElementName = c['element_name'];
-
- // don't display geoms
- if (parseInt(c['f_geom']) != 1){
+
+ if (parseInt(c['f_geom']) != 1) {
-
- if (parseInt(wfs['element'][i]['f_gid']) == 1){
+ if (parseInt(wfs['element'][i]['f_gid']) == 1) {
gid = wfsElementName;
}
-
- // display the element name and an input row for its value
str += "\t\t<tr>\n\t\t\t<td>\n";
str += "\t\t\t\t" + wfsElementName + "\n\t\t\t</td>\n\t\t\t<td colspan = 2>\n";
str += "\t\t\t\t<input name='" + wfsElementName + "' type='text' size=20 ";
+
+ if (parseInt(memberIndex) != -1) {
- // only if the selected wfs is the original wfs!
- if (parseInt(memberIndex) != -1){
- // get the 'element name' of memberArray['element'][j]
- for (var j = 0 ; j < memEl.length ; j ++){
- currentElementName = memEl[j]['name'];
- // if the element is in both objects, display the value as default
- if (currentElementName == wfsElementName){
- str += "value = '" + memEl[j]['val'] + "' ";
+ for (var j = 0 ; j < memEl.count() ; j ++) {
+ currentElementName = memEl.getName(j);
+ if (currentElementName == wfsElementName) {
+ str += "value = '" + memEl.getValue(j) + "' ";
}
}
}
- str += ">\n";
- str += "\t\t\t</td>\n\t\t</tr>\n";
+ str += ">\n\t\t\t</td>\n\t\t</tr>\n";
}
- else{
- geom = wfsElementName;
- }
+ else geom = wfsElementName;
}
-
- // generating buttons "save", "update", "delete"
- // a wfs_transaction url is required.
- if (wfs['wfs_transaction']){
+
+ if (wfs['wfs_transaction']) {
str += "\t\t<tr>\n";
- // if not all buttons will be generated, the missing columns will be generated afterwards.
+
var colspan = 0;
-
- if (geom){
+ if (geom) {
str += "\t\t\t<td><input type='button' name='saveButton' value='Save' onclick='window.opener.saveGeom("+selMember+")' /></td>\n";
}
- else{
- colspan++;
- }
- if (parseInt(memberIndex) != -1 && gid){
- if (geom){
+ else colspan++;
+
+ if (parseInt(memberIndex) != -1 && gid) {
+ if (geom) {
str += "\t\t\t<td><input type='button' name='updateButton' value='Update' onclick='window.opener.updateGeom("+selMember+")'/></td>\n";
}
- else{
- colspan++;
- }
+ else colspan++;
str += "\t\t\t<td><input type='button' name='deleteButton' value='Delete' onclick='window.opener.deleteGeom("+selMember+")'/></td>\n";
}
- else{
- colspan++;
- }
-
- if (colspan > 0 && colspan < 3){
+ else colspan++;
+
+ if (colspan > 0 && colspan < 3) {
str += "\t\t\t<td colspan = " + colspan + "></td>\n";
}
-
str += "\t\t</tr>";
}
str += "\t</table>\n";
- // str += "<input type='text' name='mb_geom'>";
- // str += "<input type='text' name='mb_wfs_conf'>";
+// str += "<input type='text' name='mb_geom'>";
+// str += "<input type='text' name='mb_wfs_conf'>";
str += "</form>\n";
}
}
return str;
}
-
-
- //
- //
- //
-function showWfs(index){
+
+
+//
+// this method opens a new window and displays the attributes in wfs_conf
+//
+function showWfs(index) {
+
wfsWindow = open("", "wfsattributes", "width=300, height=300, resizable, dependent=yes, scrollbars=yes");
wfsWindow.document.open("text/html");
wfs_conf = parent.get_complete_wfs_conf();
@@ -1281,80 +756,31 @@
str += " onChange='document.getElementById(\"elementForm\").innerHTML = window.opener.buildElementForm(this.value , " + index + ")'";
str += ">\n\t\t";
- for (var attr in wfs_conf){
+ for (var attr in wfs_conf) {
str += "<option value='" + attr + "'";
// if the geometry is already associated with a wfs
- if (parseInt(D[index]['wfs_conf']) == parseInt(attr)){
+ if (parseInt(d.get(index).wfs_conf) == parseInt(attr)) {
str += " selected";
defaultIndex = parseInt(attr);
}
str += ">" + wfs_conf[attr]['wfs_conf_abstract'];
str += "</option>\n\t\t";
-
+
}
str += "</select>\n\t\t</form>\n\t";
str += "<div id='elementForm'>\n</div>\n";
-
+
wfsWindow.document.write(str);
wfsWindow.document.close();
- if (defaultIndex != -1){
+ if (defaultIndex != -1) {
wfsWindow.document.getElementById("elementForm").innerHTML = buildElementForm(defaultIndex, index);
}
}
-function updateListOfGeometries(){
- var listOfGeom = "";
-
- if (D.length > 0){
- listOfGeom += "<table>\n";
- }
-
- for (var i = 0 ; i < D.length; i ++){
- listOfGeom += "\t<tr>\n";
- listOfGeom += "\t\t<td>\n";
- listOfGeom += "\t\t\t<img src = '../img/button_digitize/geomInfo.png' title='WFS conf' onclick='showWfs("+i+")'>\n";
- listOfGeom += "\t\t</td>\n";
- listOfGeom += "\t\t<td>\n";
- listOfGeom += "\t\t\t<img src = '../img/button_digitize/geomRemove.png' title='delete this " + D[i]['geomtype'] + "' onclick='deleteMember("+i+")'>\n";
- listOfGeom += "\t\t</td>\n";
- listOfGeom += "\t\t<td style = 'color:blue'>\n";
- listOfGeom += "\t\t\t<div onmouseover='parent.mb_wfs_perform(\"over\",D["+i+"])' ";
- listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",D["+i+"])' ";
-
- // if a geometry is a wfs result -> zoom to geometry
-
- if (D[i]['wfs_conf'] != -1){
- listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",D["+i+"]);' ";
- }
- // ... a geometry has been digitized by hand -> zoom to first point (FIXME: zooming to the entire geometry would be better)
- else{
- listOfGeom += " onclick='parent.zoom(mod_digitize_target,\"true\", 1.0, " + D[i]['geometry'][0]['x'][0] + ", " + D[i]['geometry'][0]['y'][0] + ");' ";
- }
- var geomName = parent.getElementValueByName(D, i, "name");
- if (!geomName){
- geomName = "new";
- }
- var suffix = " ";
- if (D[i]['geomtype'] == "Polygon"){
- suffix += "(Py)";
- }
- else if (D[i]['geomtype'] == "Line"){
- suffix += "(Li)";
- }
- if (D[i]['geomtype'] == "Point"){
- suffix += "(Pt)";
- }
-
- listOfGeom += ">" + geomName + suffix +"</div>";
- listOfGeom += "\t\t</td>\n";
- }
-
- if (D.length > 0){
- listOfGeom += "</table>\n";
- }
- parent.writeTag(mod_digitize_elName,"listOfGeometries",listOfGeom);
+function mod_saveGeom() {
+ dwin = window.open("../php/mod_wfs_save.php","dwin","width=300,height=200");
}
function saveGeom(m){
@@ -1362,25 +788,19 @@
var ind = myform.wfs.selectedIndex;
var wfs = myform.wfs.options[ind].value;
myform = wfsWindow.document.forms[1];
- D[m]['wfs_conf'] = wfs;
- D[m]['element'] = new Array();
- D[m]['element']['name'] = new Array();
- D[m]['element']['val'] = new Array();
+ d.get(m).wfs_conf = wfs;
+ d.get(m).e = new Wfs_element();
var cnt = 0;
for( var i=0; i<myform.length; i++){
if(myform.elements[i].type == 'text'){
- D[m]['element'][cnt] = new Array();
- D[m]['element'][cnt]['name'] = myform.elements[i].name;
- D[m]['element'][cnt]['val'] = myform.elements[i].value;
- cnt++;
+ d.get(m).e.setElement(myform.elements[i].name, myform.elements[i].value);
}
}
- // alert(wfs_conf[D[m]['wfs_conf']]['wfs_transaction']);
- var myconf = wfs_conf[D[m]['wfs_conf']];
+ var myconf = wfs_conf[d.get(m).wfs_conf];
document.sendForm.url.value = myconf['wfs_transaction'];
var str = '<wfs:Transaction version="1.0.0" service="WFS" ';
- for (var q = 0 ; q < myconf['namespaces'].length ; q++){
+ for (var q = 0 ; q < myconf['namespaces'].length ; q++) {
//alert('xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ');
str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
}
@@ -1388,11 +808,11 @@
str += 'xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&typename=mapbender_user http://www.opengis.net/wfs../wfs/1.0.0/WFS-transaction.xsd">';
str += '<wfs:Insert>';
str += '<'+ myconf['featuretype_name']+'>';
- for(var i=0; i<D[m]['element'].length; i++){
- if(D[m]['element'][i]['val'] != ""){
- var tmp = D[m]['element'][i]['name'];
+ for(var i=0; i<d.get(m).e.count(); i++){
+ if(d.get(m).e.getValue(i) != ""){
+ var tmp = d.get(m).e.getName(i);
str += '<' + tmp + '>';
- str += D[m]['element'][i]['val'];
+ str += d.get(m).e.getValue(i);
str += '</' + tmp + '>';
}
}
@@ -1427,8 +847,7 @@
// str += '</gml:lineStringMember>';
// str += '</gml:MultiLineString>';
// }
-
- if(D[m]['geomtype'] == 'Polygon'){
+ if(d.get(m).geomtype == geomTypePolygon){
str += '<gml:MultiPolygon srsName="epsg:4326">';
str += '<gml:polygonMember>';
str += '<gml:Polygon>';
@@ -1436,11 +855,11 @@
str += '<gml:LinearRing>';
str += '<gml:coordinates>';
- for(var k=0; k<D[m]['geometry'][0]['x'].length; k++){
+ for(var k=0; k<d.getGeometry(m,0).count(); k++){
if(k>0){
str += " ";
}
- str += D[m]['geometry'][0]['x'][k] + "," + D[m]['geometry'][0]['y'][k];
+ str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
}
str += '</gml:coordinates>';
str += '</gml:LinearRing>';
@@ -1453,43 +872,40 @@
str += '</'+ myconf['featuretype_name']+'>';
str += '</wfs:Insert>';
str += '</wfs:Transaction>';
- document.forms[1].filter.value = str;
- document.forms[1].submit();
+ document.sendForm.filter.value = str;
+ document.sendForm.submit();
+// document.forms[1].filter.value = str;
+// document.forms[1].submit();
return false;
}
-
function updateGeom(m){
var myid_value;
var myform = wfsWindow.document.forms[0];
var ind = myform.wfs.selectedIndex;
var wfs = myform.wfs.options[ind].value;
myform = wfsWindow.document.forms[1];
- D[m]['wfs_conf'] = wfs;
- D[m]['element'] = new Array();
- D[m]['element']['name'] = new Array();
- D[m]['element']['val'] = new Array();
+ d.get(m).wfs_conf = wfs;
+ d.get(m).e = new Wfs_element();
var cnt = 0;
for( var i=0; i<myform.length; i++){
if(myform.elements[i].type == 'text'){
- D[m]['element'][cnt] = new Array();
- D[m]['element'][cnt]['name'] = myform.elements[i].name;
- D[m]['element'][cnt]['val'] = myform.elements[i].value;
- if(D[m]['element'][cnt]['name'] == 'gid'){
- myid_value = D[m]['element'][cnt]['val'];
+ d.get(m).e.setElement(myform.elements[i].name, myform.elements[i].value);
+ if(d.get(m).e.getName(cnt) == 'gid'){
+ myid_value = d.get(m).e.getValue(cnt);
}
cnt++;
}
}
- // alert(wfs_conf[D[m]['wfs_conf']]['wfs_transaction']);
- var myconf = wfs_conf[D[m]['wfs_conf']];
+// alert(wfs_conf[D[m]['wfs_conf']]['wfs_transaction']);
+ var myconf = wfs_conf[d.get(m).wfs_conf];
document.sendForm.url.value = myconf['wfs_transaction'];
var str = '<wfs:Transaction version="1.0.0" service="WFS" xmlns="http://www.someserver.com/myns" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&typename=mapbender_user http://www.opengis.net/wfs../wfs/1.0.0/WFS-transaction.xsd" xmlns:topp="http://www.someserver.com/topp">';
str += '<wfs:Update typeName="'+ myconf['featuretype_name']+'">';
- for(var i=0; i<D[m]['element'].length; i++){
- if(D[m]['element'][i]['val'] != ""){
+ for(var i=0; i<d.get(m).e.count(); i++){
+ if(d.get(m).e.getValue(i) != ""){
str += '<wfs:Property>';
- str += '<wfs:Name>'+D[m]['element'][i]['name']+'</wfs:Name>';
- str += '<wfs:Value>'+D[m]['element'][i]['val']+'</wfs:Value>';
+ str += '<wfs:Name>'+d.get(m).e.getName(i)+'</wfs:Name>';
+ str += '<wfs:Value>'+d.get(m).e.getValue(i)+'</wfs:Value>';
str += '</wfs:Property>';
}
}
@@ -1498,33 +914,32 @@
var el_geom = myconf['element'][j]['element_name'];
}
}
- // str += '<' + el_geom + '>';
-
- // if(dig.D[0].type == 'text'){
- // str += '<gml:Point srsName="epsg:4326">';
- // str += '<gml:coordinates>';
- // str += dig.D[0].x[0] + "," + dig.D[0].y[0];
- // str += '</gml:coordinates>';
- // str += '</gml:Point>';
- // }
- // if(dig.D[0].type == 'line'){
- // str += '<gml:MultiLineString srsName="epsg:4326">';
- // str += '<gml:lineStringMember>';
- // str += '<gml:LineString>';
- //
- // str += '<gml:coordinates>';
- // for(var k=0; k<dig.D[0].x.length; k++){
- // if(k>0){
- // str += " ";
- // }
- // str += dig.D[0].x[k] + "," + dig.D[0].y[k];
- // }
- // str += '</gml:coordinates>';
- // str += '</gml:LineString>';
- // str += '</gml:lineStringMember>';
- // str += '</gml:MultiLineString>';
- // }
- if(D[m]['geomtype'] == 'Polygon'){
+// str += '<' + el_geom + '>';
+// if(dig.D[0].type == 'text'){
+// str += '<gml:Point srsName="epsg:4326">';
+// str += '<gml:coordinates>';
+// str += dig.D[0].x[0] + "," + dig.D[0].y[0];
+// str += '</gml:coordinates>';
+// str += '</gml:Point>';
+// }
+// if(dig.D[0].type == 'line'){
+// str += '<gml:MultiLineString srsName="epsg:4326">';
+// str += '<gml:lineStringMember>';
+// str += '<gml:LineString>';
+//
+// str += '<gml:coordinates>';
+// for(var k=0; k<dig.D[0].x.length; k++){
+// if(k>0){
+// str += " ";
+// }
+// str += dig.D[0].x[k] + "," + dig.D[0].y[k];
+// }
+// str += '</gml:coordinates>';
+// str += '</gml:LineString>';
+// str += '</gml:lineStringMember>';
+// str += '</gml:MultiLineString>';
+// }
+ if(d.get(m).geomtype == geomTypePolygon){
str += '<wfs:Property>';
str += '<wfs:Name>' + el_geom + '</wfs:Name>';
str += '<wfs:Value>';
@@ -1533,13 +948,12 @@
str += '<gml:Polygon>';
str += '<gml:outerBoundaryIs>';
str += '<gml:LinearRing>';
-
str += '<gml:coordinates>';
- for(var k=0; k<D[m]['geometry'][0]['x'].length; k++){
+ for(var k=0; k<d.getGeometry(m,0).count(); k++){
if(k>0){
str += " ";
}
- str += D[m]['geometry'][0]['x'][k] + "," + D[m]['geometry'][0]['y'][k];
+ str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
}
str += '</gml:coordinates>';
str += '</gml:LinearRing>';
@@ -1550,7 +964,7 @@
str += '</wfs:Value>';
str += '</wfs:Property>';
}
- // str += '</' + el_geom + '>';
+// str += '</' + el_geom + '>';
str += '<ogc:Filter>';
str += '<ogc:PropertyIsEqualTo>';
str += '<ogc:PropertyName>gid</ogc:PropertyName>';
@@ -1559,9 +973,11 @@
str += '</ogc:Filter>';
str += '</wfs:Update>';
str += '</wfs:Transaction>';
- document.forms[1].filter.value = str;
+ document.sendForm.filter.value = str;
+ document.sendForm.submit();
+ //document.forms[1].filter.value = str;
//prompt("",str);
- document.forms[1].submit();
+ //document.forms[1].submit();
return false;
}
function deleteGeom(m){
@@ -1570,24 +986,20 @@
var ind = myform.wfs.selectedIndex;
var wfs = myform.wfs.options[ind].value;
myform = wfsWindow.document.forms[1];
- D[m]['wfs_conf'] = wfs;
- D[m]['element'] = new Array();
- D[m]['element']['name'] = new Array();
- D[m]['element']['val'] = new Array();
+ d.get(m).wfs_conf = wfs;
+ d.get(m).e = new Wfs_element();
var cnt = 0;
for( var i=0; i<myform.length; i++){
if(myform.elements[i].type == 'text'){
- D[m]['element'][cnt] = new Array();
- D[m]['element'][cnt]['name'] = myform.elements[i].name;
- D[m]['element'][cnt]['val'] = myform.elements[i].value;
- if(D[m]['element'][cnt]['name'] == 'gid'){
- myid_value = D[m]['element'][cnt]['val'];
+ d.get(m).e.setElement(myform.elements[i].name, myform.elements[i].value);
+ if(d.get(m).e.getName(cnt) == 'gid'){
+ myid_value = d.get(m).e.getValue(cnt);
}
cnt++;
}
}
- // alert(wfs_conf[D[m]['wfs_conf']]['wfs_transaction']);
- var myconf = wfs_conf[D[m]['wfs_conf']];
+// alert(wfs_conf[D[m]['wfs_conf']]['wfs_transaction']);
+ var myconf = wfs_conf[d.get(m).wfs_conf];
document.sendForm.url.value = myconf['wfs_transaction'];
var str = '<wfs:Transaction version="1.0.0" service="WFS" xmlns="http://www.someserver.com/myns" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&typename=mapbender_user http://www.opengis.net/wfs../wfs/1.0.0/WFS-transaction.xsd" xmlns:topp="http://www.someserver.com/topp">';
str += '<wfs:Delete typeName="'+ myconf['featuretype_name']+'">';
@@ -1596,7 +1008,6 @@
var el_geom = myconf['element'][j]['element_name'];
}
}
-
str += '<ogc:Filter>';
str += '<ogc:PropertyIsEqualTo>';
str += '<ogc:PropertyName>gid</ogc:PropertyName>';
@@ -1605,38 +1016,20 @@
str += '</ogc:Filter>';
str += '</wfs:Delete>';
str += '</wfs:Transaction>';
- document.forms[1].filter.value = str;
+ document.sendForm.filter.value = str;
+ document.sendForm.submit();
+ //document.forms[1].filter.value = str;
//prompt("",str);
- document.forms[1].submit();
+ //document.forms[1].submit();
return false;
}
-
</script>
</head>
- <body onload="registerFunctions();displayButtons()">
- <table cellpadding='0' cellspacing='0' align = center>
- <tr>
- <td>
- <form name='dig'>
- <table cellpadding='0' cellspacing='2'>
- <tr>
- <td><div id = 'divButtonPoint'></div></td>
- <td><div id = 'divButtonLine'></div></td>
- <td><div id = 'divButtonPolygon'></div></td>
- <td> </td>
- <td><div id = 'divButtonMove'></div></td>
- <td><div id = 'divButtonInsert'></div></td>
- <td><div id = 'divButtonDelete'></div></td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
- </table>
- <div id = 'listOfGeometries'></div>
- <form name='sendForm' action='../extensions/geom2wfst.php' method='POST' TARGET='_blank'>
- <input type='hidden' name='url'>
- <input type='hidden' name='filter'>
- </form>
+ <body onload="registerFunctions();displayButtons();">
+ <table cellpadding='0' cellspacing='0' align = center><tr><td><div id='digButtons'></div></td></tr></table>
+ <div id = 'listOfGeometries'></div>
+ <form name='sendForm' action='../extensions/geom2wfst.php' method='POST' TARGET='_blank'>
+ <input type='hidden' name='url'><input type='hidden' name='filter'>
+ </form>
</body>
- </html>
\ No newline at end of file
+</html>
\ No newline at end of file
More information about the Mapbender_commits
mailing list