Polygon
Polygon Schema
Exterior/Interior schema
LinearRing
Polygons are the most complex of the basic geometries. They have an internal structure that looks quite complex on first sigh,t but it is really quite simple if you study it carefully. As was mentioned before, a polygon is a closed area which is bounded by a ring. This is described in the element of the polygon which contains a which lists the actual points that form the ring of the polygon using a list of pos or coordinate elements. Since a polygon can also contain "holes" (or in GML terms interior rings), the polygon can also have 0 or more elements. Technically, you can have a polygon with no exterior ring, but I cannot actually think of a use for this.
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:coordinates>.... </gml:coordinates>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing>
<gml:coordinates>.... </gml:coordinates>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>
<complexType name="PolygonType">
<annotation>
<documentation>
A Polygon is a special surface that is defined by a single
surface patch. The boundary of this patch is coplanar and
the polygon uses planar interpolation in its interior. It is
backwards compatible with the Polygon of GML 2,
GM_Polygon of ISO 19107 is implemented by PolygonPatch.
</documentation>
</annotation>
<complexContent>
<extension base="gml:AbstractSurfaceType">
<sequence>
<element ref="gml:exterior" minOccurs="0"/>
<element ref="gml:interior" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>
The only difference between the interior and exterior schemas is the name of the element. So I have only included the exterior one here. They form a place holder for the linear ring elements which are the same in each case but by using two schemas, a parser can tell the two rings inside the polygon apart.
<element name="exterior" type="gml:AbstractRingPropertyType">
<annotation>
<documentation>
A boundary of a surface consists of a number of rings.
In the normal 2D case, one of these rings is distinguished
as being the exterior boundary. In a general manifold this
is not always possible, in which case all boundaries shall be
listed as interior boundaries, and the exterior will be empty.
</documentation>
</annotation>
</element>
The element which actually holds the coordinates, there must be at least 4 points to make a ring and the first and last point must be the same.
<complexType name="LinearRingType">
<annotation>
<documentation>
A LinearRing is defined by four or more coordinate tuples,
with linear interpolation between them; the first and last
coordinates must be coincident.
</documentation>
</annotation>
<complexContent>
<extension base="gml:AbstractRingType">
<sequence>
<choice>
<choice minOccurs="4" maxOccurs="unbounded">
<element ref="gml:pos"/>
<element ref="gml:pointRep"/>
</choice>
<element ref="gml:coordinates"/>
</choice>
</sequence>
</extension>
</complexContent>
</complexType>