
Imports

    >>> from tests.utils import cast_tuple_int_list, resource_file
    >>> from owslib.sos import SensorObservationService
    >>> from owslib.fes2 import FilterCapabilities
    >>> from owslib.ows import OperationsMetadata
    >>> from owslib.crs import Crs
    >>> from datetime import datetime
    >>> from operator import itemgetter

Initialize

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

ServiceIdentification

    >>> id = ngmp.identification

    >>> id.service
    'OGC:SOS'

    >>> id.version
    '2.0.0'

    >>> len(id.profiles)
    3

    >>> id.title
    'GNS Science New Zealand, NGMP SOS timeseries'

    >>> id.abstract
    'GNS Hydrogeology Section, serving NGMP groundwater level through customised 52N SOS, data quality cannot be represented yet, there is no liability regarding this service, for more information go to http://ggw.gns.cri.nz/ggwdata/ (SVN: 0 @ 2013-01-12 19:55:25)'

    >>> id.keywords
    ['water level', 'groundwater', 'hydrogeology', 'ngmp']

    >>> id.fees
    'NONE'

    >>> id.accessconstraints
    'SERVICE IS IN TEST MODE, NOT RELIABLE, DATA QUALITY NOT YET VISIBLE'


ServiceProvider

    >>> p = ngmp.provider

    >>> p.name
    'GNS Science'

    >>> p.url
    'http://ggw.gns.cri.nz/ggwdata/'


    ServiceContact

    >>> sc = p.contact

    Unused fields should return nothing
    >>> sc.role
    >>> sc.position
    'STU'
    >>> sc.instructions
    >>> sc.organization
    >>> sc.fax
    >>> sc.hours
    >>> sc.name
    'Alex Kmoch'

    >>> sc.phone
    '+647374 8211'

    >>> sc.address
    '114 Karetoto Road'

    >>> sc.city
    'Wairakei'

    >>> sc.region
    'Waikato'

    >>> sc.postcode
    '3377'

    >>> sc.country
    'New Zealand'

    >>> sc.email
    'a.kmoch@gns.cri.nz'


