实施Leaflet draw时我做错了什么.在此特定示例中如何使用WFST? [英] what have I done wrong when implementing Leaflet draw. How to use WFST in this specific example?
问题描述
我是这个地理信息开发领域的新手.我正在遵循以下管道架构流程来解决基于GIS的应用程序问题.
I am new to this domain of GeoInformation development. I am following the below pipeline architecture flow to achieve a GIS-based application problem.
PostGIS-GeoServer-传单
PostGIS - GeoServer - Leaflet
我已经设置了我的传单客户端应用程序,该应用程序将图块组成了地图.我还使用了一些传单插件(例如Draw,zoom),以便为用户提供在地图上标记和绘制的选项.
I have set up my leaflet client application which composes tiles to a map. I am also using some leaflet plugins (like Draw, zoom) in order to give users the option to mark and to draw on the map.
我能够绘制并获取绘制的多边形的GeoJSON功能,如下所示:
I am able to draw and get the GeoJSON features of the drawn polygon as shown below:
在这部分工作之后,我陷入了困境,需要确定如何发送绘制的多边形请求并以编程方式检索多边形(已保存).我知道答案是WFS-T,但是如何在原始代码中使用它.这是原始代码示例:
I am stuck after this part of figuring how do I need to send the polygon request drawn and retrieve the polygon (which is saved) programmatically. I know the answer is WFS-T, but how do I use this in my raw code. Here is the raw code example:
原始代码链接: https://pastebin.com/wCAHxVc0 跟随链接代码>
参考:
https://github.com/Flexberry/Leaflet-WFST
推荐答案
了解WFS-T的最佳方法是使用GeoServer Demo选项(链接:
The best way to understand WFS-T is using GeoServer Demo option (Link: http://localhost:8080/geoserver/web/wicket/bookmarkable/org.geoserver.web.demo.DemoRequestsPage?5). The main problem for me was to figure out how do I insert and update transaction details. Exploring GeoServer Demo gave me the solution to it.
这是一个示例示例:
var postdata = "<wfs:Transaction service="WFS" version="1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd http://www.openplans.org/topp http://localhost:8080/geoserver/wfs/DescribeFeatureType?typename=topp:tasmania_roads"> <wfs:Insert>
<topp:tasmania_roads>
<topp:the_geom>
<gml:MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:lineStringMember>
<gml:LineString>
<gml:coordinates decimal="." cs="," ts=" ">
494475.71056415,5433016.8189323 494982.70115662,5435041.95096618
</gml:coordinates>
</gml:LineString>
</gml:lineStringMember>
</gml:MultiLineString>
</topp:the_geom>
<topp:TYPE>alley</topp:TYPE>
</topp:tasmania_roads> </wfs:Insert> </wfs:Transaction>"
此XML请求以后可以用于通过AJAX调用发送到GeoServer进行操作,如下所示:
This XML request can later be used to send to GeoServer for manipulation using AJAX call as shown below:
$.ajax({
type: "POST",
url: gs.wfs,
dataType: "xml",
contentType: "text/xml",
data: postdata,
//TODO: Error handling
success: function(xml) {
//TODO: User feedback
console.log("Successfully inserted");
}
});
为更好地理解WFS-T的应用场景,请尝试遵循以下URL: https://georepublic.info/en/blog/2012/leaflet-example-with-wfs-t/.这应该可以帮助您开始使用WFS-T.快乐的地图)
For better understanding with an application scenario of WFS-T, try following this URL: https://georepublic.info/en/blog/2012/leaflet-example-with-wfs-t/. This should help you get started with WFS-T. Happy map editing :)
这篇关于实施Leaflet draw时我做错了什么.在此特定示例中如何使用WFST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!