Giter Site home page Giter Site logo

geopython / owslib Goto Github PK

View Code? Open in Web Editor NEW
369.0 369.0 271.0 5.17 MB

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.

Home Page: https://owslib.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.01% Python 99.99%
ogc ogcapi ows

owslib's Introduction

geopython

Vanity package for geopython projects

pip install geopython
>>> import geopython

owslib's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owslib's Issues

Native bounding box and SRS are not being parsed in WCS

Here is a sample snippet that does this outside of OWSLib.

{{{

descCov=metadata._service.getDescribeCoverage(projected_tif.typename)
envelope = descCov.find(ns('CoverageOffering/')+ns('domainSet/')+ns('spatialDomain/')+'{http://www.opengis.net/gml}Envelope')
nativeSrs = envelope.attrib['srsName']
logger.info(nativeSrs)
gmlpositions=envelope.findall('{http://www.opengis.net/gml}pos')
lc=gmlpositions[0].text
uc=gmlpositions[1].text
bboxNative = (
float(lc.split()[0]),float(lc.split()[1]),
float(uc.split()[0]), float(uc.split()[1]),
)
logger.info(bboxNative)

}}}

Trouble Parsing ISO19139 Services

I've been working on a simple csw client to hit our CSW server. We use ISO19139 metadata that has multiple srv_Serviceidentification sections. Looking at line 85 through 96 of iso.py, it appears that MD_DataIdentification and SV_ServiceIdentification will only get parsed once for one or the other.

A chunk of code to return title, abstract, and a url list is pasted below. Note that if you set "anyText" to 'nlcd', this code works because that record puts the urls of interest in the distributioninfo section. Setting "anyText" to 'gmo' returns a record that does not return any urls because of the use of both MD_DataIndentification and SV_ServiceIdentification.

This might be a quick fix, it looks like the SV_ServiceIdentification class would be parsed to get at our needs if the parser for MD_MetaData tried to go in there. Ideas?


from owslib.csw import CatalogueServiceWeb

def getDataSetURI(anyText='gmo',CSWURL='http://cida.usgs.gov/gdp/geonetwork/srv/en/csw',BBox=None):
"""

    Searches a given CSW server and returns metadata content for the datasets found.

    Arguments
    ---------

    - CSWURL - A base URL for the CSW server to be searched. (Optional, defaults to the CDIA/GDP CSW server.)
    - anyText - A string that will be submitted to the CSW search. (Optional, deafualt is empty which will return all records.)
    - BBox - A bounding box in WGS84 lat/lon that will be used to limit results to datasets that atleast partially intersect. (Optional)

    """

    csw = CatalogueServiceWeb(CSWURL)
    csw.getrecords(keywords=[anyText], outputschema='http://www.isotc211.org/2005/gmd', esn='full')
    dataSetURIs = [['title','abstract',['urls']]]
    for rec in csw.records:
        title=csw.records[rec].identification.title
        abstract=csw.records[rec].identification.abstract
        urls=[]
        for onlineresource in range(len(csw.records[rec].distribution.online)):
                urls.append(csw.records[rec].distribution.online[onlineresource].url)
        # Should be another loop here that goes through all urls in the serviceidentification section of a metadata record as well.
        entry=[title,abstract,urls]
        dataSetURIs.append(entry)
    return dataSetURIs

dataseturis=getDataSetURI(anyText='gmo')
dataseturis

WMS time extent parsing fails when extent is missing

The spec is unclear as to what the text content of the Extent element should be when there is no data. Geoserver responds in this case with an empty element. wms.py does not check for this case.

The following diff illustrates a fix:

438,439c438
< if extent.text:

< self.timepositions=extent.text.split(',')

            self.timepositions=extent.text.split(',')

Python 3 support

Some of the changes are possible to do automatically with 2to3: http://pythonhosted.org/distribute/python3.html. I already tried that and manually tested some features. Some parts works but there is still code which doesn't work.

Blockers:
When running tests setup.py loads modules from source directory instead of build directory. Explained and fixed in: http://www.hackzine.org/python-testing-with-pytest-and-2to3-plus-tox-and-travis-ci.html. Anyone familiar enough with (2to3, )test.py and doctests to fix this?

