<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:vr="http://www.ivoa.net/xml/VOResource/v1.0"
           xmlns:sia="http://www.ivoa.net/xml/SIA/v1.1"
           xmlns:vm="http://www.ivoa.net/xml/VOMetadata/v0.1"
           targetNamespace="http://www.ivoa.net/xml/SIA/v1.1"
           elementFormDefault="unqualified" attributeFormDefault="unqualified"
           version="1.2">

   <xs:annotation>
      <xs:appinfo>
        <vm:schemaName>SIA</vm:schemaName>
        <vm:schemaPrefix>xs</vm:schemaPrefix>
        <vm:targetPrefix>sia</vm:targetPrefix>
      </xs:appinfo>
      <xs:documentation>
        Implementation of an XML Schema describing a Simple Image
        Access Service.   Based on the Simple Image Access Specification
        by Doug Tody et al.
      </xs:documentation>
   </xs:annotation>

   <xs:import namespace="http://www.ivoa.net/xml/VOResource/v1.0"
   	schemaLocation="http://docs.g-vo.org/schemata/VOResource.xsd"/>

   <xs:complexType name="SimpleImageAccess">
      <xs:annotation>
         <xs:documentation>
            The capabilities of an SIA implementation.  
         </xs:documentation>
      </xs:annotation>

      <xs:complexContent>
         <xs:extension base="vr:Capability">
            <xs:sequence>
               <xs:element name="imageServiceType" type="sia:ImageServiceType">
                  <xs:annotation>
                     <xs:documentation>
                   The class of image service: Cutout, Mosaic, Atlas, Pointed
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

               <xs:element name="maxQueryRegionSize" type="sia:SkySize"
                           minOccurs="0" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                         The maximum image query region size, expressed in 
                         decimal degrees.  Not providing this element or 
                         specifying a value of 360 degrees indicates that 
                         there is no limit and the entire data collection 
                         (entire sky) can be queried. 
                     </xs:documentation>
                     <xs:documentation>
                         Not providing a value is the prefered way to indicate
                         that there is no limit.
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

               <xs:element name="maxImageExtent" type="sia:SkySize"
                           minOccurs="0" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                         An upper bound on a region of the sky that can 
                         be covered by returned images.  That is, no image
                         returned by this service will cover more than 
                         this limit.  Not providing this element or 
                         specifying a value of 360 degrees indicates that 
                         there is no fundamental limit to the region covered 
                         by a returned image.  
                     </xs:documentation>
                     <xs:documentation>
                         When the imageServiceType is “Cutout” or “Mosaic”, 
                         this represents the largest area that can be requested.
                         In this case, the “no limit” value means that all-sky
                         images can be requested.  When the type is “Atlas” or
                         “Pointed”, it should be a region that most closely 
                         encloses largest images in the archive, and the ”no
                         limit” value means that the archive contains all-sky 
                         (or nearly so) images.  
                     </xs:documentation>
                     <xs:documentation>
                         Not providing a value is the prefered way to indicate
                         that there is no limit.
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

               <xs:element name="maxImageSize" type="xs:positiveInteger"
                           minOccurs="0" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                         A measure of the largest image the service
                         can produce given as the maximum number of
                         pixels along the first or second axes.
                         Not providing a value indicates that there is 
                         no effective limit to the size of the images 
                         that can be returned.  
                     </xs:documentation>
                     <xs:documentation>
                         This is primarily relevant when the imageServiceType
                         is “Cutout” or “Mosaic”, indicating the largest 
                         image that can be created.  When the imageServiceType 
                         is “Atlas” or “Pointed”, this should be specified only
                         when there are static images in the archive that can 
                         be searched for but not returned because they are 
                         too big.  
                     </xs:documentation>
                     <xs:documentation>
                         When a service is more fundementally limited
                         by the total number of pixels in the image, this 
                         value should be set to the square-root of that
                         number.  This number will then represent a
                         lower limit on the maximum length of a side.  
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

               <xs:element name="maxFileSize" type="xs:positiveInteger"
                           minOccurs="0" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                        The maximum image file size in bytes.  Not providing 
                        a value indicates that there is no effective limit 
                        the size of files that can be returned.  
                     </xs:documentation>
                     <xs:documentation>
                        This is primarily relevant when the imageServiceType
                        is “Cutout” or “Mosaic”, indicating the largest 
                        files that can be created.  When the imageServiceType 
                        is “Atlas” or “Pointed”, this should be specified only
                        when there are static images in the archive that can 
                        be searched for but not returned because they are 
                        too big.  
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

               <xs:element name="maxRecords" type="xs:positiveInteger"
                           minOccurs="0" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                        The largest number of records that the Image Query web
                        method will return. Not providing this value means that
                        there is no effective limit.  
                     </xs:documentation>
                     <xs:documentation>
                        This does not refer to the total number of images in 
                        the archive but rather maximum number of records the 
                        service is capable of returning.  A limit that is 
                        greater than the number of images available in the 
                        archive is equivalent to their being no effective 
                        limit.  (See RM, Hanisch 2007.)
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

               <xs:element name="testQuery" type="sia:Query" 
                           minOccurs="0" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                        a set of query parameters that is expected
                        to produce at least one matched record which
                        can be used to test the service.  
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <xs:complexType name="SkySize">
      <xs:sequence>
         <xs:element name="long" type="xs:double">
           <xs:annotation>
              <xs:documentation>
                 The maximum size in the longitude (R.A.) direction
                 given in degrees
              </xs:documentation>
           </xs:annotation>
         </xs:element>
         <xs:element name="lat" type="xs:double">
           <xs:annotation>
              <xs:documentation>
                 The maximum size in the latitude (Dec.) direction 
                 given in degrees
              </xs:documentation>
           </xs:annotation>
         </xs:element>
      </xs:sequence>
   </xs:complexType>

   <xs:complexType name="SkyPos">
      <xs:sequence>
         <xs:element name="long" type="xs:double">
           <xs:annotation>
              <xs:documentation>
                 The sky position in the longitude (R.A.) direction 
              </xs:documentation>
           </xs:annotation>
         </xs:element>
         <xs:element name="lat" type="xs:double">
           <xs:annotation>
              <xs:documentation>
                 The sky position in the latitude (Dec.) direction 
              </xs:documentation>
           </xs:annotation>
         </xs:element>
      </xs:sequence>
   </xs:complexType>

   <xs:simpleType name="ImageServiceType">
      <xs:annotation>
         <xs:documentation>
       The class of image service: Cutout, Mosaic, Atlas, Pointed
         </xs:documentation>
      </xs:annotation>

      <xs:restriction base="xs:token">

         <xs:enumeration value="Cutout">
            <xs:annotation>
               <xs:documentation>
         This is a service which extracts or “cuts out” rectangular
         regions of some larger image, returning an image of the
         requested size to the client. Such images are usually drawn
         from a database or a collection of survey images that cover
         some large portion of the sky. To be considered a cutout
         service, the returned image should closely approximate (or at
         least not exceed) the size of the requested region; however,
         a cutout service will not normally resample (rescale or
         reproject) the pixel data. A cutout service may mosaic image
         segments to cover a large region but is still considered a
         cutout service if it does not resample the data.  Image
         cutout services are fast and avoid image degredation due to
         resampling.  
               </xs:documentation>
            </xs:annotation>
         </xs:enumeration>

         <xs:enumeration value="Mosaic">
            <xs:annotation>
               <xs:documentation>
                  This service is similar to the image cutout service
                  but adds the capability to compute an image of the
                  size, scale, and projection specified by the
                  client. Mosaic services include services which
                  resample and reproject existing image data, as well
                  as services which generate pixels from some more
                  fundamental dataset, e.g., a high energy event list
                  or a radio astronomy measurement set. Image mosaics
                  can be expensive to generate for large regions but
                  they make it easier for the client to overlay image
                  data from different sources. Image mosaicing
                  services which resample already pixelated data will
                  degrade the data slightly, unlike the simpler cutout
                  service which returns the data unchanged.  
               </xs:documentation>
            </xs:annotation>
         </xs:enumeration>

         <xs:enumeration value="Atlas">
            <xs:annotation>
               <xs:documentation>
                  This category of service provides access to
                  pre-computed images that make up a survey of some
                  large portion of the sky. The service, however, is
                  not capable of dynamically cutting out requested
                  regions, and the size of atlas images is
                  predetermined by the survey. Atlas images may range
                  in size from small cutouts of extended objects to
                  large calibrated survey data frames. 
               </xs:documentation>
            </xs:annotation>
         </xs:enumeration>

         <xs:enumeration value="Pointed">
            <xs:annotation>
               <xs:documentation>
                  This category of service provides access to
                  collections of images of many small, “pointed”
                  regions of the sky. “Pointed” images normally focus
                  on specific sources in the sky as opposed to being
                  part of a sky survey. This type of service usually
                  applies to instrumental archives from observatories
                  with guest observer programs (e.g., the HST archive)
                  and other general purpose image archives (e.g., the
                  ADIL). If a service provides access to both survey
                  and pointed images, then it should be considered a
                  Pointed Image Archive for the purposes of this
                  specification; if a differentiation between the
                  types of data is desired the pointed and survey data
                  collections should be registered as separate image
                  services.  
               </xs:documentation>
            </xs:annotation>
         </xs:enumeration>

      </xs:restriction>
   </xs:simpleType>

   <xs:complexType name="Query">
      <xs:annotation>
         <xs:documentation>
            A query to be sent to the service
         </xs:documentation>
      </xs:annotation>

      <xs:sequence>
         <xs:element name="pos" type="sia:SkyPos" minOccurs="0">
            <xs:annotation>
               <xs:documentation>
                   the center position of the rectangular region that 
                   should be used as part of the query to the SIA service. 
               </xs:documentation>
            </xs:annotation>
         </xs:element>

         <xs:element name="size" type="sia:SkySize" minOccurs="0">
            <xs:annotation>
               <xs:documentation>
                   the rectangular size of the region that should be 
                   used as part of the query to the SIA service.
               </xs:documentation>
            </xs:annotation>
         </xs:element>

         <xs:element name="verb" type="xs:positiveInteger" minOccurs="0">
            <xs:annotation>
               <xs:documentation>
                   the verbosity level to use where 0 means the bare
                   minimum set of columns and 3 means the full set of 
                   available columns.
               </xs:documentation>
            </xs:annotation>
         </xs:element>

         <xs:element name="extras" type="xs:string" minOccurs="0">
            <xs:annotation>
               <xs:documentation>
                   any extra (particularly non-standard) parameters that must 
                   be provided (apart from what is part of base URL given by 
                   the accessURL element).
               </xs:documentation>
               <xs:documentation>
                   this value should be in the form of name=value
                   pairs delimited with ampersands (&amp;).  
               </xs:documentation>
            </xs:annotation>
         </xs:element>

      </xs:sequence>

   </xs:complexType>

</xs:schema>
