Skip to content
Commits on Source (4)
Changes
=======
1.0.17 (2019-02-05)
-------------------
- Fix a regression in evaluation of CRS equality (#1620).
1.0.16 (2019-02-04)
-------------------
......
rasterio (1.0.17-1) unstable; urgency=medium
* Team upload.
* New upstream release.
-- Bas Couwenberg <sebastic@debian.org> Wed, 06 Feb 2019 07:41:11 +0100
rasterio (1.0.16-1) unstable; urgency=medium
* Team upload.
......
......@@ -42,7 +42,7 @@ import rasterio.path
__all__ = ['band', 'open', 'pad', 'Env']
__version__ = "1.0.16"
__version__ = "1.0.17"
__gdal_version__ = gdal_version()
# Rasterio attaches NullHandler to the 'rasterio' logger and its
......
......@@ -58,6 +58,13 @@ cdef class _CRS(object):
cdef OGRSpatialReferenceH osr_o = NULL
cdef _CRS crs_o = other
epsg_s = self.to_epsg()
epsg_o = other.to_epsg()
if epsg_s is not None and epsg_o is not None and epsg_s == epsg_o:
return True
else:
try:
osr_s = exc_wrap_pointer(OSRClone(self._osr))
exc_wrap_ogrerr(OSRMorphFromESRI(osr_s))
......@@ -252,6 +259,42 @@ cdef class _CRS(object):
else:
return obj
@staticmethod
def from_user_input(text, morph_from_esri_dialect=False):
"""Make a CRS from a WKT string
Parameters
----------
text : str
User input text of many different kinds.
morph_from_esri_dialect : bool, optional
If True, items in the input using Esri's dialect of WKT
will be replaced by OGC standard equivalents.
Returns
-------
CRS
"""
cdef const char *text_c = NULL
if not isinstance(text, string_types):
raise ValueError("A string is expected")
text_b = text.encode('utf-8')
text_c = text_b
cdef _CRS obj = _CRS.__new__(_CRS)
try:
errcode = exc_wrap_ogrerr(OSRSetFromUserInput(obj._osr, text_c))
if morph_from_esri_dialect:
exc_wrap_ogrerr(OSRMorphFromESRI(obj._osr))
except CPLE_BaseError as exc:
raise CRSError("The WKT could not be parsed. {}".format(exc))
else:
return obj
def to_dict(self):
"""Convert CRS to a PROJ4 dict
......
......@@ -421,6 +421,8 @@ class CRS(collections.Mapping):
elif isinstance(value, dict):
return cls(**value)
elif isinstance(value, string_types):
return cls.from_string(value, morph_from_esri_dialect=morph_from_esri_dialect)
obj = cls()
obj._crs = _CRS.from_user_input(value, morph_from_esri_dialect=morph_from_esri_dialect)
return obj
else:
raise CRSError("CRS is invalid: {!r}".format(value))
......@@ -426,3 +426,8 @@ def test_issue1609_wktext_b():
def test_empty_crs_str():
"""str(CRS()) should be empty string"""
assert str(CRS()) == ''
def test_issue1620():
"""Different forms of EPSG:3857 are equal"""
assert CRS.from_wkt('PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]]') == CRS.from_dict(init='epsg:3857')