Przeglądaj źródła

TableAjaxMap: transform geom before saving feature

Piotr Labudda 11 lat temu
rodzic
commit
6f112dc9e5
1 zmienionych plików z 16 dodań i 12 usunięć
  1. 16 12
      SE/se-lib/TableAjaxMap.php

+ 16 - 12
SE/se-lib/TableAjaxMap.php

@@ -110,7 +110,7 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 			$(priv.options.id).append(div);
 			$(priv.options.id).append(div);
 
 
 			_nodeProcesses.on('change', function() {
 			_nodeProcesses.on('change', function() {
-				console.log("onchange this:", this, this.selectedIndex, this.options);
+				if (priv.options.debug) console.log("onchange this:", this, this.selectedIndex, this.options);
 				var selection = this.options[this.selectedIndex].value;
 				var selection = this.options[this.selectedIndex].value;
 				if (this.selectedIndex > 0) {
 				if (this.selectedIndex > 0) {
 					OpenLayers.Request.GET({
 					OpenLayers.Request.GET({
@@ -125,7 +125,7 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 							_process = new OpenLayers.Format.WPSDescribeProcess().read(
 							_process = new OpenLayers.Format.WPSDescribeProcess().read(
 								response.responseText
 								response.responseText
 							).processDescriptions[selection];
 							).processDescriptions[selection];
-							console.log("Process:", _process);
+							if (priv.options.debug) console.log("Process:", _process);
 							priv.buildForm();
 							priv.buildForm();
 						}
 						}
 					});
 					});
@@ -206,19 +206,19 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 
 
 			_layer.events.on({
 			_layer.events.on({
 				'beforefeaturemodified': function(e) {
 				'beforefeaturemodified': function(e) {
-					console.log('Event: beforefeaturemodified modified(', e.feature.attributes._modified, ')', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
+					if (priv.options.debug) console.log('Event: beforefeaturemodified modified(', e.feature.attributes._modified, ')', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
 					// NOTE: beforefeaturemodified from new node is fired before afterfeaturemodified from old node when click from one node to enother
 					// NOTE: beforefeaturemodified from new node is fired before afterfeaturemodified from old node when click from one node to enother
 					priv.checkSelectedFeatureModifications('before');
 					priv.checkSelectedFeatureModifications('before');
 					priv.setSelectedFeature(e.feature);
 					priv.setSelectedFeature(e.feature);
 				},
 				},
 				'featuremodified': function(e) {
 				'featuremodified': function(e) {
-					console.log('Event: featuremodified modified(', e.feature.attributes._modified, ') ', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
+					if (priv.options.debug) console.log('Event: featuremodified modified(', e.feature.attributes._modified, ') ', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
 					_selectedFeature.attributes._modified = 1;
 					_selectedFeature.attributes._modified = 1;
 				},
 				},
 				'afterfeaturemodified': function(e) {
 				'afterfeaturemodified': function(e) {
-					console.log('Event: afterfeaturemodified fid('+e.feature.fid+'/'+(_selectedFeature ? _selectedFeature.fid : 'null')+') modified(', e.feature.attributes._modified, ') ', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
+					if (priv.options.debug) console.log('Event: afterfeaturemodified fid('+e.feature.fid+'/'+(_selectedFeature ? _selectedFeature.fid : 'null')+') modified(', e.feature.attributes._modified, ') ', e.feature.attributes, ' selAttras', (_selectedFeature)? _selectedFeature.attributes : 'null');// TODO: DBG
 					if (_selectedFeature && _selectedFeature.fid != e.feature.fid) {
 					if (_selectedFeature && _selectedFeature.fid != e.feature.fid) {
-						console.log('Event: afterfeaturemodified pomiń check!');
+						if (priv.options.debug) console.log('Event: afterfeaturemodified pomiń check!');
 					} else {
 					} else {
 						priv.checkSelectedFeatureModifications('after');
 						priv.checkSelectedFeatureModifications('after');
 						priv.setSelectedFeature(null);
 						priv.setSelectedFeature(null);
@@ -297,12 +297,12 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 			});
 			});
 			btnSelectFeature.events.on({
 			btnSelectFeature.events.on({
 				"boxselectionend": function(e) {
 				"boxselectionend": function(e) {
-					console.log('SelectFeature boxselectionend event', e, e.bounds);
+					if (priv.options.debug) console.log('SelectFeature boxselectionend event', e, e.bounds);
 					if (typeof priv.options.onSelectBox == "function") {
 					if (typeof priv.options.onSelectBox == "function") {
 						var layerProj = _map.getProjectionObject();
 						var layerProj = _map.getProjectionObject();
 						var targetProj = new OpenLayers.Projection("EPSG:4326");
 						var targetProj = new OpenLayers.Projection("EPSG:4326");
 						var bounds = e.bounds.transform(layerProj, targetProj);
 						var bounds = e.bounds.transform(layerProj, targetProj);
-						console.log('SelectFeature boxselectionend event bounds', bounds);
+						if (priv.options.debug) console.log('SelectFeature boxselectionend event bounds', bounds);
 						priv.options.onSelectBox.call(this, bounds);
 						priv.options.onSelectBox.call(this, bounds);
 					}
 					}
 				}
 				}
@@ -397,7 +397,7 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 
 
 		priv.updateState = function() {
 		priv.updateState = function() {
 			// TODO: update state view
 			// TODO: update state view
-			//console.log('updateState: _selectedFeature:', _selectedFeature, ' _selectedRecordId:', _selectedRecordId);
+			//if (priv.options.debug) console.log('updateState: _selectedFeature:', _selectedFeature, ' _selectedRecordId:', _selectedRecordId);
 			if (_selectedFeature || _selectedRecordId) {
 			if (_selectedFeature || _selectedRecordId) {
 				
 				
 			} else {
 			} else {
@@ -424,7 +424,7 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 		};
 		};
 
 
 		priv.isSelectedFeature = function() {
 		priv.isSelectedFeature = function() {
-			console.log('_selectedFeature:', _selectedFeature);
+			if (priv.options.debug) console.log('_selectedFeature:', _selectedFeature);
 			return (_selectedFeature)? true : false;
 			return (_selectedFeature)? true : false;
 		};
 		};
 
 
@@ -453,7 +453,11 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 		priv.saveSelectedFeature = function() {
 		priv.saveSelectedFeature = function() {
 			if (priv.isSelectedFeatureModified()) {
 			if (priv.isSelectedFeatureModified()) {
 				if (typeof priv.options.onSaveFeature == "function") {
 				if (typeof priv.options.onSaveFeature == "function") {
-					var selFeatureExtent = new OpenLayers.Format.WKT().write(_selectedFeature);
+					var sourceProj = _map.getProjectionObject();
+					var targetProj = new OpenLayers.Projection("EPSG:4326");
+					var selFeatureGeometry = _selectedFeature.geometry.clone();
+					var selFeatureGeomTransformed = selFeatureGeometry.transform(sourceProj, targetProj);
+					var selFeatureExtent = new OpenLayers.Format.WKT().extractGeometry(selFeatureGeomTransformed);
 					priv.options.onSaveFeature.call(this, _selectedRecordId, selFeatureExtent);
 					priv.options.onSaveFeature.call(this, _selectedRecordId, selFeatureExtent);
 				}
 				}
 			}
 			}
@@ -563,7 +567,7 @@ OpenLayers.ProxyHost = "index-ajax.php?_zasobID=<?php echo $this->_zasobID; ?>&_
 					this.innerHTML = new OpenLayers.Format.WKT().write(
 					this.innerHTML = new OpenLayers.Format.WKT().write(
 						_layer.selectedFeatures[0]
 						_layer.selectedFeatures[0]
 					);
 					);
-					console.log('_layer.selectedFeatures[0]: ', _layer.selectedFeatures[0]);
+					if (priv.options.debug) console.log('_layer.selectedFeatures[0]: ', _layer.selectedFeatures[0]);
 				}
 				}
 				priv.createCopy(input, this, priv.addWKTInput);
 				priv.createCopy(input, this, priv.addWKTInput);
 			};
 			};