OGC标准介绍 7

· GML示例

下面是一个包含点、线、面数据的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: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标准的点、线、面:

<?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来描述一个地理数据,写出来的文件内容可能是这样的:

<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>