
Imports

    >>> from tests.utils import resource_file
    >>> from owslib.sos import SensorObservationService
    >>> from owslib.fes import FilterCapabilities200
    >>> from owslib.ows import OperationsMetadata
    >>> from owslib.crs import Crs
    >>> from datetime import datetime
    >>> from operator import itemgetter

Initialize

    >>> xml = open(resource_file('sos_ngwd.xml'),'rb').read()
    >>> ngwd = SensorObservationService(None, xml=xml, version='2.0.0')

ServiceIdentification

    >>> id = ngwd.identification

    >>> id.service
    'OGC:SOS'

    >>> id.version
    '2.0.0'

    >>> len(id.profiles)
    5

    >>> id.title
    'GIN SOS'

    >>> id.abstract
    'GIN SOS mediator'

    >>> id.keywords
    ['water level', 'groundwater level', 'surface water flow']

    >>> id.fees
    'NONE'

    >>> id.accessconstraints
    'NONE'


ServiceProvider

    >>> p = ngwd.provider

    >>> p.name
    'Geological Survey of Canada, Earth Sciences Sector, Natural Resources Canada, Government of Canada'

    >>> p.url
    'http://gw-info.net'


    ServiceContact

    >>> sc = p.contact

    Unused fields should return nothing
    >>> sc.role
    >>> sc.position
    'Research Scientist'
    >>> sc.instructions
    >>> sc.organization
    >>> sc.fax
    '+1-613-995-9273'
    >>> sc.hours

    >>> sc.name
    'Boyan Brodaric'

    >>> sc.phone
    '+1-613-992-3562'

    >>> sc.address
    '615 Booth Street'

    >>> sc.city
    'Ottawa'

    >>> sc.region

    >>> sc.postcode
    'K1A 0E9'

    >>> sc.country
    'Canada'

    >>> sc.email
    'brodaric at nrcan dot gc dot ca'


OperationsMetadata

    >>> o = ngwd.operations
    >>> len(o)
    4

    Get by name
    >>> getcap = ngwd.get_operation_by_name('GetCapabilities')
    >>> isinstance(getcap, OperationsMetadata)
    True

    Get by name (case insensitive)
    >>> getcap = ngwd.get_operation_by_name('getcapabilities')
    >>> isinstance(getcap, OperationsMetadata)
    True

    # GetCapabilities
    >>> getcap.constraints
    []

    >>> x = getcap.parameters
    >>> x == {'AcceptVersions': {'values': ['2.0.0']}, 'updateSequence': {'values': []}, 'Sections': {'values': ['ServiceIdentification', 'ServiceProvider', 'OperationsMetadata', 'FilterCapabilities', 'Contents', 'All']}, 'AcceptFormats': {'values': ['text/xml', 'application/zip']}}
    True

    >>> x = sorted(getcap.methods, key=itemgetter('type'))
    >>> x == [{'type' : 'Get', 'url': 'http://ngwd-bdnes.cits.nrcan.gc.ca:8080/proxy/GinService/sos/gw?', 'constraints': []}, {'type' : 'Post', 'url': 'http://ngwd-bdnes.cits.nrcan.gc.ca:8080/proxy/GinService/sos/gw', 'constraints': []}]
    True


    # DescribeSensor
    >>> descsen = ngwd.get_operation_by_name('describesensor')

    >>> descsen.constraints
    []

    >>> x = descsen.parameters
    >>> x == {'procedureDescriptionFormat': {'values': ['http://www.opengis.net/sensorML/1.0.1']}, 'procedure': {'values': ['urn:ogc:object:Sensor::GIN_GroundwaterLevelProcess']}}
    True


    >>> x = sorted(descsen.methods, key=itemgetter('type'))
    >>> x == [{'type': 'Get', 'url': 'http://ngwd-bdnes.cits.nrcan.gc.ca:8080/proxy/GinService/sos/gw?', 'constraints': []}, {'type' : 'Post', 'url': 'http://ngwd-bdnes.cits.nrcan.gc.ca:8080/proxy/GinService/sos/gw', 'constraints': []}]
    True


    # GetObservation
    >>> getob = ngwd.get_operation_by_name('getobservation')

    >>> getob.constraints
    []

    >>> x = getob.parameters
    >>> x == {'srsName': {'values': []}, 'temporalFilter': {'values': []}, 'offering': {'values': ['GW_LEVEL']}, 'result': {'values': []}, 'responseFormat': {'values': ['http://www.opengis.net/waterml/2.0', 'application/zip']}, 'observedProperty': {'values': ['urn:ogc:def:phenomenon:OGC:1.0.30:groundwaterlevel']}, 'procedure': {'values': ['urn:ogc:object:Sensor::GIN_GroundwaterLevelProcess']}}
    True

    >>> x = getob.methods
    >>> x == [{'type' : 'Get', 'url': 'http://ngwd-bdnes.cits.nrcan.gc.ca:8080/proxy/GinService/sos/gw?', 'constraints': []}, {'type': 'Post', 'url': 'http://ngwd-bdnes.cits.nrcan.gc.ca:8080/proxy/GinService/sos/gw', 'constraints': []}]
    True


Filter_Capabilities

    >>> filter = ngwd.filters
    >>> isinstance(filter, FilterCapabilities200)
    False


Contents
    >>> contents = ngwd.contents
    >>> len(contents)
    1


    Network
    >>> network = contents['GW_LEVEL']
    >>> network.id
    'GW_LEVEL'

    >>> network.procedures
    ['urn:ogc:object:Sensor::GIN_GroundwaterLevelProcess']

    >>> srs = network.bbox_srs
    >>> isinstance(srs, Crs)
    True
    >>> srs.id
    'http://www.opengis.net/def/crs/EPSG/0/4326'

    >>> srs.getcodeurn()
    'urn:ogc:def:crs:EPSG::4326'

    >>> srs.getcode()
    'EPSG:4326'

    # (left, bottom, right, top)
    >>> network.bbox
    (-120.0, 41.0, -60.0, 60.0)

    >>> bbsrs = network.bbox_srs

    >>> isinstance(bbsrs, Crs)
    True

    >>> bbsrs.getcodeurn()
    'urn:ogc:def:crs:EPSG::4326'

    >>> bbsrs.getcode()
    'EPSG:4326'

    >>> bp = network.begin_position
    >>> isinstance(bp, datetime)
    True
    >>> ep = network.end_position
    >>> isinstance(ep, datetime)
    True

    >>> network.observed_properties
    ['urn:ogc:def:phenomenon:OGC:1.0.30:groundwaterlevel']

    >>> network.response_formats
    []

    >>> network.observation_models
    []
