[Mapbender-commits] r3229 - branches/digi_mvc_dev
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Nov 12 03:57:26 EST 2008
Author: christoph
Date: 2008-11-12 03:57:26 -0500 (Wed, 12 Nov 2008)
New Revision: 3229
Added:
branches/digi_mvc_dev/.project
branches/digi_mvc_dev/mod_digitize_controller.js
branches/digi_mvc_dev/mod_digitize_model.js
branches/digi_mvc_dev/mod_digitize_tab.php
branches/digi_mvc_dev/mod_digitize_view.js
branches/digi_mvc_dev/newProject
Log:
Initial import.
Added: branches/digi_mvc_dev/.project
===================================================================
--- branches/digi_mvc_dev/.project (rev 0)
+++ branches/digi_mvc_dev/.project 2008-11-12 08:57:26 UTC (rev 3229)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>digi_mvc</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ <nature>com.aptana.ide.editor.php.phpnature</nature>
+ </natures>
+</projectDescription>
Added: branches/digi_mvc_dev/mod_digitize_controller.js
===================================================================
--- branches/digi_mvc_dev/mod_digitize_controller.js (rev 0)
+++ branches/digi_mvc_dev/mod_digitize_controller.js 2008-11-12 08:57:26 UTC (rev 3229)
@@ -0,0 +1,242 @@
+var DigitizeController = function (optionObject) {
+
+ this.eventArray = {
+ point : "Point",
+ line : "Line",
+ polygon : "Polygon",
+ move : "dragBasePoint",
+ insert : "setBasePoint",
+ remove : "delBasePoint",
+ clear : "clear",
+ split : "digitizeSplit",
+ merge : "digitizeMerge",
+ difference : "digitizeDifference"
+ };
+
+ this.options = optionObject;
+
+ this.model = null;
+ this.view = null;
+
+ var basepointMemberIndex = null;
+ var basepointGeometryIndex = null;
+ var basepointRingIndex = null;
+ var basepointPointIndex = null;
+ this.currentEvent = false;
+
+ this.setView = function (aView) {
+ this.view = aView;
+ this.view.eventCurrentPointHasChanged.register(function (indexObject) {
+ basepointMemberIndex = indexObject.memberIndex;
+ basepointGeometryIndex = indexObject.geometryIndex;
+ basepointRingIndex = indexObject.ringIndex;
+ basepointPointIndex = indexObject.pointIndex;
+ }, this);
+
+
+ };
+
+ this.eventNoGeometrySelected = new parent.MapbenderEvent();
+ this.eventGeometryComplete = new parent.MapbenderEvent();
+
+ this.eventGeometryComplete.register(function () {
+ this.currentEvent = false;
+ var d = this.model.getData();
+ d.close();
+ }, this);
+
+ /**
+ * Called when a click in the map occured
+ *
+ * @param {Object} pos point with click pos (in map coordinates, not pixel)
+ */
+ this.mod_digitize_start = function (realWorldPos){
+ var d = this.model.getData();
+ // check if a proper geometry is selected
+ var geometryType = d.get(-1).geomType;
+ var currentGeometry = d.getGeometry(-1,-1);
+ var isLine = (geometryType == parent.geomType.line);
+ var isPolygon = (geometryType == parent.geomType.polygon);
+ var isPoint = (geometryType == parent.geomType.point);
+ var hasPoints = (currentGeometry.count() > 1);
+
+ if (currentGeometry.isComplete() || d.count() === 0){
+
+ if (this.currentEvent !== false) {
+ this.eventNoGeometrySelected.trigger();
+ }
+ return false;
+ }
+
+ if (isPolygon && hasPoints && currentGeometry.get(0).equals(realWorldPos)) {
+ // close the polygon
+ return this.eventGeometryComplete.trigger({
+ "button":this.currentEvent
+ });
+ }
+ else if (isLine && hasPoints && currentGeometry.get(-1).equals(realWorldPos)) {
+ return this.eventGeometryComplete.trigger({
+ "button":this.currentEvent
+ });
+ }
+ else {
+ // set the calculated real world position as point of the geometry
+ currentGeometry.addPoint(realWorldPos);
+
+ // POINT
+ if (isPoint) {
+ return this.eventGeometryComplete.trigger({
+ "button":this.currentEvent
+ });
+ }
+ // POLYGON
+ // add first point of polygon to snapping list,
+ // when three points have been inserted
+ else if (isPolygon && currentGeometry.count() == 3) {
+ this.view.addPointToSnapList(currentGeometry.get(0));
+ }
+ // LINE
+ // add last point of line to snapping list,
+ // when at least two points have been inserted
+ else if (isLine && currentGeometry.count() >= 2) {
+// if (this.currentEvent != this.eventArray.move) {
+// s.store(d);
+// }
+ this.view.addPointToSnapList(d.getPoint(-1, -1, -1));
+ }
+ }
+ this.view.eventAfterDigitizing.trigger();
+ return true;
+ };
+
+
+ this.updateAllPointsOfNonTransactionalLike = function (oldP, newP){
+ for (var i = 0; i < d.count(); i++) {
+ if (isTransactional(d.get(i))) {
+ d.get(i).updateAllPointsLike(oldP, newP);
+ }
+ }
+ };
+
+ this.insertNewPoint = function (aPoint) {
+ var d = this.model.getData();
+ if (basepointRingIndex === undefined) {
+ d.getGeometry(basepointMemberIndex,basepointGeometryIndex).addPointAtIndex(aPoint, basepointPointIndex);
+ }
+ else {
+ d.getGeometry(basepointMemberIndex,basepointGeometryIndex).innerRings.get(basepointRingIndex).addPointAtIndex(aPoint, basepointPointIndex);
+ }
+ };
+
+ this.deleteCurrentPoint = function () {
+ console.log("Test %s %s %s %s", basepointMemberIndex, basepointGeometryIndex, basepointRingIndex, basepointPointIndex);
+ var d = this.model.getData();
+ if (basepointRingIndex !== undefined) {
+ d.delAllPointsLike(d.getPoint(basepointMemberIndex, basepointGeometryIndex, basepointRingIndex, basepointPointIndex));
+ }
+ else {
+ d.delAllPointsLike(d.getPoint(basepointMemberIndex, basepointGeometryIndex, basepointPointIndex));
+ }
+
+ };
+
+ this.eventIsCreatePoint = function () {
+ return this.currentEvent == this.eventArray.point;
+ };
+
+ this.eventIsCreateLine = function () {
+ return this.currentEvent == this.eventArray.line;
+ };
+
+ this.eventIsCreatePolygon = function () {
+ return this.currentEvent == this.eventArray.polygon;
+ };
+
+ this.eventIsMove = function () {
+ return this.currentEvent == this.eventArray.move;
+ };
+
+ this.eventIsInsert = function () {
+ return this.currentEvent == this.eventArray.insert;
+ };
+
+ this.eventIsRemove = function () {
+ return this.currentEvent == this.eventArray.remove;
+ };
+
+ this.releaseBasepoint = function (e){
+
+ var i = basepointMemberIndex;
+ var j = basepointGeometryIndex;
+ var k = basepointRingIndex;
+ var l = basepointPointIndex;
+ basepointDragActive = false;
+
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var basepointDragEnd = new parent.Point(parent.clickX, parent.clickY);
+ basepointObject.onmousedown = null;
+ var p = parent.makeClickPos2RealWorldPos(mod_digitize_target, basepointDragEnd.x, basepointDragEnd.y);
+
+ var oldPoint;
+ if (k === undefined) {
+ oldPoint = parent.cloneObject(d.getPoint(i,j,l));
+ }
+ else {
+ oldPoint = parent.cloneObject(d.getPoint(i,j,k,l));
+ }
+ if (s.isSnapped()) {
+ var snappedPoint = parent.cloneObject(s.getSnappedPoint());
+ if (!this.options.nonTransactionalEditable) {
+ updateAllPointsOfNonTransactionalLike(oldPoint, snappedPoint);
+ }
+ else {
+ d.updateAllPointsLike(oldPoint, snappedPoint);
+ }
+ s.clean();
+ }
+ else {
+ var newPoint = new parent.Point(p[0],p[1]);
+ if (!this.options.nonTransactionalEditable) {
+ updateAllPointsOfNonTransactionalLike(oldPoint, newPoint);
+ }
+ else {
+ d.updateAllPointsLike(oldPoint, newPoint);
+ }
+ }
+ basepointMemberIndex = null;
+ basepointGeometryIndex = null;
+ basepointPointIndex = null;
+
+ executeDigitizeSubFunctions();
+ };
+
+ parent.eventInit.register(function () {
+ this.model = new DigitizeModel();
+ this.view.setStyleForTargetFrame();
+ this.view.checkDigitizeTag();
+ this.view.getMessages();
+ // .appendGeometryArrayFromKML();
+ this.view.initialiseMeasure();
+ this.view.initialiseSnapping();
+ this.view.getMessages();
+
+ }, this);
+
+ if (!this.options.nonTransactionalEditable) {
+ parent.eventInit.register(function () {
+ this.view.initialiseHighlight();
+ }, this);
+
+ }
+ parent.eventAfterMapRequest.register(function () {
+ this.view.updateExtent();
+ }, this);
+
+
+// try {if(spatialRequestResultToDigitize){}}catch(e) {spatialRequestResultToDigitize = 1;}
+// if(spatialRequestResultToDigitize==1){
+// parent.mb_registerWfsReadSubFunctions(function(geom){parent.tab_open(mod_digitize_elName);parent.window.frames[mod_digitize_elName].appendGeometryArray(geom);});
+// }
+// parent.mb_registerWfsWriteSubFunctions(function(){parent.zoom(mod_digitize_target, true, 0.999);});
+
+};
\ No newline at end of file
Added: branches/digi_mvc_dev/mod_digitize_model.js
===================================================================
--- branches/digi_mvc_dev/mod_digitize_model.js (rev 0)
+++ branches/digi_mvc_dev/mod_digitize_model.js 2008-11-12 08:57:26 UTC (rev 3229)
@@ -0,0 +1,7 @@
+var DigitizeModel = function () {
+ var geomArray = new parent.GeometryArray();
+
+ this.getData = function () {
+ return geomArray;
+ };
+};
\ No newline at end of file
Added: branches/digi_mvc_dev/mod_digitize_tab.php
===================================================================
--- branches/digi_mvc_dev/mod_digitize_tab.php (rev 0)
+++ branches/digi_mvc_dev/mod_digitize_tab.php 2008-11-12 08:57:26 UTC (rev 3229)
@@ -0,0 +1,703 @@
+<?php
+# $Id: mod_digitize_tab.php 3142 2008-10-08 09:31:56Z christoph $
+# http://www.mapbender.org/index.php/mod_digitize_tab.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__) . "/../php/mb_validateSession.php");
+
+$e_target = $_GET["e_target"];
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="0">
+<?php
+echo '<meta http-equiv="Content-Type" content="text/html; charset='.CHARSET.'">';
+?>
+<title>Digitize</title>
+<?php
+$digitize_conf_filename = "digitize_default.conf";
+include '../include/dyn_css.php';
+?>
+<script language='JavaScript'>
+<?php
+echo "var mod_digitize_target = '".$e_target."';";
+$digitizeConfFilenameAndPath = dirname(__FILE__) . "/../../conf/" . $digitize_conf_filename;
+if ($digitize_conf_filename && file_exists($digitizeConfFilenameAndPath)) {
+ include($digitizeConfFilenameAndPath);
+}
+include '../javascripts/mod_digitize_model.js';
+include '../javascripts/mod_digitize_view.js';
+include '../javascripts/mod_digitize_controller.js';
+?>
+
+var digitizeOptions = {
+ nonTransactionalEditable:false
+};
+var wfsWindow;
+var wfsConf = [];
+
+var mod_digitize_width;
+var mod_digitize_height;
+
+
+var digitizeDivTag;
+
+var GeometryArray;
+var MultiGeometry = parent.MultiGeometry;
+var Geometry;
+var Point;
+var geomType;
+
+var featureTypeElementFormId = "featureTypeElementForm";
+
+try {if(mod_digitize_elName){}}catch(e) {mod_digitize_elName = "digitize";}
+try {if(nonTransactionalEditable){}}catch(e) {nonTransactionalEditable = false;}
+
+function init(){
+ digitizeController = new DigitizeController(digitizeOptions);
+ digitizeView = new DigitizeView(digitizeController, digitizeButtonArray || []);
+ digitizeController.setView(digitizeView);
+}
+
+/**
+ * Append geometries from KML when KML has been loaded
+ */
+function appendGeometryArrayFromKML () {
+ try {
+ parent.kmlHasLoaded.register(function(properties){
+ d = new parent.GeometryArray();
+ d.importGeoJSON(properties);
+// d = parent.geoJsonToGeometryArray(properties);
+ executeDigitizeSubFunctions();
+ });
+ }
+ catch (e) {
+ var exc = new parent.Mb_warning(e);
+ }
+}
+
+
+// ------------------------------------------------------------------------------------------------------------------------
+// --- polygon, line, point insertion (begin) ----------------------------------------------------------------------------------------------
+
+function appendGeometryArray(obj) {
+ executeDigitizePreFunctions();
+ for (i = 0; i < obj.count(); i++) {
+ d.addCopy(obj.get(i));
+ }
+ executeDigitizeSubFunctions();
+}
+
+
+
+function isTransactional(geom) {
+// alert(typeof(geom.wfs_conf) + " " + geom.wfs_conf + " " + wfsConf.length);
+ if (typeof(geom.wfs_conf) == 'number') {
+ if (geom.wfs_conf >= 0 && geom.wfs_conf < wfsConf.length) {
+ var isTransactionalGeom = (wfsConf[geom.wfs_conf]['wfs_transaction'] != "" && wfsConf[geom.wfs_conf]['fkey_featuretype_id'] != "");
+ if (isTransactionalGeom) {
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+ }
+ else if (typeof(geom.wfs_conf) == 'undefined') {
+ return true;
+ }
+}
+
+function isValidWfsConfIndex (wfsConf, wfsConfIndex) {
+ return (typeof(wfsConfIndex) == "number" && wfsConfIndex >=0 && wfsConfIndex < wfsConf.length);
+}
+
+function getName (geom) {
+ wfsConfId = geom.wfs_conf;
+ wfsConf = parent.get_complete_wfs_conf();
+ if (isValidWfsConfIndex(wfsConf, wfsConfId)) {
+ var resultName = "";
+ for (var i = 0 ; i < wfsConf[wfsConfId]['element'].length ; i++) {
+ if (wfsConf[wfsConfId]['element'][i]['f_show'] == 1) {
+ resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
+ }
+ }
+ if (resultName == "") {
+ resultName = wfsConf[wfsConfId]['g_label'];
+ }
+ return resultName;
+ }
+ else if (geom.e.getElementValueByName("name")) {
+ return geom.e.getElementValueByName("name");
+ }
+ return null;
+}
+
+
+// -----------------------------------------------------------------------------------------------------------
+// --- wfs window form check (begin) -----------------------------------------------------------------------------------------
+
+function formCorrect(doc, formId) {
+ var isCorrect = true;
+ var errorMessage = "";
+ var result;
+ var form = doc.getElementById(formId);
+
+ result = mandatoryFieldsNotEmpty(doc, form);
+ isCorrect = isCorrect && result.isCorrect;
+ errorMessage += result.errorMessage;
+
+ result = validBoxEntrySelected(form);
+ isCorrect = isCorrect && result.isCorrect;
+ errorMessage += result.errorMessage;
+
+ result = dataTypeIsCorrect(doc, form);
+ isCorrect = isCorrect && result.isCorrect;
+ errorMessage += result.errorMessage;
+
+ return {"isCorrect":isCorrect, "errorMessage":errorMessage};
+}
+
+function validBoxEntrySelected(form){
+ var isCorrect = true;
+ var errorMessage = "";
+ for (var i = 0; i < form.childNodes.length && isCorrect; i++) {
+ if (form.childNodes[i].nodeName.toUpperCase() == "SELECT") {
+ if (parseInt(form.childNodes[i].selectedIndex) == 0) {
+ return {"isCorrect":false, "errorMessage":errorMessage};
+ }
+ }
+ else if (form.childNodes[i].hasChildNodes()) {
+ isCorrect = validBoxEntrySelected(form.childNodes[i]).isCorrect;
+ }
+ }
+ if (!isCorrect) {
+ errorMessage = msgObj.messageSelectAnOption + "\n";
+ }
+ return {"isCorrect":isCorrect, "errorMessage":errorMessage};
+}
+
+function mandatoryFieldsNotEmpty(doc, node){
+ var isCorrect = true;
+ var errorMessage = "";
+
+ nodeArray = doc.getElementsByName("mandatory");
+ for (var i = 0; i < nodeArray.length && isCorrect; i++) {
+ if (nodeArray[i].nodeName.toUpperCase() == "INPUT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,10) == "mandatory_") {
+ var nodeId = nodeArray[i].id.substr(10);
+ if (nodeArray[i].value == "true") {
+ if (doc.getElementById(nodeId).value == "") {
+ isCorrect = false;
+ errorMessage += "'"+ doc.getElementById(nodeId).name +"': "+ msgObj.messageErrorFieldIsEmpty +"\n";
+ }
+ }
+ }
+ }
+ return {"isCorrect":isCorrect, "errorMessage":errorMessage};
+}
+
+function isInteger(str) {
+ if (str.match(/^\d*$/)) {
+ return true;
+ }
+ return false;
+}
+
+function isFloat(str) {
+ if (isInteger(str)) {
+ return true;
+ }
+ if (str.match(/^\d+\.\d+$/)) {
+ return true;
+ }
+ return false;
+}
+
+function replaceCommaByDecimalPoint(str) {
+ var patternString = ",";
+ var pattern = new RegExp(patternString);
+ while (str.match(pattern)) {
+ str = str.replace(pattern, ".");
+ }
+ return str;
+}
+
+function dataTypeIsCorrect(doc, node){
+ var isCorrect = true;
+ var errorMessage = "";
+
+ nodeArray = doc.getElementsByName("datatype");
+ for (var i = 0; i < nodeArray.length ; i++) {
+ if (nodeArray[i].nodeName.toUpperCase() == "INPUT" && nodeArray[i].type == "hidden" && nodeArray[i].id.substr(0,9) == "datatype_") {
+ var nodeId = nodeArray[i].id.substr(9);
+ var nodeValue = doc.getElementById(nodeId).value;
+
+ if (nodeArray[i].value == "int") {
+ if (!isInteger(nodeValue)) {
+ isCorrect = false;
+ errorMessage += "'"+doc.getElementById(nodeId).name+"': "+ msgObj.messageErrorNotAnInteger + "\n";
+ }
+ }
+ else if (nodeArray[i].value == "double") {
+ nodeValue = replaceCommaByDecimalPoint(nodeValue);
+ if (!isFloat(nodeValue)) {
+ isCorrect = false;
+ errorMessage += "'"+doc.getElementById(nodeId).name+"': "+ msgObj.messageErrorNotAFloat + "\n";
+ }
+ else {
+ doc.getElementById(nodeId).value = nodeValue;
+ }
+ }
+ }
+ }
+ return {"isCorrect":isCorrect, "errorMessage":errorMessage};
+}
+// --- wfs window form check (end) -----------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------
+
+function getAvailableWfsForGeom(geom, wfsConf) {
+ var wfsConfIndices = [];
+
+ for (var attr in wfsConf) {
+ var isTrans = (wfsConf[attr]['wfs_transaction'] != "");
+ if (!isTrans) {
+ continue;
+ }
+ if (isValidWfsConfIndex(wfsConf, parseInt(geom.wfs_conf))) {
+
+ if (parseInt(geom.wfs_conf) == parseInt(attr)) {
+ wfsConfIndices.push(attr);
+ }
+ }
+ else {
+ for (var elementIndex = 0; elementIndex < wfsConf[attr]['element'].length ; elementIndex++) {
+ var isGeomColumn = (parseInt(wfsConf[attr]['element'][elementIndex]['f_geom']) == 1);
+ if (isGeomColumn) {
+ var isMultiPolygon = (geom.geomType == parent.geomType.polygon && wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiPolygonPropertyType');
+ var isPolygon = (geom.geomType == parent.geomType.polygon && geom.count() == 1 && wfsConf[attr]['element'][elementIndex]['element_type'] == 'PolygonPropertyType');
+ var isMultiLine = (geom.geomType == parent.geomType.line && wfsConf[attr]['element'][elementIndex]['element_type'] == 'MultiLineStringPropertyType');
+ var isLine = (geom.geomType == parent.geomType.line && geom.count() == 1 && wfsConf[attr]['element'][elementIndex]['element_type'] == 'LineStringPropertyType');
+ var isPoint = (geom.geomType == parent.geomType.point && wfsConf[attr]['element'][elementIndex]['element_type'] == 'PointPropertyType');
+// alert(isMultiPolygon + " " + isPolygon + " " + isMultiLine + " " + isLine + " " + isPoint);
+ if (isMultiPolygon || isPolygon || isMultiLine || isLine || isPoint || wfsConf[attr]['element'][elementIndex]['element_type'] == 'GeometryAssociationType') {
+
+ wfsConfIndices.push(attr);
+ }
+ }
+ }
+ }
+ }
+ return wfsConfIndices;
+}
+function wfsExistsForGeom(geom, wfsConf) {
+ wfsConfIndices = getAvailableWfsForGeom(geom, wfsConf);
+// alert(wfsConfIndices.join(","));
+ if (wfsConfIndices.length > 0) {
+ return true;
+ }
+ return false;
+}
+
+
+function showWfsKml (geometryIndex) {
+ wfsKmlWindow = open("", "wfsattributes", "width="+wfsWindowWidth+", height="+wfsWindowHeight+", resizable, dependent=yes, scrollbars=yes");
+ wfsKmlWindow.document.open("text/html");
+ wfsKmlWindow.document.writeln("<html><head></head><body><div id='linkToKml'></div><div id='elementForm'></div></body></html>");
+ wfsKmlWindow.document.close();
+
+ str = "<form id = 'wmsKmlForm' onsubmit='return false;'><table>";
+
+ var properties = d.get(geometryIndex).e;
+ var propertyCount = properties.count();
+ for (var i = 0; i < propertyCount; i++) {
+ var key = properties.getName(i);
+ var value = properties.getValue(i);
+ var expr = /Mapbender:/;
+ if (!key.match(expr)) {
+ str += "\t\t<tr>\n";
+ str += "\t\t\t<td>\n\t\t\t\t<div>" + key + "</div>\n\t\t\t</td>\n";
+ str += "\t\t\t<td>\n";
+ str += "\t\t\t\t<input id = 'wmskml_" + i + "' name='" + key + "' type='text' size=20 value = '" + value + "'>\n";
+ str += "\t\t\t</td>\n\t\t</tr>\n";
+ }
+ }
+
+ var updateOnClickText = "this.disabled=true;window.opener.updateKmlInDb("+geometryIndex+", 'update');";
+ var deleteOnClickText = "var deltrans = confirm('This geometry will be removed from the KML.');";
+ deleteOnClickText += "if (deltrans){";
+ deleteOnClickText += "this.disabled=true;window.opener.updateKmlInDb("+geometryIndex+", 'delete')}";
+
+ str += "\t\t\t<td><input type='button' name='updateButton' value='Update' onclick=\""+updateOnClickText+"\"/></td>\n";
+// delete button not yet implemented
+// str += "\t\t\t<td><input type='button' name='deleteButton' value='Delete' onclick=\""+deleteOnClickText+"\"/></td>\n";
+ str += "\t\t\t<td><input type='button' name='abortButton' value='Abort' onclick=\"window.close();\" /></td>\n";
+
+ str += "\t\t</tr>\n";
+ str += "\t</table>\n";
+ str += "</form>\n";
+
+ wfsKmlWindow.document.getElementById("elementForm").innerHTML = str;
+}
+
+//
+// this method opens a new window and displays the attributes in wfs_conf
+//
+function showWfs(geometryIndex) {
+ wfsConf = parent.get_complete_wfs_conf();
+
+ wfsWindow = open("", "wfsattributes", "width="+wfsWindowWidth+", height="+wfsWindowHeight+", resizable, dependent=yes, scrollbars=yes");
+ wfsWindow.document.open("text/html");
+
+ var str = "";
+ var strStyle = "";
+ var defaultIndex = -1;
+
+ str += "<form id='wfs'>\n";
+
+ //
+ // 1. add select box
+ //
+
+ var onChangeText = "document.getElementById('elementForm').innerHTML = ";
+ onChangeText += "window.opener.buildElementForm(this.value , " + geometryIndex + ");";
+ onChangeText += "window.opener.setWfsWindowStyle(this.value);";
+
+ str += "\t<select name='wfs' size='" + wfsConf.length + "'";
+ str += " onChange=\""+ onChangeText +"\"";
+ str += ">\n\t\t";
+
+ var wfsConfIndices = getAvailableWfsForGeom(d.get(geometryIndex), wfsConf);
+// alert(wfsConfIndices.join(","));
+ var selected = false;
+ for (var i = 0; i < wfsConfIndices.length ; i++) {
+ str += "<option value='" + wfsConfIndices[i] + "'";
+ if (!selected) {
+ str += " selected";
+ selected = true;
+ defaultIndex = parseInt(wfsConfIndices[i]);
+ }
+ str += ">" + wfsConf[wfsConfIndices[i]]['wfs_conf_abstract'];
+ str += "</option>\n\t\t";
+ }
+
+
+ str += "</select>\n\t\t</form>\n\t";
+ str += "<div id='elementForm'>\n</div>";
+
+ if (defaultIndex != -1) {
+ wfsWindow.document.writeln("<html><head><style type='text/css'>"+wfsConf[defaultIndex]['g_style']+"</style></head><body></body></html>");
+ wfsWindow.document.write(str);
+ wfsWindow.document.close();
+ wfsWindow.document.getElementById("elementForm").innerHTML = buildElementForm(defaultIndex, geometryIndex);
+ }
+ else {
+ wfsWindow.document.writeln("<html><head><style type='text/css'></style></head><body></body></html>");
+ wfsWindow.document.write(str);
+ wfsWindow.document.close();
+ }
+}
+
+function setWfsWindowStyle(wfsConfIndex) {
+ wfsWindow.document.getElementsByTagName("style")[0].innerHTML = wfsConf[wfsConfIndex]['g_style'];
+}
+
+// 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 featureTypeMismatch = false;
+ if (parseInt(d.get(memberIndex).wfs_conf) != parseInt(wfsConfIndex)) {featureTypeMismatch = true;}
+ var str = "";
+ var hasGeometryColumn = false;
+ var featureTypeArray = wfsConf[wfsConfIndex];
+ var memberElements;
+ var fid = false;
+
+ if (!featureTypeMismatch) {
+ memberElements = d.get(memberIndex).e;
+ fid = memberElements.getElementValueByName('fid');
+ }
+
+ if (typeof(featureTypeArray["element"]) !== "undefined") {
+
+ str += "<form id='"+featureTypeElementFormId+"'>\n\t<table>\n";
+ featureTypeElementArray = featureTypeArray["element"];
+
+ //
+ // 2. add rows to form
+ //
+ for (var i = 0 ; i < featureTypeElementArray.length ; i ++) {
+ var featureTypeElement = featureTypeElementArray[i];
+
+ var elementName = featureTypeElement['element_name'];
+ var elementType = featureTypeElement['element_type'];
+ var isEditable = (parseInt(featureTypeElement['f_edit']) == 1);
+ var isMandatory = (parseInt(featureTypeElement['f_mandatory']) == 1);
+ var isGeomColumn = (parseInt(featureTypeElement['f_geom']) == 1);
+
+ var elementLabelExists = (featureTypeElement['f_label'] != "");
+ var elementLabel = "";
+ if (elementLabelExists) {
+ elementLabel = featureTypeElement['f_label'];
+ }
+ var elementLabelStyle = featureTypeElement['f_label_id'];
+
+ if (!isGeomColumn) {
+ if (isEditable) {
+ str += "\t\t<tr>\n";
+ str += "\t\t\t<td>\n\t\t\t\t<div class = '"+elementLabelStyle+"''>" + elementLabel + "</div>\n\t\t\t</td>\n";
+ str += "\t\t\t<td>\n";
+
+ var elementValue = "";
+ if (!featureTypeMismatch) {
+ for (var j = 0 ; j < memberElements.count() ; j ++) {
+ if (memberElements.getName(j) == featureTypeElement['element_name']) {
+ elementValue = memberElements.getValue(j);
+ }
+ }
+ }
+ var formElementHtml = featureTypeElement['f_form_element_html'];
+ if (!formElementHtml || !formElementHtml.match(/<select/)) {
+ str += "\t\t\t\t<input id = 'datatype_mb_digitize_form_" + elementName + "' name='datatype' type='hidden' value = '" + elementType + "'>\n";
+ str += "\t\t\t\t<input id = 'mandatory_mb_digitize_form_" + elementName + "' name='mandatory' type='hidden' value = '" + isMandatory + "'>\n";
+ str += "\t\t\t\t<input id = 'mb_digitize_form_" + elementName + "' name='" + elementLabel + "' type='text' class = '"+featureTypeElement['f_style_id']+"' size=20 value = '" + elementValue + "'>\n";
+ }
+ else {
+ while (formElementHtml.match(/\\/)) {
+ formElementHtml = formElementHtml.replace(/\\/, "");
+ }
+// alert(formElementHtml);
+ // preselect the correct entry of the box
+ var patternString = "option value='"+elementValue+"'";
+ var pattern = new RegExp(patternString);
+ formElementHtml = formElementHtml.replace(pattern, patternString+" selected");
+// alert(formElementHtml);
+ str += formElementHtml;
+ }
+ str += "\t\t\t</td>\n\t\t</tr>\n";
+ }
+ }
+ else {
+ hasGeometryColumn = true;
+ }
+ }
+
+ //
+ // 3. add buttons "save", "update", "delete"
+ //
+ str += "</table><table>";
+ var isTransactional = (featureTypeArray['wfs_transaction']);
+ if (isTransactional) {
+ str += "\t\t<tr>\n";
+
+ var options = ["save", "update", "delete", "abort"];
+ for (var i = 0 ; i < options.length ; i++) {
+ var onClickText = "this.disabled=true;var result = window.opener.formCorrect(document, '"+featureTypeElementFormId+"');";
+ onClickText += "if (result.isCorrect) {";
+ onClickText += "window.opener.dbGeom('"+options[i]+"', "+memberIndex+"); ";
+// onClickText += "window.close();";
+ onClickText += "}";
+ onClickText += "else {";
+ onClickText += "alert(result.errorMessage);this.disabled=false;"
+ onClickText += "}";
+
+ if (options[i] == "save" && hasGeometryColumn && (!fid || showSaveButtonForExistingGeometries)) {
+ str += "\t\t\t<td><input type='button' name='saveButton' value='"+msgObj.buttonLabelSaveGeometry+"' onclick=\""+onClickText+"\" /></td>\n";
+ }
+
+ if (!featureTypeMismatch && fid) {
+ if (options[i] == "update" && hasGeometryColumn) {
+ str += "\t\t\t<td><input type='button' name='updateButton' value='"+msgObj.buttonLabelUpdateGeometry+"' onclick=\""+onClickText+"\"/></td>\n";
+ }
+ if (options[i] == "delete"){
+ var deleteOnClickText = "var deltrans = confirm('"+msgObj.messageConfirmDeleteGeomFromDb+"');";
+ deleteOnClickText += "if (deltrans){";
+ deleteOnClickText += onClickText + "}";
+ str += "\t\t\t<td><input type='button' name='deleteButton' value='"+msgObj.buttonLabelDeleteGeometry+"' onclick=\""+deleteOnClickText+"\"/></td>\n";
+ }
+ }
+ if (options[i] == "abort") {
+ str += "\t\t\t<td><input type='button' name='abortButton' value='"+msgObj.buttonLabelAbort+"' onclick=\"window.close();\" /></td>\n";
+ }
+ }
+ str += "\t\t</tr>\n";
+ }
+ str += "\t</table>\n";
+ str += "<input type='hidden' id='fid' value='"+fid+"'>";
+// str += "<input type='text' name='mb_wfs_conf'>";
+ str += "</form>\n";
+ }
+ return str;
+}
+
+function dbGeom(type,m) {
+ if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
+ d.get(m).wfs_conf = parseInt(wfsWindow.document.forms[0].wfs.options[wfsWindow.document.forms[0].wfs.selectedIndex].value);
+ d.get(m).e = new parent.Wfs_element();
+ }
+ else {
+ wfsConf = parent.get_complete_wfs_conf();
+ }
+ var myconf = wfsConf[d.get(m).wfs_conf];
+
+ var mapObjInd = parent.getMapObjIndexByName(mod_digitize_target);
+
+ if (myconf['featuretype_srs'] != parent.mb_mapObj[mapObjInd].epsg) {
+ alert(msgObj.errorMessageEpsgMismatch + parent.mb_mapObj[mapObjInd].epsg + " / "+ myconf['featuretype_srs']);
+ }
+ else {
+ var fid = false;
+ var errorMessage = "";
+ if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
+ myform = wfsWindow.document.getElementById(featureTypeElementFormId);
+
+ for (var i=0; i<myform.length; i++){
+ if (myform.elements[i].id == "fid") {
+ fid = myform.elements[i].value;
+ d.get(m).e.setElement('fid', fid);
+ }
+ else if (myform.elements[i].type == 'text' ){
+ if (myform.elements[i].id) {
+ var elementId = String(myform.elements[i].id).replace(/mb_digitize_form_/, "");
+ d.get(m).e.setElement(elementId, myform.elements[i].value);
+ }
+ else {
+ errorMessage = msgObj.messageErrorFormEvaluation;
+ }
+ }
+ // selectbox
+ else if (typeof(myform.elements[i].selectedIndex) == 'number') {
+ if (myform.elements[i].id) {
+ var elementId = String(myform.elements[i].id).replace(/mb_digitize_form_/, "");
+ d.get(m).e.setElement(elementId, myform.elements[i].options[myform.elements[i].selectedIndex].value);
+ }
+ else {
+ errorMessage = msgObj.messageErrorFormEvaluation;
+ }
+ }
+ }
+ }
+ else {
+ fid = d.get(m).e.getElementValueByName('fid');
+ }
+ str = parent.get_wfs_str(myconf, d, m, type, fid);
+
+ parent.mb_ajax_post("../extensions/geom2wfst.php", {'filter':str,'url':myconf['wfs_transaction'],'featuretype_name':myconf['featuretype_name'],'wfs_conf_id':wfsConf[d.get(m).wfs_conf]['wfs_conf_id']}, function(json,status){
+ var result = eval('('+json+')');
+ var response = result.response;
+ var fid = result.fid;
+ wfsSubWrite(m, type, status, response, fid);
+ });
+ }
+}
+
+function wfsSubWrite(m, type, status, response, fid) {
+ if (type == 'save' && fid) {
+ d.get(m).e.setElement("fid", fid);
+ }
+ if (type == 'delete') {
+ parent.mb_disableThisButton(mod_digitizeEvent);
+ d.del(m);
+ }
+ parent.mb_execWfsWriteSubFunctions();
+ executeDigitizeSubFunctions();
+
+ if (status == "success" && response == "success") {
+ var wfsWriteMessage = msgObj.messageSuccessWfsWrite;
+ }
+ else {
+ var wfsWriteMessage = msgObj.messageErrorWfsWrite;
+ }
+
+ if (typeof(wfsWindow) != 'undefined' && !wfsWindow.closed) {
+ wfsWindow.alert(wfsWriteMessage);
+ window.setTimeout("wfsWindow.close()",0);
+ }
+ else {
+ alert(wfsWriteMessage);
+ }
+}
+function getMultiGeometryIdsByPlacemarkId (placemarkId) {
+ var multiGeometryIdArray = [];
+ for (var i = 0; i < d.count(); i++) {
+ var currentPlacemarkId = d.get(i).e.getElementValueByName("Mapbender:placemarkId");
+ if (currentPlacemarkId && currentPlacemarkId == placemarkId) {
+ multiGeometryIdArray.push(i);
+ }
+ }
+ return multiGeometryIdArray;
+}
+
+function updateKmlInDb (geometryIndex, command) {
+ var properties = d.get(geometryIndex).e;
+ var placemarkId = properties.getElementValueByName("Mapbender:placemarkId");
+
+ var multiGeometryIdArray = getMultiGeometryIdsByPlacemarkId(placemarkId);
+
+ if (typeof(wfsKmlWindow) != 'undefined' && !wfsKmlWindow.closed) {
+
+ // update properties from form
+ myform = wfsKmlWindow.document.getElementById("wmsKmlForm");
+
+ for (var i=0; i < myform.length; i++){
+ if (myform.elements[i].type == 'text' ){
+ if (myform.elements[i].id) {
+ var key = myform.elements[i].name;
+ var value = myform.elements[i].value;
+
+ // update all geometries with the same placemark id
+ for (var j = 0; j < multiGeometryIdArray.length; j++) {
+ var currentProperties = d.get(j).e;
+ currentProperties.setElement(key, value);
+ }
+ }
+ }
+ }
+ var kmlId = properties.getElementValueByName("Mapbender:id");
+
+ parent.mb_ajax_post("../php/mod_updateKmlInDb.php", {command:command, kmlId:kmlId, placemarkId:placemarkId, geoJSON:d.placemarkToString(placemarkId)}, function(obj, status) {
+ if (obj === "1") {
+ wfsKmlWindow.alert("KML updated.");
+ var link = wfsKmlWindow.document.createElement("a");
+ link.href = "../php/mod_displayKML.php?kmlId=" + kmlId;
+ link.target = "_blank";
+ link.innerHTML = "KML";
+ wfsKmlWindow.document.getElementById('elementForm').innerHTML = "";
+ wfsKmlWindow.document.getElementById('linkToKml').appendChild(link);
+ }
+ else {
+ wfsKmlWindow.alert("Error, KML could not be updated. Check your error log.");
+ }
+ });
+ }
+}
+
+
+// --- wfs window (begin) -----------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------
+
+
+
+ </script>
+ </head>
+ <body onload = "init()">
+ <div id='digButtons'></div>
+ <div id='listOfGeometries' class='digitizeGeometryList'></div>
+ </body>
+</html>
Added: branches/digi_mvc_dev/mod_digitize_view.js
===================================================================
--- branches/digi_mvc_dev/mod_digitize_view.js (rev 0)
+++ branches/digi_mvc_dev/mod_digitize_view.js 2008-11-12 08:57:26 UTC (rev 3229)
@@ -0,0 +1,887 @@
+var DigitizeView = function (aController, aButtonArray) {
+ var msgObj;
+ var controller = aController;
+ var basepointObject = false;
+ var basepointDragActive = false;
+
+ var s;
+
+ controller.eventGeometryComplete.register(function (data) {
+ // disables the button
+ // and also calls digitizeDisable!
+ parent.mb_disableThisButton(data.button);
+ }, this);
+
+ //default definition of image directory for digitize buttons, might
+ //be overwritten with digitize conf data
+ var buttonImageFolder = "../img/button_digitize/";
+
+ var buttonArray = aButtonArray;
+ var nonTransactionalHighlight;
+
+ this.checkDigitizeTag = function () {
+ var digitizeTagName = "digitize";
+ var digitizeTagStyle = {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeTransactionalZIndex, "font-size":"10px"};
+
+ digitizeDivTag = new parent.DivTag(digitizeTagName, mod_digitize_target, digitizeTagStyle);
+ parent.mb_registerPanSubElement(digitizeTagName);
+// parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].drawDashedLine()");
+ };
+
+ this.setStyleForTargetFrame = function () {
+ 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);
+ };
+
+ this.initialiseSnapping = function () {
+ s = new parent.Snapping(mod_digitize_target, snappingTolerance, snappingColor, snappingHighlightZIndex);
+ };
+
+ this.updateExtent = function () {
+ var anInd = parent.getMapObjIndexByName(mod_digitize_target);
+ var change = false;
+ if (typeof(mod_digitize_width) == 'undefined' || mod_digitize_width != parent.mb_mapObj[anInd].width) {
+ mod_digitize_width = parent.mb_mapObj[anInd].width;
+ change = true;
+ }
+ if (typeof(mod_digitize_height) == 'undefined' || mod_digitize_height != parent.mb_mapObj[anInd].height) {
+ mod_digitize_height = parent.mb_mapObj[anInd].height;
+ change = true;
+ }
+ if (typeof(mod_digitize_epsg) == 'undefined' || mod_digitize_epsg != parent.mb_mapObj[anInd].epsg) {
+ mod_digitize_epsg = parent.mb_mapObj[anInd].epsg;
+ change = true;
+ }
+ // if (change) {
+ // drawDashedLine();
+ // }
+ };
+
+ this.initialiseHighlight = function () {
+ nonTransactionalHighlight = new parent.Highlight([mod_digitize_target], "nonTransactional", {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeNonTransactionalZIndex}, nonTransactionalLineWidth);
+ };
+
+ this.initialiseMeasure = function () {
+ measureDivTag = new parent.DivTag(measureTagName, measureTagTarget, measureTagStyle);
+ parent.eventAfterMapRequest.register(function () {
+ this.updateMeasureTag();
+ }, this);
+ };
+
+ this.updateMeasureTag = function () {
+ var d = controller.model.getData();
+ if (d.count() > 0 ) {
+ if (d.get(-1).count() > 0) {
+ if (d.getGeometry(-1, -1).count() > 0) {
+ if (controller.currentEvent == controller.eventArray.line || controller.currentEvent == controller.eventArray.polygon) {
+ var measureString = "";
+ measureString += msgObj.measureTagLabelCurrent + d.getGeometry(-1, -1).getCurrentDist(measureNumberOfDigits) + "<br>";
+ measureString += msgObj.measureTagLabelTotal + d.getGeometry(-1, -1).getTotalDist(measureNumberOfDigits);
+ measureDivTag.write(measureString);
+ return true;
+ }
+ }
+ }
+ }
+ measureDivTag.clean();
+ };
+
+
+ this.updateListOfGeometries = function (){
+ var d = controller.model.getData();
+ var listOfGeom = "<ul>";
+ if (d.count() > 0) {
+ wfsConf = parent.get_complete_wfs_conf();
+ for (var i = 0 ; i < d.count(); i ++) {
+
+ if (d.get(i).get(-1).isComplete() && (controller.options.nonTransactionalEditable || isTransactional(d.get(i)))) {
+
+ // for the geometries from a kml, there is another save dialogue
+ if (d.get(i).isFromKml()) {
+ // if the kml is in the db (id = id in database)
+ if (d.get(i).e.getElementValueByName("Mapbender:id")) {
+ // button: geometry information, update kml
+ listOfGeom += "<li>";
+ listOfGeom += "<img src = '"+buttonImageFolder + buttonDig_wfs_src+"' title='"+msgObj.buttonDig_wfs_title+"' onclick='showWfsKml("+i+")'>";
+ }
+ }
+ else {
+ // button: geometry information, save, update, delete
+ listOfGeom += "<li>";
+ if (wfsExistsForGeom(d.get(i), wfsConf)) {
+ listOfGeom += "<img src = '"+buttonImageFolder+buttonDig_wfs_src+"' title='"+msgObj.buttonDig_wfs_title+"' onclick='showWfs("+i+")'>";
+ }
+
+ // button: remove this geometry
+ listOfGeom += "<img src = '"+buttonImageFolder+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(controller.currentEvent);d.del("+i+");this.eventAfterDigitizing.trigger();'>";
+ }
+
+ // button: remove geometry from database
+ if (isValidWfsConfIndex(wfsConf, d.get(i).wfs_conf)) {
+ listOfGeom += "<img src = '"+buttonImageFolder+buttonDig_removeDb_src+"' title='"+msgObj.buttonDig_removeDb_title+"' onclick=\"var deltrans = confirm('"+msgObj.messageConfirmDeleteGeomFromDb+"');if (deltrans) dbGeom('delete', "+i+")\">";
+ }
+ listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+"));' ";
+ listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+"))' ";
+ listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+"));' ";
+ var geomName = getName(d.get(i)) || msgObj.digitizeDefaultGeometryName;
+ var currentGeomType;
+ if (d.get(i).geomType == parent.geomType.polygon) {
+ currentGeomType = msgObj.messageDescriptionPolygon;
+ }
+ else if (d.get(i).geomType == parent.geomType.line) {
+ currentGeomType = msgObj.messageDescriptionLine;
+ }
+ else if (d.get(i).geomType == parent.geomType.point) {
+ currentGeomType = msgObj.messageDescriptionPoint;
+ }
+ var multi = "";
+ if (d.get(i).count() > 1) {
+ multi = "multi";
+ }
+ listOfGeom += ">" + geomName +" (" + multi + currentGeomType + ")</div>";
+
+ // multigeometries
+ listOfGeom += "<ul>";
+ for (var j = 0; j < d.get(i).count(); j++) {
+ var currentGeom = d.get(i).get(j);
+ if (d.get(i).count() > 1 || (d.get(i).geomType == parent.geomType.polygon &&
+ d.get(i).get(j).innerRings &&
+ d.get(i).get(j).innerRings.count() > 0)) {
+ listOfGeom += "<li>";
+ listOfGeom += "<img src = '"+buttonDig_imgdir+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(controller.currentEvent);d.get("+i+").del(" + j + ");this.eventAfterDigitizing.trigger();'>";
+ listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.get("+i+").get("+j+"));' ";
+ listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.get("+i+").get("+j+"))' ";
+ listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.get("+i+").get("+j+"));' ";
+ listOfGeom += ">" + currentGeomType + "#" + (j+1) +"</div></li>";
+ }
+ if (d.get(i).geomType == parent.geomType.polygon &&
+ d.get(i).get(j).innerRings &&
+ d.get(i).get(j).innerRings.count() > 0) {
+ listOfGeom += "<ul>";
+ for (var k = 0; k < d.get(i).get(j).innerRings.count(); k++) {
+ var currentRing = d.get(i).get(j).innerRings.get(k);
+ listOfGeom += "<li>";
+ listOfGeom += "<img src = '"+buttonImageFolder+buttonDig_remove_src+"' title='"+msgObj.buttonDig_remove_title+"' onclick='parent.mb_disableThisButton(controller.currentEvent);d.get("+i+").get(" + j + ").innerRings.del(" + k + ");this.eventAfterDigitizing.trigger();'>";
+ listOfGeom += "<div class='digitizeGeometryListItem' onmouseover='parent.mb_wfs_perform(\"over\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "));' ";
+ listOfGeom += " onmouseout='parent.mb_wfs_perform(\"out\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "))' ";
+ listOfGeom += " onclick='parent.mb_wfs_perform(\"click\",d.getGeometry("+i+","+j+").innerRings.get(" + k + "));' ";
+ listOfGeom += ">inner ring #" + (k+1) +"</div></li>";
+
+ }
+ listOfGeom += "</ul>";
+ }
+ }
+ listOfGeom += "</ul>";
+ listOfGeom += "</li>";
+ }
+ }
+ }
+ listOfGeom += "<ul>";
+ parent.writeTag(mod_digitize_elName,"listOfGeometries",listOfGeom);
+ };
+
+ this.applyMessages = function () {
+ this.updateMeasureTag();
+ this.updateListOfGeometries();
+ this.updateButtons();
+ };
+ var that = this;
+
+ this.getMessages = function () {
+ parent.mb_ajax_json("../php/mod_digitize_messages.php", function(obj, status) {
+ msgObj = obj;
+ that.applyMessages();
+ });
+ };
+ // ===========================================================
+ // BUTTONS BEGIN
+ // ===========================================================
+
+ //
+ // INITIALISATION
+ //
+ var displayButtons = function () {
+ for (var i = 0 ; i < buttonArray.length ; i ++) {
+ var b = buttonArray[i];
+ if (parseInt(b.status, 10) === 1) {
+ var divTag = document.createElement("div");
+ divTag.setAttribute("id", "div_" + b.name);
+ document.getElementById("digButtons").appendChild(divTag);
+
+ var tagContent = "<div style='position:absolute; top:"+b.top+"px; left:"+b.left+"px;'>" +
+ "<img name=\""+b.name+"\" " +
+ "onmouseover=\"parent.mb_regButton_frame('digitizeView.initDigButton', mod_digitize_elName, " + i +");\" " +
+ "id=\""+b.name+"\" title=\""+b.imgOff+"\" src=\""+buttonImageFolder+b.imgOff+"\"></div>";
+ parent.writeTag("digitize","div_" + b.name,tagContent);
+ }
+ }
+ };
+
+ this.initDigButton = function (ind, pos){
+ var b = buttonArray[pos];
+ parent.mb_button[ind] = document.getElementById(b.name);
+ parent.mb_button[ind].img_over = buttonImageFolder + b.imgOff.replace(/_off/,"_over");
+ parent.mb_button[ind].img_on = buttonImageFolder + b.imgOff.replace(/_off/,"_on");
+ parent.mb_button[ind].img_off = buttonImageFolder + b.imgOff;
+ parent.mb_button[ind].title_on = b.title;
+ parent.mb_button[ind].title_off = b.title;
+ parent.mb_button[ind].status = 0;
+ parent.mb_button[ind].elName = b.name;
+ parent.mb_button[ind].fName = "";
+ parent.mb_button[ind].go = function(){
+ that.digitizeEnable(parent.mb_button[ind]);
+ };
+ parent.mb_button[ind].stop = function(){
+ that.digitizeDisable(parent.mb_button[ind]);
+ };
+ };
+
+ //
+ // UPDATE
+ //
+ this.updateButtons = function () {
+ for (var i = 0 ; i < buttonArray.length ; i++) {
+ var b = buttonArray[i];
+ if (parseInt(b.status, 10) === 1) {
+ var currentButton = document.getElementById(b.name);
+ var status = currentButton.status;
+ var newTitle = "";
+ switch (b.name) {
+ case "Point":
+ newTitle = (status == 1 ? msgObj.buttonLabelPointOn : msgObj.buttonLabelPointOff);
+ break;
+ case "Line":
+ newTitle = (status == 1 ? msgObj.buttonLabelLineOn : msgObj.buttonLabelLineOff);
+ break;
+ case "Polygon":
+ newTitle = (status == 1 ? msgObj.buttonLabelPolygonOn : msgObj.buttonLabelPolygonOff);
+ break;
+ case "dragBasePoint":
+ newTitle = (status == 1 ? msgObj.buttonLabelMoveBasepointOn : msgObj.buttonLabelMoveBasepointOff);
+ break;
+ case "setBasePoint":
+ newTitle = (status == 1 ? msgObj.buttonLabelInsertBasepointOn : msgObj.buttonLabelInsertBasepointOff);
+ break;
+ case "delBasePoint":
+ newTitle = (status == 1 ? msgObj.buttonLabelDeleteBasepointOn : msgObj.buttonLabelDeleteBasepointOff);
+ break;
+ case "clear":
+ newTitle = (status == 1 ? msgObj.buttonLabelClearListOn : msgObj.buttonLabelClearListOff);
+ break;
+ case "digitizeSplit":
+ newTitle = (status == 1 ? msgObj.buttonLabelSplitOn : msgObj.buttonLabelSplitOff);
+ break;
+ case "digitizeMerge":
+ newTitle = (status == 1 ? msgObj.buttonLabelMergeOn : msgObj.buttonLabelMergeOff);
+ break;
+ case "digitizeDifference":
+ newTitle = (status == 1 ? msgObj.buttonLabelDifferenceOn : msgObj.buttonLabelDifferenceOff);
+ break;
+ }
+ currentButton.title = newTitle;
+ }
+ }
+ };
+
+ //
+ // INTERACTION
+ //
+ // when a button is clicked, this funtion is called
+ this.digitizeEnable = function (obj) {
+ var d = controller.model.getData();
+
+ if (obj.id == controller.eventArray.move ||
+ obj.id == controller.eventArray.insert ||
+ obj.id == controller.eventArray.remove) {
+ controller.currentEvent = obj.id;
+ this.eventBeforeDigitizing.trigger();
+ }
+ else if (obj.id == controller.eventArray.point ||
+ obj.id == controller.eventArray.line ||
+ obj.id == controller.eventArray.polygon ||
+ obj.id == controller.eventArray.clear ||
+ obj.id == controller.eventArray.split ||
+ obj.id == controller.eventArray.merge ||
+ obj.id == controller.eventArray.difference) {
+
+
+ if (controller.currentEvent == controller.eventArray.point ||
+ controller.currentEvent == controller.eventArray.line ||
+ controller.currentEvent == controller.eventArray.polygon) {
+ //
+ // Add event handlers to map
+ //
+ var el = parent.frames[mod_digitize_target].document;
+ el.onmousemove = addEventHandlersToMap;
+ }
+
+ controller.currentEvent = obj.id;
+
+ if (controller.currentEvent == controller.eventArray.point ||
+ controller.currentEvent == controller.eventArray.line ||
+ controller.currentEvent == controller.eventArray.polygon ||
+ controller.currentEvent == controller.eventArray.insert ) {
+ s.store(d);
+ }
+
+ this.eventBeforeDigitizing.trigger();
+
+ obj.title = obj.title_on;
+ if (obj.id == controller.eventArray.point) {
+ if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
+ if (d.get(-1).geomType != parent.geomType.point) {
+ d.close();
+ this.eventAfterDigitizing.trigger();
+ }
+ else {
+ s.add(d.getPoint(-1, -1, 0));
+ }
+ }
+ if (d.count() === 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
+ d.addMember(parent.geomType.point);
+ d.get(-1).addGeometry();
+ }
+ }
+ else if (obj.id == controller.eventArray.polygon) {
+ if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
+ if (d.get(-1).geomType != parent.geomType.polygon) {
+ d.close();
+ this.eventAfterDigitizing.trigger();
+ }
+ else {
+ s.add(d.getPoint(-1, -1, 0));
+ }
+ }
+ if (d.count() === 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
+ // new geometry
+ d.addMember(parent.geomType.polygon);
+ d.get(-1).addGeometry();
+ }
+ }
+ else if (obj.id == controller.eventArray.line) {
+ if (d.count() > 0 && d.get(-1).count() > 0 && !d.get(-1).get(-1).isComplete()) {
+ if (d.get(-1).geomType != parent.geomType.line) {
+ d.close();
+ this.eventAfterDigitizing.trigger();
+ }
+ else {
+ s.add(d.getPoint(-1, -1, 0));
+ }
+ }
+ if (d.count() === 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
+ d.addMember(parent.geomType.line);
+ d.get(-1).addGeometry();
+ }
+ }
+ else if (obj.id == controller.eventArray.clear) {
+ var clear = confirm(msgObj.messageConfirmDeleteAllGeomFromList);
+ if (clear) {
+ d = new parent.GeometryArray();
+ parent.mb_disableThisButton(controller.eventArray.clear);
+ }
+ }
+ else if (obj.id == controller.eventArray.merge) {
+ var applicable = (d.count() > 1);
+
+ var polygonTextArray = [];
+ for (var i = 0; i < d.count(); i++) {
+ if (d.get(i).geomType != parent.geomType.polygon) {
+ applicable = false;
+ polygonTextArray = [];
+ break;
+ }
+ polygonTextArray.push(d.get(i).toText());
+ }
+
+ if (!applicable) {
+ alert(msgObj.messageErrorMergeNotApplicable);
+ parent.mb_disableThisButton(controller.eventArray.merge);
+ return false;
+ }
+
+ parent.mb_ajax_post("../php/mod_digitize_mergePolygon.php", {polygons: polygonTextArray.join(";")}, function(json, status) {
+ var response = eval('(' + json + ')');
+ var polygon = response.polygon;
+ d.importGeometryFromText(polygon);
+ parent.mb_disableThisButton(controller.eventArray.merge);
+ });
+ }
+ else if (obj.id == controller.eventArray.split) {
+ var applicable = (d.count() == 2) &&
+ (d.get(0).geomType == parent.geomType.polygon) &&
+ (d.get(1).geomType == parent.geomType.line);
+ if (!applicable) {
+ alert(msgObj.messageErrorSplitNotApplicable);
+ parent.mb_disableThisButton(controller.eventArray.split);
+ return false;
+ }
+
+ var polygonText = d.get(0).toText();
+ var lineText = d.get(1).toText();
+
+ parent.mb_ajax_post("../php/mod_digitize_splitPolygon.php", {polygon: polygonText, line: lineText}, function(json, status) {
+ var response = eval('(' + json + ')');
+ var polygonArray = response.polygons;
+ for (var i in polygonArray) {
+ d.importGeometryFromText(polygonArray[i]);
+ }
+ parent.mb_disableThisButton(controller.eventArray.split);
+ });
+ }
+ else if (obj.id == controller.eventArray.difference) {
+ var applicable = (d.count() == 2) &&
+ (d.get(0).geomType == parent.geomType.polygon) &&
+ (d.get(1).geomType == parent.geomType.polygon);
+ if (!applicable) {
+ alert(msgObj.messageErrorDifferenceNotApplicable);
+ parent.mb_disableThisButton(controller.eventArray.difference);
+ return false;
+ }
+
+ var polygon1Text = d.get(0).toText();
+ var polygon2Text = d.get(1).toText();
+
+ parent.mb_ajax_post("../php/mod_digitize_differencePolygon.php", {polygon1: polygon1Text, polygon2: polygon2Text}, function(json, status) {
+ var response = eval('(' + json + ')');
+ var polygonArray = response.polygons;
+ for (var i in polygonArray) {
+ d.importGeometryFromText(polygonArray[i]);
+ }
+ parent.mb_disableThisButton(controller.eventArray.difference);
+ });
+ }
+ }
+ };
+
+ /**
+ * Called when a Button is deactivated
+ *
+ * @param {Object} obj the button DOM element
+ */
+ this.digitizeDisable = function (obj) {
+ if (obj.id == controller.eventArray.point ||
+ obj.id == controller.eventArray.line ||
+ obj.id == controller.eventArray.polygon){
+
+ obj.title = obj.title_off;
+ var d = controller.model.getData();
+ if (d.get(-1).get(-1).count() === 0) {
+ d.delGeometry(-1,-1);
+ }
+ removeEventHandlersFromMap();
+ this.eventAfterDigitizing.trigger();
+ }
+ else {
+ removeEventHandlersFromMap();
+ this.eventAfterDigitizing.trigger();
+ }
+ };
+
+ // ===========================================================
+ // BUTTONS END
+ // ===========================================================
+
+ this.drawDashedLine = function (){
+ if (!controller.options.nonTransactionalEditable) {
+ nonTransactionalHighlight.clean();
+ }
+ 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>";
+
+ if (!controller.options.nonTransactionalEditable) {
+ nonTransactionalHighlight.clean();
+ }
+ var smPArray = [];
+ smPArray[smPArray.length] = "<div class='t_img'>"
+ + "<img src='"+parent.mb_trans.src+"' width='"+mod_digitize_width+"' height='0'></div>"
+ + "<div class='t_img'>"
+ + "<img src='"+parent.mb_trans.src+"' width='0' height='"+mod_digitize_height+"'></div>";
+
+ var mapObj = parent.mb_mapObj[parent.getMapObjIndexByName(mod_digitize_target)];
+ var width = mapObj.width;
+ var height = mapObj.height;
+ var arrayBBox = mapObj.extent.split(",");
+ var minX = parseFloat(arrayBBox[0]);
+ var minY = parseFloat(arrayBBox[1]);
+ var maxX = parseFloat(arrayBBox[2]);
+ var maxY = parseFloat(arrayBBox[3]);
+ var cx = width/(maxX - minX);
+ var cy = height/(maxY - minY);
+ var isMoveOrInsertOrDelete = controller.currentEvent == controller.eventArray.move || controller.currentEvent == controller.eventArray.insert || controller.currentEvent == controller.eventArray.remove;
+ var minDist = 6;
+
+ var d = controller.model.getData();
+
+ for(var i=0, lenGeomArray = d.count(); i < lenGeomArray; i++){
+ var currentGeomArray = d.get(i);
+
+ if (!controller.options.nonTransactionalEditable && !isTransactional(currentGeomArray)) {
+ nonTransactionalHighlight.add(currentGeomArray, nonTransactionalColor);
+ }
+ else {
+ for(var j=0, lenGeom = currentGeomArray.count(); j < lenGeom ; j++){
+ var currentGeometry = d.getGeometry(i,j);
+ var isPolygon = currentGeomArray.geomType == parent.geomType.polygon;
+ var isLine = currentGeomArray.geomType == parent.geomType.line;
+ var isComplete = currentGeometry.isComplete();
+ var lastPaintedPoint = false;
+
+ for(var k = 0, lenPoint = currentGeometry.count(); k < lenPoint; k++){
+ var currentPoint = currentGeometry.get(k);
+ var currentPointMap = new parent.Point(Math.round((currentPoint.x - minX)*cx), Math.round((maxY - currentPoint.y)*cy));
+
+ // var isTooCloseToPrevious = lastPaintedPoint && (k > 0) && Math.abs(currentPointMap.x-lastPaintedPoint.x) <= minDist && Math.abs(currentPointMap.y-lastPaintedPoint.y) <= minDist;
+ // if (!isTooCloseToPrevious) {
+ var currentPointIsVisible = currentPointMap.x > 0 && currentPointMap.x < width && currentPointMap.y > 0 && currentPointMap.y < height;
+ if (currentPointIsVisible) {
+ if (!isComplete && ((k === 0 && isPolygon) || (k == lenPoint-1 && isLine))) {
+ smPArray[smPArray.length] = "<div class='bp' style='top:"+
+ (currentPointMap.y-2)+"px;left:"+(currentPointMap.x-2)+"px;z-index:"+
+ digitizeTransactionalZIndex+";background-color:"+linepointColor+"'";
+ }
+ else {
+ smPArray[smPArray.length] = "<div class='bp' style='top:"+(currentPointMap.y-2)+"px;left:"+(currentPointMap.x-2)+"px;z-index:"+digitizeTransactionalZIndex+";'";
+ }
+ if(k === 0 && isPolygon && !isComplete){
+ smPArray[smPArray.length] = " title='"+msgObj.closePolygon_title+"' ";
+ }
+ if(isMoveOrInsertOrDelete) {
+ smPArray[smPArray.length] = " onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].digitizeView.handleBasepoint(this,"+i+","+j+","+k+")' ;";
+ }
+ smPArray[smPArray.length] = "></div>";
+ lastPaintedPoint = currentPointMap;
+ }
+ if (k > 0) {
+ points = parent.calculateVisibleDash(currentPointMap, previousPointMap, width, height);
+ if (points !== false) {
+ smPArray[smPArray.length] = evaluateDashes(points[0], points[1], i, j, k);
+ }
+ }
+ // }
+ var previousPointMap = currentPointMap;
+ }
+ if (isPolygon && currentGeometry.innerRings.count() > 0) {
+ // draw inner rings
+
+ for (var l = 0, lenRings = currentGeometry.innerRings.count(); l < lenRings; l++) {
+ var currentRing = currentGeometry.innerRings.get(l);
+ var lastPaintedPoint = false;
+
+ for (var m = 0, lenPoint = currentRing.count(); m < lenPoint; m++) {
+ var currentPoint = currentRing.get(m);
+ var currentPointMap = new parent.Point(Math.round((currentPoint.x - minX) * cx), Math.round((maxY - currentPoint.y) * cy));
+
+ // var isTooCloseToPrevious = lastPaintedPoint && (k > 0) && Math.abs(currentPointMap.x-lastPaintedPoint.x) <= minDist && Math.abs(currentPointMap.y-lastPaintedPoint.y) <= minDist;
+ // if (!isTooCloseToPrevious) {
+ var currentPointIsVisible = currentPointMap.x > 0 && currentPointMap.x < width && currentPointMap.y > 0 && currentPointMap.y < height;
+ if (currentPointIsVisible) {
+ if (!isComplete && ((k === 0 && isPolygon) || (k == lenPoint - 1 && isLine))) {
+ smPArray[smPArray.length] = "<div class='bp' style='top:" +
+ (currentPointMap.y - 2) +
+ "px;left:" +
+ (currentPointMap.x - 2) +
+ "px;z-index:" +
+ digitizeTransactionalZIndex +
+ ";background-color:" +
+ linepointColor +
+ "'";
+ }
+ else {
+ smPArray[smPArray.length] = "<div class='bp' style='top:" + (currentPointMap.y - 2) + "px;left:" + (currentPointMap.x - 2) + "px;z-index:" + digitizeTransactionalZIndex + ";'";
+ }
+ if (m === 0 && isPolygon && !isComplete) {
+ smPArray[smPArray.length] = " title='" + msgObj.closePolygon_title + "' ";
+ }
+ if (isMoveOrInsertOrDelete) {
+ smPArray[smPArray.length] = " onmouseover='parent.window.frames[\"" + mod_digitize_elName + "\"].digitizeView.handleBasepoint(this," + i + "," + j + "," + l + "," + m + ")' ;";
+ }
+ smPArray[smPArray.length] = "></div>";
+ lastPaintedPoint = currentPointMap;
+ }
+ if (m > 0) {
+ points = parent.calculateVisibleDash(currentPointMap, previousPointMap, width, height);
+ if (points !== false) {
+ smPArray[smPArray.length] = evaluateDashes(points[0], points[1], i, j, l, m);
+ }
+ }
+ // }
+ var previousPointMap = currentPointMap;
+ }
+ }
+ }
+ }
+ }
+ }
+ digitizeDivTag.write(smPArray.join(""));
+ };
+
+ var evaluateDashes = function (start, end, memberIndex, geomIndex, ringIndex, pointIndex){
+ if (pointIndex === undefined) {
+ pointIndex = ringIndex;
+ ringIndex = undefined;
+ }
+ var d = controller.model.getData();
+ var strArray = [];
+ var delta = new parent.Point(end.x - start.x, end.y - start.y);
+ var lastGeomIsComplete = d.getGeometry(-1,-1).isComplete();
+
+ var vecLength = start.dist(end);
+ var n = Math.round(vecLength/dotDistance);
+ if (n > 0) {
+ var step = delta.dividedBy(n);
+ }
+ for(var i=1; i < n; i++){
+ 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){
+ if (memberIndex == d.count()-1 && !lastGeomIsComplete) {
+ strArray[strArray.length] = "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:"+digitizeTransactionalZIndex+";background-color:"+linepointColor+"' ";
+ }
+ else {
+ strArray[strArray.length] = "<div class='lp' style='top:"+y+"px;left:"+x+"px;z-index:"+digitizeTransactionalZIndex+";' ";
+ }
+ if(controller.currentEvent == controller.eventArray.insert) {
+ strArray[strArray.length] = "onmouseover='parent.window.frames[\""+mod_digitize_elName+"\"].digitizeView.convertLinepointToBasepoint(this,"+memberIndex+","+geomIndex+","+ringIndex+","+pointIndex+")'";
+ }
+ strArray[strArray.length] = "></div>";
+ }
+ }
+ return strArray.join("");
+ };
+
+ /**
+ * Adds event handlers to the map, corresponding to each button
+ *
+ * @param {Object} e event
+ */
+ var addEventHandlersToMap = function (e){
+ // 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 parent.Point(parent.clickX, parent.clickY);
+ s.check(currentPos);
+ }
+
+ var el = parent.frames[mod_digitize_target].document;
+ el.onmousedown = function(e){
+ var realWorldPos;
+ if (s.isSnapped()) {
+ realWorldPos = s.getSnappedPoint();
+ s.clean();
+ }
+
+ if (!realWorldPos) {
+ parent.mb_getMousePos(e, mod_digitize_target);
+ realWorldPos = parent.mapToReal(mod_digitize_target,new parent.Point(parent.clickX,parent.clickY));
+ }
+
+ controller.mod_digitize_start(realWorldPos);
+ };
+ };
+
+ this.addPointToSnapList = function (somePoint) {
+ s.add(somePoint);
+ };
+
+ /**
+ * Removes all event handlers from the map
+ */
+ var removeEventHandlersFromMap = function (){
+ var el = parent.frames[mod_digitize_target].document;
+ el.onmousedown = null;
+ el.onmouseup = null;
+ el.onmousemove = null;
+ };
+
+ this.handleBasepoint = function (obj, memberIndex, geometryIndex, ringIndex, pointIndex) {
+ if (!(
+ controller.eventIsMove ||
+ controller.eventIsInsert ||
+ controller.eventIsRemove)
+ ) {
+ return false;
+ }
+
+ var indexObject = {};
+ indexObject.memberIndex = memberIndex;
+ indexObject.geometryIndex = geometryIndex;
+
+ // if point index is undefined, then the polygon
+ // has no rings, and the ring Index has to be set
+ // to undefined
+ if (pointIndex === undefined) {
+ pointIndex = ringIndex;
+ indexObject.ringIndex = undefined;
+ }
+ else {
+ indexObject.ringIndex = ringIndex;
+ }
+ indexObject.pointIndex = pointIndex;
+
+ this.eventCurrentPointHasChanged.trigger(indexObject);
+
+ console.log("Event: %s", controller.currentEvent);
+
+ var basepointObject = obj;
+ if (controller.eventIsMove) {
+ console.log("Event: %s", controller.currentEvent);
+ basepointObject.style.cursor = 'move';
+ basepointObject.onmousedown = function (e) {
+ selectBasepoint(e);
+ };
+ }
+
+ if (controller.eventIsRemove) {
+ basepointObject.style.cursor = 'crosshair';
+ basepointObject.onmousedown = function(e) {
+ controller.deleteCurrentPoint();
+ that.eventAfterDigitizing.trigger();
+ };
+ }
+ };
+
+ this.eventCurrentPointHasChanged = new parent.MapbenderEvent();
+
+ this.convertLinepointToBasepoint = function (obj, memberIndex, geomIndex, ringIndex, pointIndex){
+ if (!(controller.eventIsInsert)) {
+ return false;
+ }
+
+ obj.style.cursor = 'crosshair';
+ obj.onclick = function(e){
+ insertBasepoint(e);
+ };
+
+ basepointObject = obj;
+ var indexObject = {};
+ indexObject.memberIndex = memberIndex;
+ indexObject.geometryIndex = geomIndex;
+ indexObject.ringIndex = ringIndex;
+ indexObject.pointIndex = pointIndex;
+ this.eventCurrentPointHasChanged.trigger(indexObject);
+ };
+
+ var insertBasepoint = function (e){
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var pos = parent.makeClickPos2RealWorldPos(mod_digitize_target,parent.clickX, parent.clickY);
+ var p = new parent.Point(pos[0], pos[1]);
+
+ controller.insertNewPoint(p);
+
+ that.eventAfterDigitizing.trigger();
+ };
+
+
+ this.selectBasepoint = function (e){
+ if(!basepointDragActive && this.currentEvent == this.eventArray.move){
+ basepointDragActive = true;
+ s.store(d, d.getPoint(basepointMemberIndex, basepointGeometryIndex, basepointPointIndex));
+ // 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/transparent.gif)";
+ }
+ else{
+ basepointObject.style.backgroundColor = 'transparent';
+ }
+
+ basepointObject.onmouseup = releaseBasepoint;
+ basepointObject.onmousemove = dragBasepoint;
+ }
+ };
+
+ this.dragBasepoint = function (e){
+ if(basepointDragActive){
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var currentPos = new parent.Point(parent.clickX, parent.clickY);
+ var res = s.check(currentPos);
+
+ }
+ };
+
+ this.releaseBasepoint = function (e){
+
+ var i = basepointMemberIndex;
+ var j = basepointGeometryIndex;
+ var k = basepointRingIndex;
+ var l = basepointPointIndex;
+ basepointDragActive = false;
+
+ parent.mb_getMousePos(e, mod_digitize_target);
+ var basepointDragEnd = new parent.Point(parent.clickX, parent.clickY);
+ basepointObject.onmousedown = null;
+ var p = parent.makeClickPos2RealWorldPos(mod_digitize_target, basepointDragEnd.x, basepointDragEnd.y);
+
+ var oldPoint;
+ if (k === undefined) {
+ oldPoint = parent.cloneObject(d.getPoint(i,j,l));
+ }
+ else {
+ oldPoint = parent.cloneObject(d.getPoint(i,j,k,l));
+ }
+ if (s.isSnapped()) {
+ var snappedPoint = parent.cloneObject(s.getSnappedPoint());
+ if (!this.options.nonTransactionalEditable) {
+ updateAllPointsOfNonTransactionalLike(oldPoint, snappedPoint);
+ }
+ else {
+ d.updateAllPointsLike(oldPoint, snappedPoint);
+ }
+ s.clean();
+ }
+ else {
+ var newPoint = new parent.Point(p[0],p[1]);
+ if (!this.options.nonTransactionalEditable) {
+ updateAllPointsOfNonTransactionalLike(oldPoint, newPoint);
+ }
+ else {
+ d.updateAllPointsLike(oldPoint, newPoint);
+ }
+ }
+ basepointMemberIndex = null;
+ basepointGeometryIndex = null;
+ basepointPointIndex = null;
+
+ executeDigitizeSubFunctions();
+ };
+
+
+
+ this.eventBeforeDigitizing = new parent.MapbenderEvent();
+ this.eventAfterDigitizing = new parent.MapbenderEvent();
+
+ this.eventBeforeDigitizing.register(function () {
+ console.log("eventBeforeDigitizing %s", controller.currentEvent);
+ this.updateExtent();
+ this.drawDashedLine();
+ }, this);
+
+ this.eventAfterDigitizing.register(function () {
+ console.log("eventAfterDigitizing");
+ this.updateListOfGeometries();
+ this.drawDashedLine();
+ }, this);
+
+ // DigitizeView constructor
+ displayButtons();
+
+ controller.eventNoGeometrySelected.register(function () {
+ alert(msgObj.errorMessageNoGeometrySelected);
+ }, this);
+};
\ No newline at end of file
Added: branches/digi_mvc_dev/newProject
===================================================================
--- branches/digi_mvc_dev/newProject (rev 0)
+++ branches/digi_mvc_dev/newProject 2008-11-12 08:57:26 UTC (rev 3229)
@@ -0,0 +1,3 @@
+<?php
+ phpinfo();
+?>
More information about the Mapbender_commits
mailing list