<?xml version="1.0" encoding="UTF-8"?>
<schema
    targetNamespace="http://xml.fmi.fi/namespace/meteorology/conceptual-model/meteorological-objects/2009/11/09"
    xmlns:metobj="http://xml.fmi.fi/namespace/meteorology/conceptual-model/meteorological-objects/2009/11/09"
    xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:html="http://www.w3.org/1999/xhtml"
    xmlns:sch="http://www.ascc.net/xml/schematron" xsi:schemaLocation="http://www.ascc.net/xml/schematron
    http://www.ascc.net/xml/schematron/schematron1-5.xsd" elementFormDefault="qualified" version="1.0">

    <annotation>
        <appinfo>
            <sch:title>Schematron validation</sch:title>
            <sch:ns prefix="gml" uri="http://www.opengis.net/gml" />
            <sch:ns prefix="xlink" uri="http://www.w3.org/1999/xlink" />
            <sch:pattern name="Check either href or content not both">
                <sch:rule abstract="true" id="hrefOrContent">
                    <sch:report test="@xlink:href and (*|text())"
                        >Property element may not carry both a reference to an object and contain an object.</sch:report>
                    <sch:assert test="@xlink:href | (*|text())"
                        >Property element must either carry a reference to an object or contain an object.</sch:assert>
                </sch:rule>
            </sch:pattern>
        </appinfo>
        <documentation>
            <html:div xmlns="http://www.w3.org/1999/xhtml">
                <p>Surface type Conceptual Model objects
                    (a.k.a Meteorological Objects) used at Finnish Meteorological Institute as GML 3.1.1
                    Features.</p>
                
                <p>For detailed info see <a href="http://xml.fmi.fi/namespace/meteorology/conceptual-model/meteorological-objects/2009/11/09">documentation</a></p>
                
                <p>Author: Ilkka Rinne / FMI 2009.</p>
            </html:div>
        </documentation>
    </annotation>

    <import namespace="http://www.opengis.net/gml" schemaLocation="gml311-part.xsd" />

    <include schemaLocation="metobjects-base.xsd" />

    <!-- ========================================================================================== -->
    <element name="SurfacePrecipitationArea" type="metobj:SurfacePrecipitationAreaType"
        substitutionGroup="metobj:AbstractSurfaceObject" />
    <!-- ========================================================================================== -->
    <complexType name="SurfacePrecipitationAreaType">
        <annotation>
            <documentation>
                <html:div xmlns="http://www.w3.org/1999/xhtml">
                    <p>Area of precipitation to be observed on the ground.
                        Area is modelled as continuous patch of abstract earth surface (without topology)
                        defined by an exterior Ring and 0..n interior Rings ("holes").</p>
                    
                    <p>Exactly one rain (water) phase can be defined for the area.</p>
                    
                    <p>The continuity (as in continuous rain) and the showeriness (as in rain showers) 
                        of the rain can both be specified as a floating point number between 0 and 1.</p>
                    
                    <p>Precipitation areas may contain 0..n inner areas with different rain phase,
                        continuity and/or showeriness qualities. These area are defined by
                        using innerArea element which is a property containing or referring to
                        another SurfacePrecipitationArea object. The exterior of the contained
                        area object must be completely inside the exterior
                        and not even partly cover the area inside any of the interior Rings
                        of the parent object. If a value for any of the qualities is not
                        given, it is assumed to be the same as in its parent.</p>
                </html:div>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="metobj:AbstractSurfaceObjectType">
                <sequence>
                    <element name="rainPhase" type="metobj:rainPhaseType" minOccurs="0"
                        maxOccurs="1" />
                    <element name="continuity" type="metobj:percentageType" minOccurs="0"
                        maxOccurs="1" />
                    <element name="showeriness" type="metobj:percentageType" minOccurs="0"
                        maxOccurs="1" />
                    <element name="approximateRainFall" type="gml:MeasureType" minOccurs="0" 
                        maxOccurs="1"/>
                    <element name="innerArea" type="metobj:SurfacePrecipitationAreaPropertyType"
                        minOccurs="0" maxOccurs="unbounded" />
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <!-- ================================================================= -->
    <element name="surfacePrecipitationAreaProperty"
        type="metobj:SurfacePrecipitationAreaPropertyType" />
    <!-- ================================================================= -->
    <complexType name="SurfacePrecipitationAreaPropertyType">
        <annotation>
            <documentation>To be used when using this object type as property of n GML object
                type according to the GML object-property-association model (it is not allowed for
                GML Objects to contain other GML Objects as direct children). Enables referencing to
                an existing object using xlink:href attribute.</documentation>
        </annotation>

        <sequence minOccurs="0">
            <element ref="metobj:SurfacePrecipitationArea" />
        </sequence>
        <attributeGroup ref="gml:AssociationAttributeGroup" />

    </complexType>

    <!-- ========================================================================================== -->
    <element name="CloudArea" type="metobj:CloudAreaType"
        substitutionGroup="metobj:AbstractSurfaceObject" />
    <!-- ========================================================================================== -->
    <complexType name="CloudAreaType">
        <annotation>
            <documentation>
                <html:div xmlns="http://www.w3.org/1999/xhtml">
                    <p>Area of cloud coverage including cloud type and coverage in percentage, eighths or
                        cloud amount abbreviations according to the ICAO's "Annex 3 to the Convention on 
                        International Civil Aviation: Meteorological Service 
                        for International Air Navigation".</p>
                    
                    <p>Cloud areas may contain 0..n inner areas with different cloud type and coverage
                        qualities. These area are defined by
                        using innerArea element which is a property containing or referring to
                        another CloudArea object. The exterior of the contained
                        area object must be completely inside the exterior
                        and not even partly cover the area inside any of the interior Rings
                        of the parent object. If a value for any of the qualities is not
                        given, it is assumed to be the same as in its parent.</p>
                </html:div>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="metobj:AbstractSurfaceObjectType">
                <sequence>
                    <element name="cloudType" type="metobj:cloudTypeAnnex3Type" minOccurs="1"
                        maxOccurs="1" />
                    <choice>
                        <element name="cloudCoverPercent" type="metobj:percentageType"
                            minOccurs="0" maxOccurs="1" />
                        <element name="cloudCoverEighths" type="metobj:cloudCoverEighthsType"
                            minOccurs="0" maxOccurs="1" />
                        <element name="cloudCoverAnnex3" type="metobj:cloudCoverAnnex3Type"
                            minOccurs="0" maxOccurs="unbounded" />
                    </choice>
                    <element name="innerArea" type="metobj:CloudAreaPropertyType" minOccurs="0"
                        maxOccurs="unbounded" />
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <!-- ================================================================= -->
    <element name="CloudAreaProperty" type="metobj:CloudAreaPropertyType" />
    <!-- ================================================================= -->
    <complexType name="CloudAreaPropertyType">
        <annotation>
            <documentation>To be used when using this object type as property of n GML object
                type according to the GML object-property-association model (it is not allowed for
                GML Objects to contain other GML Objects as direct children). Enables referencing to
                an existing object using xlink:href attribute.</documentation>
        </annotation>

        <sequence minOccurs="0">
            <element ref="metobj:CloudArea" />
        </sequence>
        <attributeGroup ref="gml:AssociationAttributeGroup" />

    </complexType>

    <!-- ========================================================================================== -->
    <element name="ParameterValueArea" type="metobj:ParameterValueAreaType"
        substitutionGroup="metobj:AbstractSurfaceObject" />
    <!-- ========================================================================================== -->
    <complexType name="ParameterValueAreaType">
        <annotation>
            <documentation>
                <html:div xmlns="http://www.w3.org/1999/xhtml">
                    <p />
                </html:div>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="metobj:AbstractSurfaceObjectType">
                <sequence>
                    <element name="parameter" type="metobj:GeophysicalParameterPropertyType"
                        minOccurs="1" maxOccurs="1" />
                    <element name="value" type="gml:MeasureType" minOccurs="1" maxOccurs="1" />
                    <element name="elevation" type="metobj:ElevationPropertyType" minOccurs="0" maxOccurs="1"/>
                    <element name="innerArea" type="metobj:ParameterValueAreaPropertyType"
                        minOccurs="0" maxOccurs="unbounded" />
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    <!-- ========================================================================================== -->
    <element name="parameterValueAreaProperty" type="metobj:ParameterValueAreaPropertyType" />
    <!-- ========================================================================================== -->
    <complexType name="ParameterValueAreaPropertyType">
        <annotation>
            <documentation>To be used when using this object type as property of n GML object
                type according to the GML object-property-association model (it is not allowed for
                GML Objects to contain other GML Objects as direct children). Enables referencing to
                an existing object using xlink:href attribute.</documentation>
        </annotation>

        <sequence minOccurs="0">
            <element ref="metobj:ParameterValueArea" />
        </sequence>
        <attributeGroup ref="gml:AssociationAttributeGroup" />
    </complexType>
    
    <!-- ========================================================================================== -->
    <element name="TextForecastArea" type="metobj:TextForecastAreaType"
        substitutionGroup="metobj:AbstractSurfaceObject" />
    <!-- ========================================================================================== -->
    <complexType name="TextForecastAreaType">
        <annotation>
            <documentation>
                <html:div xmlns="http://www.w3.org/1999/xhtml">
                    <p>Textual weather forecast for the given area with one or more semantically divided sections
                        (rain, wind, temperature conditions and so on).
                        Forecast target area is modelled as continuous patch of abstract earth surface (without topology)
                        defined by an exterior Ring and 0..n interior Rings ("holes").</p>
                    
                    
                    <p>Text forecast areas may contain 0..n inner areas with different qualities. These area are defined by
                        using innerArea element which is a property containing or referring to
                        another GroundTextForecast object. The exterior of the contained
                        area object must be completely inside the exterior
                        and not even partly cover the area inside any of the interior Rings
                        of the parent object. If a value for any of the qualities is not
                        given, it is assumed to be the same as in its parent.</p>
                </html:div>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="metobj:AbstractSurfaceObjectType">
                <sequence>
                    <element name="forecastTime" type="dateTime"
                    minOccurs="1" maxOccurs="1" />
                    <element name="section" type="metobj:ForecastTextSectionPropertyType" minOccurs="1" maxOccurs="unbounded"/>
                    <element name="innerArea" type="metobj:TextForecastAreaPropertyType"
                    minOccurs="0" maxOccurs="unbounded" />
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    
    <!-- ========================================================================================== -->
    <element name="textForecastAreaProperty" type="metobj:TextForecastAreaPropertyType" />
    <!-- ========================================================================================== -->
    <complexType name="TextForecastAreaPropertyType">
        <annotation>
            <documentation>To be used when using this object type as property of n GML object
                type according to the GML object-property-association model (it is not allowed for
                GML Objects to contain other GML Objects as direct children). Enables referencing to
                an existing object using xlink:href attribute.</documentation>
        </annotation>
        
        <sequence minOccurs="0">
            <element ref="metobj:TextForecastArea" />
        </sequence>
        <attributeGroup ref="gml:AssociationAttributeGroup" />
    </complexType>
    
    <!-- ======================================================================================================== -->
    <element name="AreaNote"
        type="metobj:AreaNoteType" substitutionGroup="metobj:AbstractSurfaceObject" />
    <!-- ======================================================================================================== -->
    <complexType name="AreaNoteType">
        <annotation>
            <documentation>
                <html:div xmlns="http://www.w3.org/1999/xhtml">
                    <p>A general note regarding a specified surface area and time.</p>
                </html:div>
            </documentation>
        </annotation>
        <complexContent>
            <extension base="metobj:AbstractSurfaceObjectType">
                <sequence>
                    <element name="noteText" type="metobj:longLocalizedStringType" minOccurs="0" maxOccurs="unbounded"/>
                    <element ref="metobj:GraphicSymbol" minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
    
</schema>