通过JS前端调用Geoserver的wfs接口新增修改删除空间表feature
借助github的js插件 geojson-to-wfs-t-2
安装方式 npm install geojson-to-wfs-t-2
使用方式
import wfs from 'geojson-to-wfs-t-2';
const nullIsland = {
type: 'Feature',
properties: {place_name: 'null island'},
geometry: {
type: 'Point',
coordinates: [0, 0]
}
id: 'feature_id'
}
const params = {geometry_name: 'geom', layer: 'my_lyr', ns: 'my_namespace'};
// create a stringified transaction inserting null island
wfs.Transaction(
wfs.Insert(nullIsland, params),
{
nsAssignments: {
my_namespace: 'https://example.com/namespace_defn.xsd'
}
}
);
// create a stringified transaction updating null island's name
wfs.Transaction(
wfs.Update({properties: {place_name: 'not Atlantis'}, id: nullIsland.id }),
{nsAssignments: ...}
)
// same deal, but deleting it
wfs.Transaction(
wfs.Delete({id: nullIsland.id}, params),
{nsAssignments: ...}
)
一.wfs-t删除功能
通过wfs-t插件 将json 转成xml
![](https://liubf.com/wp-content/uploads/2024/06/image-1.png)
![](https://liubf.com/wp-content/uploads/2024/06/image-18.png)
转换的xml如下
<wfs:Transaction
xmlns:fes=”http://www.opengis.net/fes/2.0″
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:gml=”http://www.opengis.net/gml/3.2″
xmlns:wfs=”http://www.opengis.net/wfs/2.0″ xsi:schemaLocation=”http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0/wfs.xsd” service=”WFS” version=”2.0.0″>
<wfs:Delete typeName=”gtp”>
<fes:Filter>
<fes:ResourceId rid=”gtp.72″/>
</fes:Filter>
</wfs:Delete>
</wfs:Transaction>
使用ajax、fetch、axios、postman请求接口
记得加入鉴权
![](https://liubf.com/wp-content/uploads/2024/06/image-2-1024x262.png)
将转换的xml代入参数 调接口成功
![](https://liubf.com/wp-content/uploads/2024/06/image-3-1024x567.png)
可以数据库中看到数据已被成功删除
![](https://liubf.com/wp-content/uploads/2024/06/BS3X4VBSB29BG9M6-1024x362.png)
![](https://liubf.com/wp-content/uploads/2024/06/image-5-1024x325.png)
二.wfs-t修改功能 (测试不可修改坐标,仅可修改属性,可批量修改)
![](https://liubf.com/wp-content/uploads/2024/06/image-8.png)
转换的xml如下
<wfs:Transaction
xmlns:fes=”http://www.opengis.net/fes/2.0″
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:gml=”http://www.opengis.net/gml/3.2″
xmlns:wfs=”http://www.opengis.net/wfs/2.0″ xsi:schemaLocation=”http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0/wfs.xsd” service=”WFS” version=”2.0.0″>
<wfs:Update typeName=”gtp”>
<wfs:Property>
<wfs:ValueReference>offset_x</wfs:ValueReference>
<wfs:Value>111</wfs:Value>
</wfs:Property>
<wfs:Property>
<wfs:ValueReference>gtp_id</wfs:ValueReference>
<wfs:Value>dddd</wfs:Value>
</wfs:Property>
<fes:Filter>
<fes:ResourceId rid=”gtp.67″/>
</fes:Filter>
</wfs:Update>
</wfs:Transaction>
xml 放入参数 请求接口
![](https://liubf.com/wp-content/uploads/2024/06/image-9-1024x611.png)
![](https://liubf.com/wp-content/uploads/2024/06/image-10-1024x390.png)
三.wfs-t新增功能
![](https://liubf.com/wp-content/uploads/2024/06/image-13.png)
转换的xml如下
<wfs:Transaction
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:gml=”http://www.opengis.net/gml/3.2″
xmlns:wfs=”http://www.opengis.net/wfs/2.0″ xsi:schemaLocation=”http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0/wfs.xsd” service=”WFS” version=”2.0.0″>
<wfs:Insert>
<gtp gml:id=”gtp.”>
<geom>
<gml:Point>
<gml:pos>100 20 30</gml:pos>
</gml:Point>
</geom>
<offset_x>222</offset_x>
<gtp_id>3333xxx</gtp_id>
</gtp>
</wfs:Insert>
</wfs:Transaction>
![](https://liubf.com/wp-content/uploads/2024/06/image-12-1024x708.png)
![](https://liubf.com/wp-content/uploads/2024/06/image-14-1024x408.png)
四.wfs-t替换功能 (修改单个点属性和坐标)
![](https://liubf.com/wp-content/uploads/2024/06/image-15.png)
转换的xml如下
<wfs:Transaction
xmlns:fes=”http://www.opengis.net/fes/2.0″
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:gml=”http://www.opengis.net/gml/3.2″
xmlns:wfs=”http://www.opengis.net/wfs/2.0″ xsi:schemaLocation=”http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0/wfs.xsd” service=”WFS” version=”2.0.0″>
<wfs:Replace>
<gtp gml:id=”gtp.67″>
<geom>
<gml:Point>
<gml:pos>120 40 60</gml:pos>
</gml:Point>
</geom>
<offset_x>1114551</offset_x>
<project_id>665541</project_id>
<gtp_id>iamxiyou</gtp_id>
</gtp>
<fes:Filter>
<fes:ResourceId rid=”gtp.67″/>
</fes:Filter>
</wfs:Replace>
</wfs:Transaction>
![](https://liubf.com/wp-content/uploads/2024/06/image-16-1024x692.png)
![](https://liubf.com/wp-content/uploads/2024/06/image-17-1024x360.png)
You have mentioned very interesting points! ps nice web site.Raise your business
noKxqDWZ
Hey people!!!!!
Good mood and good luck to everyone!!!!!
ahWToKzsVxnjY
NzepSuMBs
MKIbXYJifrDn
RntfeJkmrlGQz
nPajdhAHzqpY
cPmJFvRQUYTqS
Для заказа прогона Хрумером, вам необходимо обратиться к специализированным компаниям или Вы можете заказать у нас по наращиванию линк билдинг
так же мы предоставляем услуги по сео продвижению с помощью гса прогонов через тир и поможем если будет нужно оптимизировать ваш проект
для быстрой связи через телеграмм логин @pokras7777 либо добавится в нащу группу в телеграмм https://t.me/bazixrumer либо через скайп логин pokras7777
мы будем рады вам помочь в любых вопросах по наращиванию трафика на вашем проекте время работы 24/7 без выходных!
seo аудит сайта заказать seo аудит сайта заказать .
ZFHhqWsLuDPYr
ouIsMOAbWfTxGK
UiocBPYMLEkxmZha
icAkCyhW
Your blog is a treasure trove of valuable insights and thought-provoking commentary. Your dedication to your craft is evident in every word you write. Keep up the fantastic work!
Mysimba – Quick and Easy Weight Lass
Mysimba is a medicine used along with diet and exercise to help manage weight in adults:
who are obese (have a body-mass index – BMI – of 30 or more);
who are overweight (have a BMI between 27 and 30) and have weight-related complications such as diabetes, abnormally high levels of fat in the blood, or high blood pressure.
BMI is a measurement that indicates body weight relative to height.
Mysimba contains the active substances naltrexone and bupropion.
https://cutt.ly/RezL73vz
WwGeXUZvQFTa