MD_Metadata Parsing AttributeError

Was testing out some CSW calls that parse various xml files. I found an error regarding a "missing" field with a nilReason tag. Not sure exactly what the hangup is, but I've attached two files. One with and one without the empty tag.

Do

from lxml import etree
from owslib.iso import MD_Metadata
md = MD_Metadata(etree.parse('nlcd.xml'))
to reproduce. There is also a file at nlcd.xml that does not have the empty purpose element that parses fine.

I'm fine removing the element rather than leaving it empty, but figured you'd want to know, I think a nillreason and empty tag is valid, atleast Oxygen thinks it is.

Example files are here: ftp://ftpext.usgs.gov/pub/er/wi/middleton/dblodgett/example_iso_files/

build failure from pypi

cc @kwilcox

FYI when pushing to pypi with python setup.py sdist upload, requirements.txt does not get included.

This causes a build error when doing pip install OWSLib because setup.py sets install_requires by reading requirements.txt:

(foo)tkralidi@www:/tmp/OWSLib$ pip install OWSLib
Downloading/unpacking OWSLib
  Running setup.py egg_info for package OWSLib
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/home/tkralidi/work/foss4g/pycsw/pycsw-master/build/OWSLib/setup.py", line 17, in <module>
        reqs = [line.strip() for line in open('requirements.txt')]
    IOError: [Errno 2] No such file or directory: 'requirements.txt'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/home/tkralidi/work/foss4g/pycsw/pycsw-master/build/OWSLib/setup.py", line 17, in <module>

    reqs = [line.strip() for line in open('requirements.txt')]

IOError: [Errno 2] No such file or directory: 'requirements.txt'

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/tkralidi/work/foss4g/pycsw/pycsw-master/build/OWSLib
Storing complete log in /home/tkralidi/.pip/pip.log

Options:

  • just hardcode setup.py install_requires
  • ensure requirements.txt is added when doing python setup.py sdist upload

I will do the first option now as this is a blocker, but it would be neat to have requirements.txt be included and thus read as intended.

WMS 1.3.0 not supported because of xml namespaces

I've been debugging an owslib-using application. WMS getcapabilities doesn't work in the 1.3.0 version because of the way owslib queries the xml file with etree:

Traceback (most recent call last):
...
self.type = self._root.find('Name').text
AttributeError: 'NoneType' object has no attribute 'find'

