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 <http://www.openplans.org/topp>"
xmlns:ogc="http://www.opengis.net/ogc <http://www.opengis.net/ogc>"
xmlns:wfs="http://www.opengis.net/wfs <http://www.opengis.net/wfs>">
<wfs:Update typeName=....*

to see if there's something strange there...


Vikram <[email protected]> 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 <[email protected]> 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 <[email protected]>
>> 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 <[email protected]> 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-6fb6a820ac58
>>>>
>>>> see 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 <[email protected]> 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 <[email protected]> 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.
>>>>>>
>>>>>> Check this
>>>>>>
>>>>>> https://gis.stackexchange.com/questions/46730/openlayers-cloned-features-get-style-from-original-feature
>>>>>>
>>>>>> 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 <[email protected]> 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 writeTransaction method 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', {
>>>>>>>         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
>>>>>>>
>>>>>>>
>>>>>>> [email protected]
>>>>>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> www.vfonsecaz.pt
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> <div dir="lt
>>>>>
>>>>>
>
> --
>
> www.vfonsecaz.pt
>
>

-- 

www.vfonsecaz.pt
_______________________________________________
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


[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to