在VB.Net中解析GML的最佳方法是什么

在VB.Net中解析GML的最佳方法是什么,vb.net,gml-geographic-markup-lan,Vb.net,Gml Geographic Markup Lan,我正在寻找解析GML以返回空间数据的最佳方法。例如,这里有一个GML文件: <?xml version="1.0" encoding="utf-8"?> <gml:FeatureCollection xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instanc

我正在寻找解析GML以返回空间数据的最佳方法。例如,这里有一个GML文件:

<?xml version="1.0" encoding="utf-8"?>
<gml:FeatureCollection xmlns:gml="http://www.opengis.net/gml"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:onecallgml="http://www.pelicancorp.com/onecallgml"
    xsi:schemaLocation="http://www.pelicancorp.com/onecallgml http://www.pelicancorp.com/digsafe/onecallgml.xsd">
<gml:featureMember>
    <onecallgml:OneCallReferral gml:id="digsite">
    <onecallgml:LocationDetails>    
    <gml:surfaceProperty>
    <gml:Polygon srsName="EPSG:2193">
    <gml:exterior>
    <gml:LinearRing>
    <gml:posList>
        1563229.00057526 5179234.72234694 1563576.83066077 5179352.36361939 1563694.22647617 5179123.23451613 1563294.42782719 5179000.13697214 1563229.00057526 5179234.72234694
    </gml:posList>
    </gml:LinearRing>
    </gml:exterior>
    </gml:Polygon>
    </gml:surfaceProperty>
    </onecallgml:LocationDetails>
    </onecallgml:OneCallReferral>
</gml:featureMember>
</gml:FeatureCollection>

1563229.00057526 5179234.72234694 1563576.83066077 5179352.36361939 1563694.22647617 5179123.23451613 1563294.42782719 5179000.13697214 1563229.00057526 5179234.72234694

如何遍历每个featureMember,然后遍历其多边形,然后将posList坐标放入数组?

在VB.NET中处理XML时,我建议使用。您可能希望提取更多信息(例如,与featureMember关联的内容),但一个简单的示例可能是:

' You will need to import the XML namespace
Imports <xmlns:gml = "http://www.opengis.net/gml">
...
Dim xml As XElement = XElement.Parse(myGmlString) ' or some other method
Dim polys = (
    From fm In xml...<gml:featureMember>
    From poly In fm...<gml:Polygon>
    Select New With {
        .Name = poly.@srsName,
        .Coords = (poly...<gml:posList>.Value.Trim() _
            .Split({" "}, StringSplitOptions.RemoveEmptyEntries) _
            .Select(Function(x) CDbl(x))).ToArray()
    }
).ToList()
”您需要导入XML命名空间
进口
...
将xml标注为XElement=XElement.Parse(myGmlString)或其他方法
模糊多边形=(
从xml格式的fm。。。
从保利在调频。。。
选择“新建”{
.Name=poly@srsName,
.Coords=(poly…Value.Trim()_
.Split({“”},StringSplitOptions.RemoveEmptyEntries)_
.选择(函数(x)CDbl(x))).ToArray()
}
)托利斯先生()

这将为您提供一个匿名类型列表,其中多边形名称和坐标为Double数组。

Hi。展示你迄今为止所做的尝试?