I am configuring a database (Postgis on windows) to store GPS
coordinates.
I want to update the geometry for the points in real time (well at least
as
close to as possible). I am trying to figure out the XML necessary to
perform such an operation through WFS. I have come up with two possible
approaches:
1. Use Update statement with geometry column. Does this work?. If so, I
don't know how to write such an expression, if anyone can help me out
here
it would be great.
Yeah, this should work, and I think is probably the preferred way, if you
are just wanting to update the geometry for the points, a delete and
insert will work, but changes the featureid of the point (which you may
not need), but also just takes longer...
I do believe the order should be correct though.
All that you do to get it to work is put the gml for the point in the
update field:
<wfs:Transaction service="WFS" version="1.0.0"
xmlns:topp="http://www.openplans.org/topp"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml"
xmlns:wfs="http://www.opengis.net/wfs">
<wfs:Update typeName="topp:obs">
<wfs:Property>
<wfs:Name>topp:location</wfs:Name>
<wfs:Value>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#0">
<gml:coordinates decimal="." cs="," ts="
">430000,4650000</gml:coordinates>
</gml:Point>
</wfs:Value>
</wfs:Property>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>topp:objectid</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
I'll put this in the demo section of the next release, since the update
example is just for a non-geometry field.
2. Use Delete and Insert statements within a Transaction. I have tried
the
following:
<wfs:Transaction service="WFS" handle="Transaction 01" version="1.0.0"
xmlns:cdf="http://www.opengis.net/cite/data"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:wfs="http://www.opengis.net/wfs">
<wfs:Delete typeName="topp:posiciones">
.....
</wfs:Insert>
</wfs:Transaction>
If I do Delete and Insert in separate transactions they work but I want
both commands to be in one transaction to ensure data integrity.
But I get the following error:
> <ServiceException
locator="org.vfny.geoserver.requests.readers.DispatcherXmlReader">
> XML get capabilities request parsing error:
org.xml.sax.SAXParseException: The prefix "topp" for element
"topp:posiciones" is not bound. </ServiceException>
</ServiceExceptionReport>
What am I doing wrong?.
Ah, I'm actually sort of the cause for that problem. What you need to do
is include xmlns:topp="http://www.openplans.org/topp"
in the header:
<wfs:Transaction service="WFS" handle="Transaction 01" version="1.0.0"
xmlns:cdf="http://www.opengis.net/cite/data"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:topp="http://www.openplans.org/topp">
I should have put the topp namespace in the delete for the demo section,
it should be there, but GeoServer doesn't require it for a delete, but it
does for an update. So if you have that in there then all should be fine.
It's just that xml parser is trying to look up what the namespace the topp
prefix corresponds to, but it was not declared.
As for Saul's question about what GeoServer enforces, it uses sAX xml
parsing, so it enforces any use of xml prefixes, as
the parser won't be able to look up the declarations. But updates and
deletes don't actually use the prefix in the xml,
it is within the element (<wfs:Name>topp:location</wfs:Name>), and in that
case GeoServer does not validate it.
best regards,
Chris
--