self._root is None because it is a query for .find('Service'), which does find the service tag for 1.1.1, but in 1.3.0 it is a fully namespaced xml file. Only.find('{http://url.to.wms.namespace/}Service')` now finds the Service tag...

I don't know if there are other changes in the 1.3.0 format, but this is at least a python-level thing that needs fixing before the actual format changes can be taken into account.

(Possible solution: some wrapper function that does the 'find' which adds the namespace? A small function to add the namespace to the string?)

Adding layer MetadataURL support to WebMapService - lost

This patch will be commited on http://svn.gispython.org/svn/gispy/OWSLib/trunk but it will be probably lost in the migration...

Original message:

Hello,

using OWSLib's WebMapService, one may browse the details of a WMS
layer (see [1]).

I notice that the element is not supported (see [2])
whereas it is defined as an optional child element of in the
WMS GetCapabilities specifications.

The attached patch adds the support of MetadataURL. Would it be useful
to create a ticket and join this patch? If yes, what is the procedure
to do so?

Best regards,
Alexandre

[1] http://gispython.org/owslib/docs/en/trunk/#wms
[2] http://trac.gispython.org/lab/browser/OWSLib/trunk/owslib/wms.py#L303

crsOptions bug in wms.py

line 410: self.crsOptions=None

if that's a parent, in the child layer,
self.crsOptions = list(self.parent.crsOptions)
blows up.

line 410 should be self.crsOptions = []

Show lxml version requirement

6b9aedb#L1R14 introduced the register_namespace function, which is only available on lxml>=2.3. I know this is quite an old version, but for the poor guys (like me) working with old versions of lxml it'd be good to have the lxml version requirement listed somewhere.

WPS client

It would be very nice feature for OWSlib to have WPS client support. I will investigate this a bit further.

git clone command correct?

I am no expert with git, but the given command does not work for me. Here is a patch with a working version ;)

diff --git a/docs/en/index.rst b/docs/en/index.rst
index 093337a..d6103dc 100644
--- a/docs/en/index.rst
+++ b/docs/en/index.rst
@@ -80,7 +80,7 @@ Git:

 .. code-block:: bash

-  $ git clone [email protected]:geopython/OWSLib.git
+  $ git clone git://github.com/geopython/OWSLib.git

 openSUSE:

getCapabilities with nested Layers

This getCapabilities File generated by ArcGIS Server 9.3.1 contains nested Layer definitions, where the non-queryable layers don't have a name.

owslib does not allow to get a valid list of layernames out of this getcapabilities response.

there are several issues: 1) the layer-reading should be fully recursive 2) if the layer has got no name defined, there is a problem in the dictionary, as the id is set to the name and thus the layer is not correctly inserted into the dictionnary.

add support for OGC Sensor Observation Service (SOS) 1.0.0

As discussed on mailing list, add support for OGC SOS 1.0.0. Notes:

I've started working on this.

WMTS tests requires fixes/updates

@bradh can you take a look in latest master at the WMTS tests? I get the following test issues:

$ py.test tests/doctests/wmts*
================================================================================ test session starts ================================================================================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
plugins: cov
collected 6 items 

tests/doctests/wmts_EOSDISWMTSCapabilities.txt .
tests/doctests/wmts_ERDAS13WMTSCapabilities.txt F
tests/doctests/wmts_ERDASWMTSCapabilities.txt F
tests/doctests/wmts_geoserver21.txt .
tests/doctests/wmts_SFSWorldWMTSCapabilities.txt .
tests/doctests/wmts.txt .

===================================================================================== FAILURES ======================================================================================
_____________________________________________________________________________________ [doctest] _____________________________________________________________________________________
071     'ogc:1.0:googlemapscompatible'
072     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].crs
073     'urn:ogc:def:crs:EPSG:6.18:3:3857'
074     >>> sorted(wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix.keys())
075     ['0', '1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '2', '3', '4', '5', '6', '7', '8', '9']
076     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].identifier
077     '0'
078     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].scaledenominator
079     559082264.0287178
080     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].topleftcorner
Expected:
    (20037508.34279, -20037508.34279)
Got:
    (-20037508.34279, 20037508.34279)

/home/tkralidi/work/foss4g/OWSLib/OWSLib/tests/doctests/wmts_ERDAS13WMTSCapabilities.txt:80: DocTestFailure
_____________________________________________________________________________________ [doctest] _____________________________________________________________________________________
071     'ogc:1.0:googlemapscompatible'
072     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].crs
073     'urn:ogc:def:crs:EPSG:6.18:3:3857'
074     >>> sorted(wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix.keys())
075     ['0', '1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '2', '3', '4', '5', '6', '7', '8', '9']
076     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].identifier
077     '0'
078     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].scaledenominator
079     559082264.0287178
080     >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].topleftcorner
Expected:
    (20037508.34279, -20037508.34279)
Got:
    (-20037508.34279, 20037508.34279)

/home/tkralidi/work/foss4g/OWSLib/OWSLib/tests/doctests/wmts_ERDASWMTSCapabilities.txt:80: DocTestFailure
======================================================================== 2 failed, 4 passed in 3.09 seconds =========================================================================
(OWSLib)tkralidi@www:~/work/foss4g/OWSLib/OWSLib$ 

ValueError: invalid literal for int() with base 10: 'false'

Dear,

I was doing several tests and I got this error:

wms = WebMapService('http://frameworkwfs.usgs.gov/framework/wms/wms.cgi')

Traceback (most recent call last):
File "", line 1, in
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 86, in init
self._buildMetadata(parse_remote_metadata)
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 126, in _buildMetadata
gather_layers(caps, None)
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 120, in gather_layers
cm = ContentMetadata(elem, parent=parent_metadata, index=index+1, parse_remote_metadata=parse_remote_metadata)
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 327, in init
self.queryable = int(elem.attrib.get('queryable', 0))
ValueError: invalid literal for int() with base 10: 'false'

OWSLib==0.7.2

Using QGis the service works.

Thanks!

D

Doctest wms_JPLCapabilities.txt fails due to dictionary key sorting

Testing trace and repository version are listed below. Diff file correcting this issue is attached.

Tested using: Python 2.6.4

{{{
$ svn info
Path: .
URL: http://svn.gispython.org/svn/gispy/OWSLib/trunk
Repository Root: http://svn.gispython.org/svn/gispy
Repository UUID: b426a367-1105-0410-b9ff-cdf4ab011145
Revision: 1675
Node Kind: directory
Schedule: normal
Last Changed Author: domlowe
Last Changed Rev: 1675
Last Changed Date: 2010-09-02 05:10:13 -0600 (Thu, 02 Sep 2010)
}}}

{{{

FAIL: Doctest: wms_JPLCapabilities.txt

Traceback (most recent call last):
File "/usr/lib/python2.6/doctest.py", line 2145, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for wms_JPLCapabilities.txt
File "/usr/local/OWSLib/trunk/tests/wms_JPLCapabilities.txt", line 0


File "/usr/local/OWSLib/trunk/tests/wms_JPLCapabilities.txt", line 57, in wms_JPLCapabilities.txt
Failed example:
wms.contents.keys()
Expected:
['us_landsat_wgs84', 'modis', 'global_mosaic_base',
'huemapped_srtm', 'srtm_mag', 'daily_terra', 'us_ned',
'us_elevation', 'global_mosaic', 'daily_terra_ndvi',
'daily_aqua_ndvi', 'daily_aqua_721', 'daily_aqua', 'BMNG',
'srtmplus', None, 'us_colordem', 'worldwind_dem', 'daily_terra_721']
Got:
[None, 'us_landsat_wgs84', 'global_mosaic_base',
'huemapped_srtm', 'srtm_mag', 'daily_terra', 'modis',
'us_elevation', 'global_mosaic', 'daily_terra_ndvi',
'daily_aqua_ndvi', 'daily_aqua_721', 'daily_aqua', 'BMNG',
'srtmplus', 'us_colordem', 'worldwind_dem', 'us_ned',
'daily_terra_721']


Ran 13 tests in 223.622s

FAILED (failures=1)
}}}

ISO metadata parsing - Only one <gmd:extent> seems to be parsed in Identificationinfo

The specification (http://www.isotc211.org/2005/gmd/identification.xsd) states that various <gmd:extent> elements may be present:

<xs:element
    name="extent"
    type="gmd:EX_Extent_PropertyType"
    minOccurs="0"
    maxOccurs="unbounded"
/>

for example, as defined in the <gmd:extent> specification (http://www.isotc211.org/2005/gmd/extent.xsd), both temporal extent and BoundingBox extent may be present.

Using the owslib.iso parser, it seems to be only possible to get one of these <gmd:extent> elements, the other ones being discarded.

To reproduce

Test with http://geo.gob.bo/geonetwork/srv/es/iso19139.xml?id=171 for example. Download it to /tmp/test.xml and parse with

from owslib.iso import *
m=MD_Metadata(etree.parse('/tmp/test.xml'))

The two temporal extent fields are filled:

  • m.identificationinfo[0].temporalextent_start value is '2006-01-15T18:08:00'
  • m.identificationinfo[0].temporalextent_end value is '2006-12-30T18:09:00'

but the BoundingBox field is empty

  • m.identificationinfo[0].bbox is None or m.identificationinfo[0].extent.boundingBox is None give True

whereas it is not in the metadata XML file:

<gmd:extent>
  <gmd:EX_Extent>
    <gmd:geographicElement>
      <gmd:EX_GeographicBoundingBox>
        <gmd:westBoundLongitude>
          <gco:Decimal>-69.6562</gco:Decimal>
        </gmd:westBoundLongitude>
        <gmd:eastBoundLongitude>
          <gco:Decimal>-57.5211</gco:Decimal>
        </gmd:eastBoundLongitude>
        <gmd:southBoundLatitude>
          <gco:Decimal>-22.9011</gco:Decimal>
        </gmd:southBoundLatitude>
        <gmd:northBoundLatitude>
          <gco:Decimal>-9.6792</gco:Decimal>
        </gmd:northBoundLatitude>
      </gmd:EX_GeographicBoundingBox>
    </gmd:geographicElement>
  </gmd:EX_Extent>
</gmd:extent>

csw.getrecords2 having problem with CWIC CSW

I'm using the latest OWSlib code (code that fixed issue 78), and still getting an error getting records from this CSW. Note sure if this is an OWSLib problem or a provider problem:

from owslib.csw import CatalogueServiceWeb

endpoint = 'http://cwic.csiss.gmu.edu/cwicv1/discovery'

csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.getrecords2(maxrecords=2)

gives this error:

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-7-3cf19d5d4035> in <module>()
----> 1 csw.getrecords2(maxrecords=2)

C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\lib\site-packages\owslib-0.7_dev-py2.7.egg\owslib\csw.pyc in getrecords2(self, constraints, sortby, typenames, esn, outputschema, format, startposition, maxrecords, cql, xml, resulttype)
    339             self.request = node0
    340 
--> 341         self._invoke()
    342 
    343         if self.exceptionreport is None:

C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\lib\site-packages\owslib-0.7_dev-py2.7.egg\owslib\csw.pyc in _invoke(self)
    573             self.request = util.xml2string(etree.tostring(self.request))
    574 
--> 575             self.response = util.http_post(self.url, self.request, self.lang, self.timeout)
    576 
    577         # parse result see if it's XML

C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\lib\site-packages\owslib-0.7_dev-py2.7.egg\owslib\util.pyc in http_post(url, request, lang, timeout)
    285 
    286         try:
--> 287             up = urllib2.urlopen(r,timeout=timeout);
    288         except TypeError:
    289             import socket

C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in urlopen(url, data, timeout)
    124     if _opener is None:
    125         _opener = build_opener()
--> 126     return _opener.open(url, data, timeout)
    127 
    128 def install_opener(opener):

C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in open(self, fullurl, data, timeout)
    404         for processor in self.process_response.get(protocol, []):
    405             meth = getattr(processor, meth_name)
--> 406             response = meth(req, response)
    407 
    408         return response

C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in http_response(self, request, response)
    517         if not (200 <= code < 300):
    518             response = self.parent.error(
--> 519                 'http', request, response, code, msg, hdrs)
    520 
    521         return response

C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in error(self, proto, *args)
    442         if http_err:
    443             args = (dict, 'default', 'http_error_default') + orig_args
--> 444             return self._call_chain(*args)
    445 
    446 # XXX probably also want an abstract factory that knows when it makes

C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
    376             func = getattr(handler, meth_name)
    377 
--> 378             result = func(*args)
    379             if result is not None:
    380                 return result

C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in http_error_default(self, req, fp, code, msg, hdrs)
    525 class HTTPDefaultErrorHandler(BaseHandler):
    526     def http_error_default(self, req, fp, code, msg, hdrs):
--> 527         raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    528 
    529 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 500: Internal Server Error

WMS should support vendor specifc parameters

See patch submitted by Servais Nabil

I would like to suggest 2 patchs. The first is for supporting custom parameters of WMS, I don't know if it's normalize by OGC, but it's supported by Mapserver.

For exemple I have this request in openlayers:

http://wmshost/cgi-bin/xyea?LAYERS=oursindep%2Cetablissement&FORMAT=jpg&IDOURSIN=%20uai_dger%7C%7Cinsee_resplegal%20%7C%7Cfiliere_code%7C%7Csecteur_pro_code%7C%7Coption_code&GROUPBYCLAUSE=%20GROUP%20BY%20%20uai_dger&WHERECLAUSE=%20WHERE%20secteur_code%20%3D%201&GEOMSUFFIXE=_rel&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A27572&BBOX=-679807.84,1230100.62,1925309.84,2987770.38&WIDTH=996&HEIGHT=672 And this is the request with my owslib patched :

url_wms = ' http://wmshost/cgi-bin/xyea' layers = [ 'oursindep', 'etablissement', 'responsables_legaux', 'regions']

    bbox = (-10.900634765625, 36.857250976562, 15.400634765625, 55.742749023437)

styles = custom = {'WHERECLAUSE':'WHERE secteur_code = 1',

        'GROUPBYCLAUSE':'GROUP BY uai_dger',

            'IDOURSIN':'uai_dgerinsee_resplegal filiere_codesecteur_pro_codeoption_code'}

img = wms.getmap(layers=layers,

styles=styles, bbox=bbox,

    size=(1197, 859),

format='image/jpeg', srs='EPSG:4326', custom = custom )

Alternatively, could use the same implementation as WCS. To decide.

in util.py/testXMLValue, val.text.strip() throws an error on empty Element

for example,
< Abstract />

Traceback (most recent call last):
File "/home/admin/morges/buildout/eggs/c2cgeoportal-1.2-py2.6.egg/c2cgeoportal/views/entry.py", line 37, in _wms_getcap
wms = WebMapService(url, version='1.1.1')
File "/home/admin/morges/OWSLib/owslib/wms.py", line 86, in init
self._buildMetadata(parse_remote_metadata)
File "/home/admin/morges/OWSLib/owslib/wms.py", line 126, in _buildMetadata
gather_layers(caps, None)
File "/home/admin/morges/OWSLib/owslib/wms.py", line 120, in gather_layers
cm = ContentMetadata(elem, parent=parent_metadata, index=index+1, parse_remote_metadata=parse_remote_metadata)
File "/home/admin/morges/OWSLib/owslib/wms.py", line 489, in init
self.layers.append(ContentMetadata(child, self))
File "/home/admin/morges/OWSLib/owslib/wms.py", line 340, in init
self.abstract = testXMLValue(elem.find('Abstract'))
File "/home/admin/morges/OWSLib/owslib/util.py", line 148, in testXMLValue
return val.text.strip()
[Fri Dec 07 12:18:50 2012] [error] AttributeError: 'NoneType' object has no attribute 'strip'

OWSLib can't open the CWIC CSW

When I try to open NASA's CWIC CSW endpoint:
http://cwic.csiss.gmu.edu/cwicv1/discovery
listed at on the CEOS CWIC page, I get an error:

endpoint = 'http://cwic.csiss.gmu.edu/cwicv1/discovery'  # CWIC
csw = CatalogueServiceWeb(endpoint,timeout=60)

ExceptionReport: 'REQUEST_EXCEPTION: UNRECOGNIZED_REQUEST - Only GetRecords and GetRecordById supported for HTTP POST method.'

I'm guessing this isn't really an OWSlib issue, but more a provider issue, right?
Can you tell what the CWIC folks would need to fix to have OWSlib work with this CSW?

Thanks,
Rich

update order of XML library setting in owslib/etree.py

Currently, XML library loading in owslib is wrapped in [https://sourceforge.net/apps/trac/owslib/browser/trunk/owslib/etree.py owslib/etree.py], which sets the appropriate library according to what the wrapper finds for python XML libs via try/except with imports. Calling modules always see owslib.etree as a result.

The current behaviour of [https://sourceforge.net/apps/trac/owslib/browser/trunk/owslib/etree.py owslib/etree.py] is as follows:

  • try to load elementtree.!ElementTree and patch namespaces
  • if that fails, try to load xml.etree.!ElementTree and patch namespaces
  • if that fails, try to load lxml.etree
  • if that fails, raise error

I propose we reverse this order so that lxml.etree is looked for first, then xml.etree.!ElementTree, then elementtree.!ElementTree. This would ensure that lxml.etree would be loaded first to take advantage of features of lxml (which may not be in owslib, but the calling app[s] use/call), and elementtree.!ElementTree would be called as the last resort.

WMS should support vendor specific parameters

See patch submitted by Servais Nabil

I would like to suggest 2 patchs. The first is for supporting custom parameters of WMS, I don't know if it's normalize by OGC, but it's supported by Mapserver.

For exemple I have this request in openlayers:

http://wmshost/cgi-bin/xyea?LAYERS=oursindep%2Cetablissement&FORMAT=jpg&IDOURSIN=%20uai_dger%7C%7Cinsee_resplegal%20%7C%7Cfiliere_code%7C%7Csecteur_pro_code%7C%7Coption_code&GROUPBYCLAUSE=%20GROUP%20BY%20%20uai_dger&WHERECLAUSE=%20WHERE%20secteur_code%20%3D%201&GEOMSUFFIXE=_rel&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A27572&BBOX=-679807.84,1230100.62,1925309.84,2987770.38&WIDTH=996&HEIGHT=672 And this is the request with my owslib patched :

url_wms = ' http://wmshost/cgi-bin/xyea' layers = [ 'oursindep', 'etablissement', 'responsables_legaux', 'regions']

    bbox = (-10.900634765625, 36.857250976562, 15.400634765625, 55.742749023437)

styles = custom = {'WHERECLAUSE':'WHERE secteur_code = 1',

        'GROUPBYCLAUSE':'GROUP BY uai_dger',

            'IDOURSIN':'uai_dgerinsee_resplegal filiere_codesecteur_pro_codeoption_code'}

img = wms.getmap(layers=layers,

styles=styles, bbox=bbox,

    size=(1197, 859),

format='image/jpeg', srs='EPSG:4326', custom = custom )

Alternatively, could use the same implementation as WCS. To decide.

Handle CSV response format from SOS

Currently as described in #5 it seems that SOS get_records requires an XML response, and a request for a non-XML response, such as the "text/csv" response below, fails:

from owslib.sos import SensorObservationService
sos_endpoint = 'http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?service=SOS&request=GetCapabilities&version=1.0.0'
coops = SensorObservationService(sos_endpoint)
print coops.get_operation_by_name('getobservation').parameters['responseFormat']['values']

returns

['text/csv',
 'text/tab-separated-values',
 'text/xml;schema="ioos/0.6.1"',
 'application/ioos+xml;version=0.6.1',
 'application/vnd.google-earth.kml+xml']

but then

response = coops.get_observation(offerings=['urn:ioos:station:NOAA.NOS.CO-OPS:8447930'],
                                 responseFormat='text/csv',
                                 observedProperties=['water_surface_height_above_reference_datum'],
                                 eventTime='2013-06-13T00:00:00Z/2013-06-14T00:00:00Z')

returns

File "<string>", line unknown
XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1

WCS Should check for ServiceExceptions

Before parsing it as a valid GetCapabilities record.

Using owslib 0.5 installed from pypi.

  File "/home/tkralidi/geonode/geonode/layers/models.py", line 650, in geoserver_post_save
    links = wcs_links(settings.GEOSERVER_BASE_URL + 'wcs?', instance.typename)
  File "/home/tkralidi/geonode/geonode/layers/ows.py", line 15, in wcs_links
    wcs = WebCoverageService(wcs_url, version=version)
  File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/wcs.py", line 39, in WebCoverageService
    return wcs100.WebCoverageService_1_0_0.__new__(wcs100.WebCoverageService_1_0_0, url, xml, cookies)
  File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/coverage/wcsBase.py", line 34, in __new__
    obj.__init__(url, xml, cookies)
  File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/coverage/wcs100.py", line 51, in __init__
    self.identification=ServiceIdentification(subelem)                               
  File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/coverage/wcs100.py", line 184, in __init__
    self.service = testXMLValue(elem.find(ns('name')))
AttributeError: 'NoneType' object has no attribute 'find'

DeprecationWarning in WCS : object.__new__() takes no parameters

We are using the library successfully with Geoserver, but get the following annoying warning when calling !WebCoverageService?(): /usr/local/lib/python2.6/dist-packages/OWSLib-0.3.2beta-py2.6.egg

Python 2.6 raises a deprecation warning.

/owslib/coverage/wcsBase.py:33:

!DeprecationWarning?: object.new() takes no parameters obj=object.new(self, url, xml ,cookies) Fixing this was a simple matter of removing those arguments (as suggested in the warning). I have attached the updated version of wcsBase.py for your consideration. We are using OWSLib from the repository with SVN revision number 1672 and Python version 2.6x

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.