Skip to content

Commit 4587435

Browse files
committed
Create 2025-04-07-wfs-transaction.md
From #249
1 parent 9a71b42 commit 4587435

File tree

1 file changed

+60
-52
lines changed

1 file changed

+60
-52
lines changed

_posts/2025-03-18-geospatial-techno.md renamed to _posts/2025-04-07-wfs-transaction.md

+60-52
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
author: Milad Rafiei
33
layout: post
44
title: Mastering WFS Transactions in GeoServer
5-
date: 2025-03-18
5+
date: 2025-04-07
66
categories:
77
- Tutorials
88
---
@@ -40,23 +40,25 @@ Here is an example of how to use the WFS insert feature in GeoServer:
4040
- Navigate to the **Demos** page, then click on the **Demo requests** link.
4141
- From the **Request** drop-down list, select **WFS_transactionInsert.xml**.
4242
- Enter the new coordinates and road's type as follows:
43-
44-
<wfs:Insert>
45-
<topp:tasmania_roads>
46-
<topp:the_geom>
47-
<gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
48-
<gml:lineStringMember>
49-
<gml:LineString>
50-
<gml:coordinates decimal="." cs="," ts=" ">
51-
145.2,-42.5 145.2,-43.3 145.8,-43.3
52-
</gml:coordinates>
53-
</gml:LineString>
54-
</gml:lineStringMember>
55-
</gml:MultiLineString>
56-
</topp:the_geom>
57-
<topp:TYPE>street</topp:TYPE>
58-
</topp:tasmania_roads>
59-
</wfs:Insert>
43+
44+
```xml
45+
<wfs:Insert>
46+
<topp:tasmania_roads>
47+
<topp:the_geom>
48+
<gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
49+
<gml:lineStringMember>
50+
<gml:LineString>
51+
<gml:coordinates decimal="." cs="," ts=" ">
52+
145.2,-42.5 145.2,-43.3 145.8,-43.3
53+
</gml:coordinates>
54+
</gml:LineString>
55+
</gml:lineStringMember>
56+
</gml:MultiLineString>
57+
</topp:the_geom>
58+
<topp:TYPE>street</topp:TYPE>
59+
</topp:tasmania_roads>
60+
</wfs:Insert>
61+
```
6062

6163
- Remember that using the WFS transaction in GeoServer requires appropriate permissions and access rights to ensure that only authorized users can modify the data. Enter the username and password to be authorized, and then press the **Submit** button.
6264
- GeoServer processes the transaction request. If successful, it adds the new feature to the road layer; if unsuccessful, a relevant error information is displayed and no changes are made to the data.
@@ -72,24 +74,26 @@ The Update feature of the WFS transaction in GeoServer enables users to modify e
7274

7375
Here are the steps to perform an update feature with WFS transaction in GeoServer:
7476
- Select **WFS_transactionUpdateGeom.xml** from the **Request** drop-down list, then edit the codes as follows:
75-
76-
<wfs:Update typeName="topp:tasmania_roads">
77-
<wfs:Property>
78-
<wfs:Name>the_geom</wfs:Name>
79-
<wfs:Value>
80-
<gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
81-
<gml:lineStringMember>
82-
<gml:LineString>
83-
<gml:coordinates>145.55,-42.7 145.04,-43.04 145.8,-43.4</gml:coordinates>
84-
</gml:LineString>
85-
</gml:lineStringMember>
86-
</gml:MultiLineString>
87-
</wfs:Value>
88-
</wfs:Property>
89-
<ogc:Filter>
90-
<ogc:FeatureId fid="tasmania_roads.15"/>
91-
</ogc:Filter>
92-
</wfs:Update>
77+
78+
```xml
79+
<wfs:Update typeName="topp:tasmania_roads">
80+
<wfs:Property>
81+
<wfs:Name>the_geom</wfs:Name>
82+
<wfs:Value>
83+
<gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
84+
<gml:lineStringMember>
85+
<gml:LineString>
86+
<gml:coordinates>145.55,-42.7 145.04,-43.04 145.8,-43.4</gml:coordinates>
87+
</gml:LineString>
88+
</gml:lineStringMember>
89+
</gml:MultiLineString>
90+
</wfs:Value>
91+
</wfs:Property>
92+
<ogc:Filter>
93+
<ogc:FeatureId fid="tasmania_roads.15"/>
94+
</ogc:Filter>
95+
</wfs:Update>
96+
```
9397

