您的位置:首页 > 其它

地理空间数据格式——OGC-GML

2016-11-10 19:07 756 查看
GML-地理标记语言

1. 概述

GML(OpenGIS® Geography Markup Language Encoding Standard)当前版本是3.2.1。它是一种基于XML的地理要素描述语言标准,用以在不同的软件或系统间交换空间数据,比如后面会介绍的WFS标准就使用GML作为输入和输出格式。GML同时也是ISO标准。

2. GML Schema

GML标准其实就是通过XML Schema(XSD)来定义了GML文档的结构,这些定义都可以访问在线为:http://schemas.opengis.net/gml/ 得到。目前3.2.1版本的GML中包含7个顶级XSD(其中一个是废弃类型,为了向前兼容),这些XSD下还有其它子XSD,它们组合成为如图
10的结构。



3. GML示例

下面是一个包含点、线、面数据的GML的简单的例子,通过这个例子可以看到GML的组织情况:
<pre name="code" class="javascript"><?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:fme="http://www.safe.com/gml/fme"
xsi:schemaLocation="http://www.safe.com/gml/fme MyGML.xsd">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:4326" srsDimension="2">
<gml:lowerCorner>-0.012611143330844 -0.050087654172727</gml:lowerCorner>
<gml:upperCorner>0.051158411625351 0.019154661096934</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<fme:point gml:id="id9e2fb700-bbdb-48a5-8d99-f68b89886f4a">
<fme:Id>0</fme:Id>
<gml:pointProperty>
<gml:Point srsName="EPSG:4326" srsDimension="2">
<gml:pos>0.027363801567048 -0.028672505120255</gml:pos>
</gml:Point>
</gml:pointProperty>
</fme:point>
</gml:featureMember>
<gml:featureMember>
<fme:line gml:id="id4e0efc7b-d652-4d3c-8466-1a2419bca6d2">
<fme:Id>0</fme:Id>
<gml:curveProperty>
<gml:LineString srsName="EPSG:4326" srsDimension="2">
<gml:posList>0.051158411625351 0.019154661096934 0.039736998797366 -0.050087654172727</gml:posList>
</gml:LineString>
</gml:curveProperty>
</fme:line>
</gml:featureMember>
<gml:featureMember>
<fme:polygon gml:id="idf9b78df6-c402-4bc9-afd4-22762401c565">
<fme:Name>0</fme:Name>
<gml:surfaceProperty>
<gml:Surface srsName="EPSG:4326" srsDimension="2">
<gml:patches>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing>
<gml:posList>0.016656227040926 -0.024151529209121 0.003569191508859 0.005829679464227
-0.012611143330844 -0.01177833197886 -0.004283029810438 -0.042473378954071 0.018321849744836
-0.049373815870979 0.016656227040926 -0.024151529209121</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
</gml:patches>
</gml:Surface>
</gml:surfaceProperty>
</fme:polygon>
</gml:featureMember>
</gml:FeatureCollection>



在这个例子中描述了一个GML的FeatureCollection,由于这是由FME导出的数据,因此其中还包含“fme”的命名空间 “fme:point” 、“fme:line”、 “fme: polygon”类型, 这些类型在这个XML包含的XSD中进行了描述,实际对应的类型为基于GML标准的点、线、面:
<pre name="code" class="javascript"><?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:fme="http://www.safe.com/gml/fme"
targetNamespace="http://www.safe.com/gml/fme"
elementFormDefault="qualified">
<import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
<element name="point" type="fme:pointType" substitutionGroup="gml:_Feature"/>
<complexType name="pointType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element name="Id" minOccurs="0" type="integer"/>
<element ref="gml:pointProperty" minOccurs="0"/>
<element ref="gml:multiPointProperty" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element name="line" type="fme:lineType" substitutionGroup="gml:_Feature"/>
<complexType name="lineType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element name="Id" minOccurs="0" type="integer"/>
<element ref="gml:curveProperty" minOccurs="0"/>
<element ref="gml:multiCurveProperty" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element name="polygon" type="fme:polygonType" substitutionGroup="gml:_Feature"/>
<complexType name="polygonType">
<complexContent>
<extension base="gml:AbstractFeatureType">
<sequence>
<element name="Name" minOccurs="0">
<simpleType>
<restriction base="string">
<maxLength value="30"/>
</restriction>
</simpleType>
</element>
<element ref="gml:surfaceProperty" minOccurs="0"/>
<element ref="gml:multiSurfaceProperty" minOccurs="0"/>
</sequence>
</extension>
</complexContent>
</complexType>
</schema>




而描述数据范围的“gml:boundedBy”属性则直接由“gml:Envelope”类型的对象来描述;另外,数据的坐标节点、空间参考等属性则直接由GML的类型进行描述。更简单一点,如果我们需要自己写一个GML来描述一个地理数据,写出来的文件内容可能是这样的:

<pre name="code" class="javascript"><City><!--描述某城市的数据-->
<gml:boundedBy>
<gml:Envelope>
<gml:pos>100 200</gml:pos>
<gml:pos>230 250</gml:pos>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<Bridge gml:id="bridge 1"><!--某桥对象-->
<span>100</span><!--属性信息:该桥的跨度-->
<height>200</height><!--属性信息:该桥的高度-->
<gml:curveProperty><!--几何信息-->
<gml:LineString gml:id="line 24">
<gml:pos>100 200</gml:pos>
<gml:pos>200 200</gml:pos>
</gml:LineString>
</gml:curveProperty>
</Bridge>
</gml:featureMember>
</City>


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  OGC GML 地理标记语言