[OpenLayers-Commits] r4736 - in sandbox/timandseb/wfsv: examples lib/OpenLayers/Control
commits at openlayers.org
commits at openlayers.org
Mon Oct 1 13:47:40 EDT 2007
Author: sbenthall
Date: 2007-10-01 13:47:39 -0400 (Mon, 01 Oct 2007)
New Revision: 4736
Modified:
sandbox/timandseb/wfsv/examples/wfs-v.html
sandbox/timandseb/wfsv/lib/OpenLayers/Control/FeatureEditor.js
sandbox/timandseb/wfsv/lib/OpenLayers/Control/ModifyFeature.js
sandbox/timandseb/wfsv/lib/OpenLayers/Control/SelectFeature.js
Log:
WFS-V with attempted reverting of features when clicked on in the modified control (to allow for a "cancel" functionality).
Currently attempts to revert the changes to the version of the feature in the database by discarding the client-side feature and replacing it with one gotten from a getFeature request.
Problem: the returned feature from the getFeature request has the wrong projection, even though the getFeature request has an srsName attribute. This problem only occurs when I try to getFeature using a feature's fid. On the getFeature request built into the wfs-v example, the projection is passed in both in the srsName attribute and also in the BoundingBox sent in with the request. This leads me to think that the srsName attribute isn't being read.
Perhaps this bug hasn't _really_ been fixed?
http://jira.codehaus.org/browse/GEOS-1304
Modified: sandbox/timandseb/wfsv/examples/wfs-v.html
===================================================================
--- sandbox/timandseb/wfsv/examples/wfs-v.html 2007-10-01 15:38:14 UTC (rev 4735)
+++ sandbox/timandseb/wfsv/examples/wfs-v.html 2007-10-01 17:47:39 UTC (rev 4736)
@@ -217,9 +217,46 @@
"topp:restricted": {"cat": "Integer"},
"topp:archsites": {"cat": "Integer", "str1": "String"}
};
+
+
+ function addPopup(feature, content){
+ OpenLayers.Console.log("Creating Popup")
+ OpenLayers.Console.log(feature.geometry.getBounds().getCenterLonLat())
+ popup = new OpenLayers.Popup.AnchoredBubble("chicken",
+ feature.geometry.getBounds().getCenterLonLat(),
+ new OpenLayers.Size(250,75),
+ content,
+ null, true);
+
+ feature.popup = popup;
+ map.addPopup(popup,true);
+ }
+
+
+ function onHistoryStart(feature){
+ var hist = document.createElement("div")
+ hist.innerHTML = "History goes here"
+
+
+
+
+ addPopup(feature, hist)
+
+ }
+
function onViewStart(feature){
+
+ recallFeature(feature);
+
+ }
+
+ function onViewContinue(feature){
+
+ OpenLayers.Console.log("onViewContinue")
+
+ OpenLayers.Console.log(feature)
var view = document.createElement("div")
var table = document.createElement("table");
var caption = document.createElement("caption");
@@ -227,6 +264,7 @@
table.appendChild(caption);
var tbody = document.createElement("tbody");
var attr = feature.attributes;
+ OpenLayers.Console.log("Should be good until here")
var value, tr, td1, td2, valnode;
var name = document.getElementById('layerName').value.split(' ')[0];
for(var key in schema[name]) {
@@ -249,25 +287,133 @@
deleteb.onclick = function () { OpenLayers.Console.log("No delete functionality yet.");}
view.appendChild(deleteb);
var edit = document.createElement("button")
- //save.type = "button"
edit.onclick = function () {onModificationEnd(feature); onModificationStart(feature);}
edit.innerHTML = "Edit"
view.appendChild(edit);
+ var hist = document.createElement("button")
+ hist.onclick = function () {onModificationEnd(feature); onHistoryStart(feature);}
+ hist.innerHTML = "History"
+ view.appendChild(hist);
+ OpenLayers.Console.log(view);
+
+ addPopup(feature,view)
+ }
+
+
+
+
+ var xml = new OpenLayers.Format.XML();
+ var wfsns = "http://www.opengis.net/wfs";
+ var wfsvns = "http://www.opengis.net/wfsv";
+ var ogcns = "http://www.opengis.net/ogc";
+ var toppns = "http://www.openplans.org/topp";
+
+ function recallFeature(feature) {
+ OpenLayers.Console.log("recallFeature")
+ OpenLayers.Console.log(feature.geometry.getBounds().getCenterLonLat())
+
+ var getFeature = xml.createElementNS(wfsns, "wfs:GetFeature");
+ getFeature.setAttribute("version", "1.0.0");
+ getFeature.setAttribute("service", "WFSV");
+ getFeature.setAttribute("srsName", map.projection); // Shoudl be srsName? <-- Not sure how to do this right because map.projection is not a string. Need to see how this is parsed in OpenLayers.Util.getParameterString
+ getFeature.setAttribute("outputFormat", "GML2");
+ var query = xml.createElementNS(wfsns, "wfs:Query");
+ query.setAttribute("typeName", panel.featureType);
+ var filterProp = xml.createElementNS(ogcns, "ogc:Filter");
+ var featureProp = xml.createElementNS(ogcns, "ogc:FeatureId");
+ featureProp.setAttribute("fid", feature.fid);
+ filterProp.appendChild(featureProp);
+ query.appendChild(filterProp);
+ getFeature.appendChild(query);
+ var data = xml.write(getFeature);
+
+ var url = wfsUrl;
+ if(OpenLayers.ProxyHost && OpenLayers.String.startsWith(url, "http")) {
+ url = OpenLayers.ProxyHost + escape(url);
+ }
+
+ var xxyzzy = function(request){
+ var recalledFeature = panel.gml.read(request.responseXML);
- popup = new OpenLayers.Popup.AnchoredBubble("chicken",
- feature.geometry.getBounds().getCenterLonLat(),
- new OpenLayers.Size(250,75),
- view,
- null, true);
-
- feature.popup = popup;
- map.addPopup(popup,true);
+ potentialFeature = panel.vectorLayer.fids[feature.fid];
+ if(potentialFeature) {
+ panel.vectorLayer.removeFeatures([potentialFeature]);
+ }
+
+
+ panel.vectorLayer.addFeatures(recalledFeature,true)
+
+ onViewContinue(recalledFeature[0]);
+ };
+
+ new OpenLayers.Ajax.Request(url,
+ {method: 'post',
+ postBody: data,
+ onComplete: xxyzzy,
+ onFailure: function(request) {
+ OpenLayers.Console.error(request.responseText);
+ }
+ });
+
+ }
+
+ /*
+ * This method should:
+ * - remove a feature from the vector layer
+ * - request the same feature again
+ * - put the feature back into the vector layer
+ * - return this new feature
+ *
+ * This method is needed because feature attribute data is stored in the feature object
+ * on the vector layer (?). This method is for reseting the feature to have the same
+ * attributes it has server-side.
+ */
+
+ /*
+ recallFeature: (feature) {
+
+ var recalledFeature;
+
+
+ // TODO: put HTTPRequest.getFullRequestString in Util
+
+ var url = this.url + "?" + OpenLayers.Util.getParameterString(params);
+
+
+
+ this.vectorLayer.removeFeatures([feature])
+
+
+
+ var callback;
+
+ if(!reset){
+ if(evt.shiftKey) {
+ callback = this.addFeatures;
+
+ } else if(evt.ctrlKey) {
+ callback = this.removeFeatures;
+
+ } else {
+ callback = this.resetFeatures;
+ }
+ } else {
+
+ callback = this.resetFeatures;
+ OpenLayers.Console.log("2");
}
+ OpenLayers.loadURL(url, null, this, callback);
+ },
+
+
+ */
+
+
function onModificationStart(feature) {
OpenLayers.Console.log("onModificationStart("+feature+")")
@@ -317,8 +463,8 @@
var tabedit = document.createElement("div");
tabedit.appendChild(form);
var cancel = document.createElement('button')
- cancel.innerHTML = "Cancel"
- cancel.onclick = function () { onModificationEnd(feature);}
+ cancel.innerHTML = "*Cancel"
+ cancel.onclick = function () {OpenLayers.Console.log("Cancel will be broken until View and Modify take their information from a feature created by a new geoserver requesst as opposed to from the client-side stored feature (which needs to be modified in order for the panel to realize there has been something modified(?))"); onModificationEnd(feature); onViewStart(feature);}
tabedit.appendChild(cancel);
var save = document.createElement("button")
//save.type = "button"
@@ -343,14 +489,7 @@
//OpenLayers.Console.log(form)
- popup = new OpenLayers.Popup.AnchoredBubble("chicken",
- feature.geometry.getBounds().getCenterLonLat(),
- new OpenLayers.Size(250,75),
- tabedit,
- null, true);
-
- feature.popup = popup;
- map.addPopup(popup,true);
+ addPopup(feature,tabedit)
/*
var element = document.getElementById("popup-output");
@@ -378,13 +517,20 @@
}
}
+
+ function requestShownFeatures(){
+ var bounds = map.calculateBounds();
+ OpenLayers.Console.log("requestShownFeatures()")
+ panel.prepareRequest(bounds,true);
+ }
+
function confirmSave(always) {
var save = false;
if(panel.modified) {
- //var log = document.getElementById("logCheck").checked;
- if(true){ //if(log) {
+ var log = document.getElementById("logCheck").checked;
+ if(log) {
var defaultMessage = "modification " + panel.transId;
var response = prompt("Describe your changes (Cancel to not save).",
defaultMessage);
@@ -576,11 +722,19 @@
var name = featureType.substring(featureType.lastIndexOf(":") + 1);
wms[name].mergeNewParams({"token": Math.random()});
}
+
+
+
+
+
function toggleAdvanced() {
var style = document.getElementById("advanced").style;
style.display = (style.display == "block") ? "none" : "block";
}
+
+
+
OpenLayers.Util.extend(OpenLayers.Feature.Vector.style["default"], {
strokeOpacity: 0.75,
@@ -607,11 +761,11 @@
</p>
<a href="javascript: void toggleAdvanced();">more options</a>
<div id="advanced">
- <!--
+
<p>Require log messages
<input id="logCheck" type="checkbox" />
</p>
- -->
+
<p>Get changes for editable layer
<br />from <input type="text" id="fromRevision" size="3" />
to <input type="text" id="toRevision" size="3" />
Modified: sandbox/timandseb/wfsv/lib/OpenLayers/Control/FeatureEditor.js
===================================================================
--- sandbox/timandseb/wfsv/lib/OpenLayers/Control/FeatureEditor.js 2007-10-01 15:38:14 UTC (rev 4735)
+++ sandbox/timandseb/wfsv/lib/OpenLayers/Control/FeatureEditor.js 2007-10-01 17:47:39 UTC (rev 4736)
@@ -108,15 +108,17 @@
};
// getFeature request control
- this.featuresControl = new OpenLayers.Control.BoundsBox(
+ /* this.featuresControl = new OpenLayers.Control.BoundsBox(
this.prepareRequest, this);
-
+ */
+
// modify control
this.modifyControl = new OpenLayers.Control.ModifyFeature(
this.vectorLayer,
{displayClass: "olControlModifyFeature",
onModificationStart: this.onViewStart,
- onModificationEnd: this.onModificationEnd}
+ onModificationEnd: function(){},//this.onModificationEnd,
+ requestShownFeatures: function() {panel.requestShownFeatures()}}
);
this.modifyControl.onModification = function(feature) {
if(feature.state != OpenLayers.State.INSERT) {
@@ -144,7 +146,7 @@
this.addControls([this.saveControl,
this.modifyControl,
- this.featuresControl,
+ //this.featuresControl,
this.drawControl,
this.navigationControl]);
@@ -154,6 +156,13 @@
});
},
+
+
+ requestShownFeatures: function (){
+ OpenLayers.Console.log("requestShownFeatures()")
+ var bounds = this.map.calculateBounds();
+ this.prepareRequest(bounds,true);
+ },
/**
* Method: changeLayer
@@ -244,7 +253,7 @@
* Parameters:
* bounds - {<OpenLayers.Bounds>}
*/
- prepareRequest: function(bounds) {
+ prepareRequest: function(bounds,reset) {
var params = {
service: "WFS",
request: "getFeature",
@@ -255,9 +264,10 @@
};
// TODO: put HTTPRequest.getFullRequestString in Util
+
var url = this.url + "?" + OpenLayers.Util.getParameterString(params);
- this.requestFeatures(url);
+ this.requestFeatures(url,reset);
},
/**
@@ -267,20 +277,36 @@
* Parameters:
* url - {String}
*/
- requestFeatures: function(url) {
- OpenLayers.Console.log("FeatureEditor.requestFeatures")
+ requestFeatures: function(url, reset) {
+ //OpenLayers.Console.log("FeatureEditor.requestFeatures")
var callback;
- var evt = this.featuresControl.handler.evt;
- if(evt.shiftKey) {
- callback = this.addFeatures;
- } else if(evt.ctrlKey) {
- callback = this.removeFeatures;
+ //var evt = this.featuresControl.handler.evt;
+ //OpenLayers.Console.log("1");
+ //OpenLayers.Console.log(evt.shiftKey);
+ //OpenLayers.Console.log(reset);
+ if(!reset){
+ OpenLayers.Console.log(1.5);
+ if(evt.shiftKey) {
+ callback = this.addFeatures;
+ OpenLayers.Console.log("3");
+ } else if(evt.ctrlKey) {
+ callback = this.removeFeatures;
+ OpenLayers.Console.log("4");
+ } else {
+ callback = this.resetFeatures;
+ OpenLayers.Console.log("2");
+ }
} else {
- callback = this.resetFeatures;
- }
-
+ //ugly code duplication to avoid any contact with evt. which causes things to hang.
+ callback = this.resetFeatures;
+ OpenLayers.Console.log("2");
+ }
+
+ OpenLayers.Console.log(url);
+ OpenLayers.Console.log(this);
OpenLayers.loadURL(url, null, this, callback);
},
+
/**
* Method: addFeatures
Modified: sandbox/timandseb/wfsv/lib/OpenLayers/Control/ModifyFeature.js
===================================================================
--- sandbox/timandseb/wfsv/lib/OpenLayers/Control/ModifyFeature.js 2007-10-01 15:38:14 UTC (rev 4735)
+++ sandbox/timandseb/wfsv/lib/OpenLayers/Control/ModifyFeature.js 2007-10-01 17:47:39 UTC (rev 4736)
@@ -146,15 +146,19 @@
var control = this;
// configure the select control
+ OpenLayers.Console.log("onModificationStart : " + this.onModificationStart)
var selectOptions = {
+ hover:true,
geometryTypes: this.geometryTypes,
- onSelect: function(feature) {
+ onSelect: function(feature) {
control.selectFeature.apply(control, [feature]);
},
onUnselect: function(feature) {
control.unselectFeature.apply(control, [feature]);
- }
+ },
+ onClick: this.onModificationStart
};
+
this.selectControl = new OpenLayers.Control.SelectFeature(
layer, selectOptions
);
@@ -206,6 +210,9 @@
* {Boolean} Successfully activated the control and feature handler.
*/
activate: function() {
+
+ this.requestShownFeatures();
+
return (this.selectControl.activate() &&
this.keyboardHandler.activate() &&
OpenLayers.Control.prototype.activate.apply(this, arguments));
@@ -245,11 +252,12 @@
* feature - {<OpenLayers.Feature.Vector>} The selected feature.
*/
selectFeature: function(feature) {
- OpenLayers.Console.log("ModifyFeature.selectFeature("+feature+")")
+ //OpenLayers.Console.log("ModifyFeature.selectFeature("+feature+")")
this.feature = feature;
this.resetVertices();
- this.dragControl.activate();
- this.onModificationStart(this.feature);
+ // ModifyFeature.dragControl.activate() commented out because the dragControl appears to interfere with the SelectFeature control's click callback.
+ //this.dragControl.activate();
+ //this.onModificationStart(this.feature);
},
/**
@@ -266,7 +274,7 @@
this.virtualVertices = [];
this.feature = null;
this.dragControl.deactivate();
- this.onModificationEnd(feature);
+ //this.onModificationEnd(feature);
},
/**
Modified: sandbox/timandseb/wfsv/lib/OpenLayers/Control/SelectFeature.js
===================================================================
--- sandbox/timandseb/wfsv/lib/OpenLayers/Control/SelectFeature.js 2007-10-01 15:38:14 UTC (rev 4735)
+++ sandbox/timandseb/wfsv/lib/OpenLayers/Control/SelectFeature.js 2007-10-01 17:47:39 UTC (rev 4736)
@@ -88,6 +88,7 @@
over: this.overFeature,
out: this.outFeature
}, this.callbacks);
+ OpenLayers.Console.log("onClick : " + this.onClick)
var handlerOptions = {geometryTypes: this.geometryTypes};
this.handler = new OpenLayers.Handler.Feature(this, layer,
this.callbacks,
@@ -103,7 +104,9 @@
*/
clickFeature: function(feature) {
OpenLayers.Console.log("SelectFeature.clickFeature")
- if(this.hover) {
+ OpenLayers.Console.log(feature)
+ this.onClick(feature);
+ /*if(this.hover) {
return;
}
if (this.multiple) {
@@ -123,7 +126,7 @@
}
this.select(feature);
}
- }
+ }*/
},
/**
@@ -167,7 +170,7 @@
* feature - {<OpenLayers.Feature.Vector>}
*/
select: function(feature) {
- OpenLayers.Console.log("SelectFeature.select(feature)")
+ //OpenLayers.Console.log("SelectFeature.select(feature)")
// Store feature style for restoration later
if(feature.originalStyle == null) {
feature.originalStyle = feature.style;
More information about the Commits
mailing list