9498
- Enter the username and password to be authorized, and then press the **Submit** button.
9599
- After the GeoServer has processed the transaction request, go back to the **Layer Preview** section and open up the **OpenLayers** preview for the `tasmania_roads` layer. Your map should now look like this:
@@ -103,15 +107,17 @@ This operation allows users to selectively remove specific features from a datas
103107
This functionality gives users more control over their geospatial database, helping them manage and manipulate data efficiently. As an example, let's remove the features whose type attribute is equal to `road`. To do this, follow the steps displayed on the screen:
104108

105109
- Select **WFS_transactionDelete.xml** from the **Request** drop-down list, then edit the codes as follows:
106-
107-
<wfs:Delete typeName="topp:tasmania_roads">
108-
<ogc:Filter>
109-
<ogc:PropertyIsEqualTo>
110-
<ogc:PropertyName>topp:TYPE</ogc:PropertyName>
111-
<ogc:Literal>road</ogc:Literal>
112-
</ogc:PropertyIsEqualTo>
113-
</ogc:Filter>
114-
</wfs:Delete>
110+
111+
```xml
112+
<wfs:Delete typeName="topp:tasmania_roads">
113+
<ogc:Filter>
114+
<ogc:PropertyIsEqualTo>
115+
<ogc:PropertyName>topp:TYPE</ogc:PropertyName>
116+
<ogc:Literal>road</ogc:Literal>
117+
</ogc:PropertyIsEqualTo>
118+
</ogc:Filter>
119+
</wfs:Delete>
120+
```
115121

116122
- Enter the username and password to be authorized, and then press the **Submit** button.
117123
- After the GeoServer has processed the transaction request, preview for the `tasmania_roads` layer. As you can see, the features of type `Road` have been deleted.
@@ -121,16 +127,18 @@ This functionality gives users more control over their geospatial database, help
121127
Remember that you can define filter conditions to remove the specific features using the WFS Delete transaction. This can include feature IDs, attributes, spatial extent or other criteria.
122128

123129
- Again, select **WFS_transactionDelete.xml** from the **Request** drop-down list, then edit the codes as follows:
124-
125-
<wfs:Delete typeName="topp:tasmania_roads">
126-
<ogc:Filter>
127-
<ogc:FeatureId fid="tasmania_roads.15"/>
128-
</ogc:Filter>
129-
</wfs:Delete>
130+
131+
```xml
132+
<wfs:Delete typeName="topp:tasmania_roads">
133+
<ogc:Filter>
134+
<ogc:FeatureId fid="tasmania_roads.15"/>
135+
</ogc:Filter>
136+
</wfs:Delete>
137+
```
130138

131139
- Enter the username and password to be authorized, and then press the **Submit** button.
132140
- After the GeoServer has processed the transaction request, open the **OpenLayers** preview for the `tasmania_roads` layer from the **Layer Preview** section. As you can see, the `fid 15` has been deleted.
133141

134142
----
135143

136-
In this session, we took a brief journey to explore SLD styles and various filters in GeoServer. If you want to access the complete tutorial, click on the [link](https://www.youtube.com/watch?v=TIlo7UOAXKg&list=PL_ITaxp1Ob4sjk24Stboa5XbO0LGdEKbL).
144+
In this session, we took a brief journey to explore WFS Transaction to insert update and remove features in GeoServer. If you want to access the complete tutorial, click on the [link](https://www.youtube.com/watch?v=TIlo7UOAXKg&list=PL_ITaxp1Ob4sjk24Stboa5XbO0LGdEKbL).

0 commit comments

Comments
 (0)