This is an automated email from the git hooks/post-receive script. johanvdw-guest pushed a commit to branch master in repository fiona.
commit d9dc8486c70fec1ff16d69d7d8440facb6d2b408 Author: Johan Van de Wauw <johan.vandew...@gmail.com> Date: Wed Nov 5 18:18:53 2014 +0100 Imported Upstream version 1.4.8 --- CHANGES.txt | 4 ++++ fiona/__init__.py | 2 +- fiona/collection.py | 8 ++++++++ fiona/ogrext.pyx | 15 +++++++++++++++ tests/test_collection.py | 4 ++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 45a5159..0b5bb86 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,10 @@ Changes ======= +1.4.8 (2014-11-02) +------------------ +- Add missing crs_wkt property as in Rasterio (#182). + 1.4.7 (2014-10-28) ------------------ - Fix setting of CRS from EPSG codes (#149). diff --git a/fiona/__init__.py b/fiona/__init__.py index 20ea1c2..2bd2552 100644 --- a/fiona/__init__.py +++ b/fiona/__init__.py @@ -63,7 +63,7 @@ writing modes) flush contents to disk when their ``with`` blocks end. """ __all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width'] -__version__ = "1.4.7" +__version__ = "1.4.8" import logging import os diff --git a/fiona/collection.py b/fiona/collection.py index 64c1a29..02a0e61 100644 --- a/fiona/collection.py +++ b/fiona/collection.py @@ -72,6 +72,7 @@ class Collection(object): self._driver = None self._schema = None self._crs = None + self._crs_wkt = None self.env = None self.path = vsi_path(path, vsi, archive) @@ -187,6 +188,13 @@ class Collection(object): return self._crs @property + def crs_wkt(self): + """Returns a WKT string.""" + if self._crs_wkt is None and self.mode in ("a", "r") and self.session: + self._crs_wkt = self.session.get_crs_wkt() + return self._crs_wkt + + @property def meta(self): """Returns a mapping with the driver, schema, and crs properties.""" return { diff --git a/fiona/ogrext.pyx b/fiona/ogrext.pyx index f7e1ab1..769c636 100644 --- a/fiona/ogrext.pyx +++ b/fiona/ogrext.pyx @@ -541,6 +541,21 @@ cdef class Session: log.debug("Projection not found (cogr_crs was NULL)") return crs + def get_crs_wkt(self): + cdef char *proj_c = NULL + if self.cogr_layer == NULL: + raise ValueError("Null layer") + cogr_crs = ograpi.OGR_L_GetSpatialRef(self.cogr_layer) + if cogr_crs is not NULL: + log.debug("Got coordinate system") + ograpi.OSRExportToWkt(cogr_crs, &proj_c) + if proj_c == NULL: + raise ValueError("Null projection") + proj_b = proj_c + crs_wkt = proj_b.decode('utf-8') + ograpi.CPLFree(proj_c) + return crs_wkt + def get_extent(self): if self.cogr_layer == NULL: raise ValueError("Null layer") diff --git a/tests/test_collection.py b/tests/test_collection.py index 3fff4d0..128bcec 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -156,6 +156,10 @@ class ReadingTest(unittest.TestCase): crs = self.c.crs self.failUnlessEqual(crs['init'], 'epsg:4326') + def test_crs_wkt(self): + crs = self.c.crs_wkt + self.failUnless(crs.startswith('GEOGCS["GCS_WGS_1984"')) + def test_closed_crs(self): # Crs is lazy too, never computed in this case. TODO? self.c.close() -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/fiona.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel