I changed the featureNS to a URI, still the same result. featureType should be “streets_freiburg”. I have checked this before.
The description says that the update element describes an operation that can be applied to a set of features, but in my case, I have multiple update elements. Maybe that is the problem… just a guess

···
On 22/01/2020 15:51, Vitor Fonseca wrote:
as per WFS 1.1.0 specification
so i think you problem is similar to this
you should check formatGML. featureType should be FR_TEST:streets_freiburg" and featureNS a URI (Namespace URI)
Vitor Fonseca <vfonsecaz@…84…> escreveu no dia quarta, 22/01/2020 à(s) 14:32:
so each update block has a different and valid fid?
This bit xmlns:feature=“FR_TEST” looks strange. What’s FR_TEST?
The wfs update examples I came across with only state the typeName property.How did you create formatGML?
Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 14:20:
Yes, I deleted an update block because it was too long to be included in this email haha. There were two features.
2 update blocks basically.
The second one starts like :
the_geom 7.8322757 47.9760968 7.8321782 47.9759269 7.8320462 47.9756999 7.8319787 47.9756003 7.831903 47.9755152 7.83138 47.9749857 7.8311329 47.9747349 Street_Id 2399319 Src_Str_id 0 .........I can’t use
node = formatWFS.writeTransaction(null, **[f]**, null, formatGML);because I am sending in an array of features already.
On 22/01/2020 15:21, Vitor Fonseca wrote:
Is that the complete request?
There’s only one feature there (
what if you replace this
node = formatWFS.writeTransaction(null, f, null, formatGML);with
node = formatWFS.writeTransaction(null, **[f]**, null, formatGML);Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 14:10:
Yes. It looks like this :
<?xml version="1.0" encoding="UTF-8"?><Transaction xmlns=“http://www.opengis.net/wfs” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” service=“WFS” version=“1.1.0” xsi:schemaLocation=“http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd”>
the_geom
<MultiLineString xmlns=“http://www.opengis.net/gml” srsName=“CRS:84”>
7.8311329 47.9747349 7.8310331 47.9746403
Street_Id
2414838
Src_Str_id
0
Full_Name
Schlierbergstraße
Class
6
One_way
Extra_Pass
0
Length
12.878
Speed
30
DrivingTim
0.0257
Serv_Area
From_Z
0
To_Z
0
Width
0
Veh_Size
LPriority
0
RPriority
0
ZipL
ZipR
LComment
RComment
LServeTime
0
RServeTime
0
BServeTime
0
LQuantity
0
RQuantity
0
BQuantity
0
LCusts
0
RCusts
0
BCusts
0
LUnits
0
RUnits
0
BUnits
0
LRevenue
0
RRevenue
0
BRevenue
0
LRoute
0
RRoute
0
BRoute
0
LRouteFile
RRouteFile
LCycle
0
RCycle
0
CycleLegnd
0
LFacil
0
RFacil
0
LFacilCost
0
RFacilCost
0
LSP
0
RSP
0
X_LRoute
0
X_RRoute
0
NetErr
NetErr_Ok
NetErr_Id
0
Up_Date
0
SameSelect
1
Serv_Mode
WalkingTim
0
ARA_BU_L
0
ARA_BU_R
0
Prefix
Name
Type
Suffix
L_F_Add
L_T_Add
R_F_Add
R_T_Add
RndAb
0
Exclude
0
OSM_ID
198512516
OSM_NameL
Schlierbergstraße
OSM_NameI
OSM_RdRef
OSM_Meta
lcn=yes, lit=yes, name=Schlierbergstraße, FIXME=recheck position and access, layer=1, bridge=yes, highway=residential, surface=asphalt, maxspeed=30, maxweight=3.5, motor_vehicle:back
Meters
12.878
Feet
42.25
OSM_KMH
30
OSM_MPH
18.641
OSM_Lanes
0
Po_Class
41
Po_Flags
3
PoEdge_id
315286
PoEId_Src
209581
PoEId_Trg
244684
Po_Car
1
Po_Bike
1
Po_Foot
0
Po_Area
0
<Filter xmlns=“http://www.opengis.net/ogc”>
On 22/01/2020 15:04, Vitor Fonseca wrote:
well i suggest you check the payload on the wfs request (using developer tools)
should be something like<wfs:Transaction service=“WFS” version=“1.0.0”
xmlns:topp=“http://www.openplans.org/topp”
xmlns:ogc=“http://www.opengis.net/ogc”
xmlns:wfs=“http://www.opengis.net/wfs”>
<wfs:Update typeName=…to see if there’s something strange there…
Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 13:55:
Yes. Like the example. I have already tried that.
On 22/01/2020 14:58, Vitor Fonseca wrote:
Ok got it.
have you tried creating the clone with var clone = new ol.Feature(featureProperties); instead of the clone function?
Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 13:01:
It is basically creating a copy of the feature which looks exactly the same except for the boundedBy property. So the geoserver identifies the feature you want to update using the id.
On 22/01/2020 13:59, Vitor Fonseca wrote:
Yes. But cloning creates new features right?
You are trying to update features that did not exist in the first place, and that GeoServer is not aware…i’m a bit confused now
A quarta, 22/01/2020, 12:53, Vikram <vikram.eswar@…10264…> escreveu:
No I am trying to update features. If you look at the example that you shared, one has to create a clone in order to strip the boundedBy property from the feature.
On 22/01/2020 13:28, Vitor Fonseca wrote:
Wait a minute. Shouldn’t you be making insert’s instead of update’s?
You are creating new features after all…Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 12:14:
Yes I have seen this example. Gives me the same result.
Now, I don’t get the assertion error anymore, I create the feature with WKT. But the end result is the same. I think the geoserver is not updating the features separately ie. it reads the features one by one, but stores the properties in the same variable, thus overwriting the properties every time. And then it updates all the features with this set of properties, thus making them all look alike.
have you also tried calling writeTransaction within a loop for updating one feature at a time?
I just tried this. It doesn’t produce the problem, I can see that it is called multiple times through the loop, but in the end, only one feature is updated…
On 22/01/2020 12:53, Vitor Fonseca wrote:
The browser console should give you a little bit more detail on the error…(expand all the error lines…)what’s the OL version?
check this example:
https://medium.com/@goldrydigital/wfs-t-with-openlayers-3-16-6fb6a820ac58see the new feature created with…
var clone = new ol.Feature(featureProperties);
have you also tried calling writeTransaction within a loop for updating one feature at a time?
Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 11:40:
It says assertion failed at this line of code :
node = formatWFS.writeTransaction(null, f, null, formatGML);
Well I am not able to see where the fid is… I can only see id_ and ol_uid on the console. They are different for every clone.
On 22/01/2020 12:33, Vitor Fonseca wrote:
I have struggle in the past with the clone feature too.
You have different id’s in the clones or differente fid’s?
Because you’re setting “clone.setId(feature.getId());” and that’s not the “internal” feature ID.BTW what exactly is the assertion error?
Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 11:24:
Hi Vitor,
Thanks for your reply.
The clone approach works fine for one feature ie. when I try to update one feature. I have checked the console and the clones have different IDs.
I tried creating feature with WKT, but got an assertion error while passing the created feature to the writeTransaction method…
Regards,
Vikram
On 22/01/2020 11:58, Vitor Fonseca wrote:
Hi,
I think this is a programming problem rather than a Geoserver problem.
From my experience the issue should be with the clone functionality.Someone mentions "I have noticed that cloned features share the same featureID as the original. " and this should be the problem when sending the features over to WFS-T…
You could try creating new features some other way (wkt…)Vikram <vikram.eswar@…10264…> escreveu no dia quarta, 22/01/2020 à(s) 10:24:
HI all,
I am trying to update features using WFS-T update. I am sending the request from my website (OpenLayers) by passing an array of features.
However, I have noticed that the attributes and geometry of last feature in the array is copied to all other features.
For example, if I pass 5 features to the
writeTransactionmethod to update an attribute of all 5 features, it copies the attributes and geometry of the 5th feature to the other features.var clones = [] selectedFeatures.forEach(function (feature) { var featureProperties = feature.getProperties(); delete featureProperties.boundedBy; var clone = feature.clone(); clone.setId(feature.getId()); clone.setGeometryName('the_geom'); clone.setProperties({'xyz':'xyz'}) clones.push(clone) }) console.log(clones) transactWFS('update_batch', clones);int the transactWFS method,
transactWFS = function (mode, f) { var node; switch (mode) { case 'insert': node = formatWFS.writeTransaction([f], null, null, formatGML); break; case 'update': node = formatWFS.writeTransaction(null, [f], null, formatGML); break; case 'update_batch': node = formatWFS.writeTransaction(null, f, null, formatGML); break; case 'delete': node = formatWFS.writeTransaction(null, null, [f], formatGML); break; } var payload = xs.serializeToString(node); $.ajax('[http://localhost:8080/geoserver/TEST/ows](http://localhost:8080/geoserver/TEST/ows)', { service: 'WFS', type: 'POST', dataType: 'xml', processData: false, contentType: 'text/xml', data: payload, success: function(data) { }, error: function(e) { var errorMsg = e? (e.status + ' ' + e.statusText) : ""; alert('Error saving this feature to GeoServer.<br><br>' + errorMsg); } }).done(function() { wfsSource.refresh() }); };Does anyone have a solution?
Regards,
Vikram
Geoserver-users mailing list
Please make sure you read the following two resources before posting to this list:
- Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html
If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users–
–
–
–
–
–