OperationsMetadata

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

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

    # GetCapabilities
    >>> getcap.constraints
    []

    >>> x = getcap.parameters
    >>> x == {'AcceptVersions': {'values': ['1.0.0', '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': 'https://geier.gns.cri.nz/ngmp-sos/sos?', 'constraints': []}, {'type': 'Post', 'url': 'https://geier.gns.cri.nz/ngmp-sos/sos', 'constraints': []},]
    True


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

    >>> descsen.constraints
    []

    >>> x = descsen.parameters
    >>> x == {'procedureDescriptionFormat': {'values': ['http://www.opengis.net/sensorML/1.0.1']}, 'procedure': {'values': ['http://resources.smart-project.info/ggwdata/procedure/acidity_sampling', 'http://resources.smart-project.info/ggwdata/procedure/chloride_sampling', 'http://resources.smart-project.info/ggwdata/procedure/conductivity_sampling', 'http://resources.smart-project.info/ggwdata/procedure/groundwaterlevel_sensor', 'http://resources.smart-project.info/ggwdata/procedure/hydraulic_conductivity_sampling', 'http://resources.smart-project.info/ggwdata/procedure/iron_sampling', 'http://resources.smart-project.info/ggwdata/procedure/manganese_sampling', 'http://resources.smart-project.info/ggwdata/procedure/nitrate_sampling', 'http://resources.smart-project.info/ggwdata/procedure/temperature_sampling', 'http://resources.smart-project.info/ggwdata/procedure/tritium_sampling']}}
    True


    >>> x = sorted(descsen.methods, key=itemgetter('type'))
    >>> x == [{'type' : 'Get', 'url': 'https://geier.gns.cri.nz/ngmp-sos/sos?', 'constraints': []}, {'type': 'Post', 'url': 'https://geier.gns.cri.nz/ngmp-sos/sos', 'constraints': []}]
    True


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

    >>> getob.constraints
    []

    >>> x = getob.parameters
    >>> x == {'srsName': {'values': []}, 'offering': {'values': ['NGMP_HYDRAULIC_CONDUCTIVITY', 'NGMP_TRITIUM_ALL_FORMS', 'NGMP_DISSOLVED_MANGANESE', 'NGMP_TEMPERATURE', 'NGMP_DISSOLVED_IRON', 'NGMP_CONDUCTIVITY', 'NGMP_ACIDITY', 'NGMP_GROUNDWATER_LEVEL', 'NGMP_DISSOLVED_NITRATE_NO3_AS_N', 'NGMP_DISSOLVED_CHLORIDE']}, 'temporalFilter': {'values': []}, 'responseFormat': {'values': ['http://www.ioos.gov/dif/csv/0.9', 'http://www.opengis.net/waterml/2.0', 'http://www.opengis.net/om/2.0', 'application/zip']}, 'featureOfInterest': {'values': ['10', '11', '12', '13', '139', '14', '140', '15', '16', '17', '18', '19', '1993', '20', '2013', '2015', '2016', '2039', '2069', '2080', '21', '2103', '22', '23', '24', '2466', '2470', '2479', '25', '26', '27', '28', '29', '3', '30', '31', '32', '3200', '3258', '3280', '3281', '33', '3325', '3327', '3336', '338', '339', '34', '340', '346', '347', '348', '349', '35', '350', '351', '352', '353', '354', '355', '356', '358', '359', '36', '360', '361', '362', '363', '364', '37', '3705', '3706', '3707', '3708', '3709', '3710', '3711', '3712', '378', '379', '38', '380', '381', '382', '383', '384', '386', '387', '388', '389', '39', '390', '391', '392', '393', '394', '395', '4', '40', '401', '402', '403', '404', '405', '406', '407', '408', '409', '41', '410', '411', '412', '413', '414', '415', '416', '417', '418', '419', '42', '420', '421', '422', '423', '43', '437', '44', '443', '444', '445', '446', '447', '448', '449', '45', '451', '452', '453', '454', '455', '456', '458', '46', '464', '465', '466', '467', '468', '469', '47', '48', '49', '5', '50', '51', '511', '512', '52', '53', '54', '55', '552', '553', '56', '57', '58', '59', '6', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '7', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '8', '80', '81', '82', '83', '9']}, 'observedProperty': {'values': ['http://resources.smart-project.info/ggwdata/phenomenon/hydraulic_conductivity', 'http://resources.smart-project.info/ggwdata/phenomenon/tritium_all_forms', 'http://resources.smart-project.info/ggwdata/phenomenon/dissolved_manganese', 'http://resources.smart-project.info/ggwdata/phenomenon/temperature', 'http://resources.smart-project.info/ggwdata/phenomenon/dissolved_iron', 'http://resources.smart-project.info/ggwdata/phenomenon/conductivity', 'http://resources.smart-project.info/ggwdata/phenomenon/acidity', 'http://resources.smart-project.info/ggwdata/phenomenon/groundwaterlevel', 'http://resources.smart-project.info/ggwdata/phenomenon/dissolved_nitrate_no3_as_n', 'http://resources.smart-project.info/ggwdata/phenomenon/dissolved_chloride']}, 'procedure': {'values': ['http://resources.smart-project.info/ggwdata/procedure/acidity_sampling', 'http://resources.smart-project.info/ggwdata/procedure/chloride_sampling', 'http://resources.smart-project.info/ggwdata/procedure/conductivity_sampling', 'http://resources.smart-project.info/ggwdata/procedure/groundwaterlevel_sensor', 'http://resources.smart-project.info/ggwdata/procedure/hydraulic_conductivity_sampling', 'http://resources.smart-project.info/ggwdata/procedure/iron_sampling', 'http://resources.smart-project.info/ggwdata/procedure/manganese_sampling', 'http://resources.smart-project.info/ggwdata/procedure/nitrate_sampling', 'http://resources.smart-project.info/ggwdata/procedure/temperature_sampling', 'http://resources.smart-project.info/ggwdata/procedure/tritium_sampling']}, 'result': {'values': []}}
    True

    >>> x = sorted(getob.methods, key=itemgetter('type'))
    >>> x == [{'type' : 'Get', 'url': 'https://geier.gns.cri.nz/ngmp-sos/sos?', 'constraints': []}, {'type': 'Post', 'url': 'https://geier.gns.cri.nz/ngmp-sos/sos', 'constraints': []}]
    True


Filter_Capabilities

    >>> filter = ngmp.filters
    >>> isinstance(filter, FilterCapabilities)
    False


Contents
    >>> contents = ngmp.contents
    >>> len(contents)
    10


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

    >>> network.procedures
    ['http://resources.smart-project.info/ggwdata/procedure/temperature_sampling']
    
    >>> srs = network.bbox_srs
    >>> isinstance(srs, Crs)
    True
    >>> srs.id
    'http://www.opengis.net/def/crs/EPSG/0/4272'

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

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

    # (left, bottom, right, top)
    >>> cast_tuple_int_list(network.bbox)
    [168, -46, 177, -34]
    
    >>> bp = network.begin_position
    >>> isinstance(bp, datetime)
    True
    >>> ep = network.end_position
    >>> isinstance(ep, datetime)
    True
   
    >>> network.observed_properties
    ['http://resources.smart-project.info/ggwdata/phenomenon/temperature']

    >>> network.response_formats
    ['http://www.ioos.gov/dif/csv/0.9', 'http://www.opengis.net/waterml/2.0', 'http://www.opengis.net/om/2.0', 'application/zip']

    >>> network.observation_models
    ['http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Observation']
