Skip to content
Commits on Source (4)
......@@ -68,4 +68,4 @@ Authors
* Vincent Schut
* Alan D.
* grovduck
* Dan Little
* Dan "Ducky" Little
Changes
=======
1.0.15 (2019-01-27)
-------------------
- Google cloud storage support was *not* in fact added in 1.0.14, but is
present in 1.0.15.
1.0.14 (2019-01-22)
-------------------
......
rasterio (1.0.15-1) unstable; urgency=medium
* Team upload.
* New upstream release.
-- Bas Couwenberg <sebastic@debian.org> Mon, 28 Jan 2019 07:21:11 +0100
rasterio (1.0.14-1) unstable; urgency=medium
* Team upload.
......
......@@ -42,7 +42,7 @@ import rasterio.path
__all__ = ['band', 'open', 'pad', 'Env']
__version__ = "1.0.14"
__version__ = "1.0.15"
__gdal_version__ = gdal_version()
# Rasterio attaches NullHandler to the 'rasterio' logger and its
......
......@@ -114,9 +114,12 @@ cdef class _CRS(object):
exc_wrap_ogrerr(OSRMorphFromESRI(osr))
if OSRAutoIdentifyEPSG(osr) == 0:
epsg_code = OSRGetAuthorityCode(osr, NULL)
if epsg_code != NULL:
return int(epsg_code.decode('utf-8'))
else:
return None
else:
return None
finally:
_safe_osr_release(osr)
......
......@@ -18,13 +18,14 @@ SCHEMES = {
'tar': 'tar',
'zip': 'zip',
'file': 'file',
'oss': 'oss'
'oss': 'oss',
'gs': 'gs',
}
CURLSCHEMES = set([k for k, v in SCHEMES.items() if v == 'curl'])
# TODO: extend for other cloud plaforms.
REMOTESCHEMES = set([k for k, v in SCHEMES.items() if v in ('curl', 's3', 'oss')])
REMOTESCHEMES = set([k for k, v in SCHEMES.items() if v in ('curl', 's3', 'oss', 'gs')])
class Path(object):
......
......@@ -92,8 +92,8 @@ def info(ctx, input, aspect, indent, namespace, meta_member, verbose, bidx,
if gcps:
info['gcps'] = {'points': [p.asdict() for p in gcps]}
if crs:
epsg = crs.to_epsg()
if gcps_crs:
epsg = gcps_crs.to_epsg()
if epsg:
info['gcps']['crs'] = 'EPSG:{}'.format(epsg)
else:
......
......@@ -318,4 +318,51 @@ class OSSSession(Session):
return {k.upper(): v for k, v in self.credentials.items()}
class GSSession(Session):
"""Configures access to secured resources stored in Google Cloud Storage
"""
def __init__(self, google_application_credentials=None):
"""Create new Google Cloude Storage session
Parameters
----------
google_application_credentials: string
Path to the google application credentials JSON file.
"""
self._creds = {}
if google_application_credentials is not None:
self._creds['google_application_credentials'] = google_application_credentials
@classmethod
def hascreds(cls, config):
"""Determine if the given configuration has proper credentials
Parameters
----------
cls : class
A Session class.
config : dict
GDAL configuration as a dict.
Returns
-------
bool
"""
return 'GOOGLE_APPLICATION_CREDENTIALS' in config
@property
def credentials(self):
"""The session credentials as a dict"""
return self._creds
def get_credential_options(self):
"""Get credentials as GDAL configuration options
Returns
-------
dict
"""
return {k.upper(): v for k, v in self.credentials.items()}
......@@ -2,7 +2,7 @@
import pytest
from rasterio.session import DummySession, AWSSession, Session, OSSSession
from rasterio.session import DummySession, AWSSession, Session, OSSSession, GSSession
def test_dummy_session():
......@@ -133,3 +133,10 @@ def test_session_factory_oss_kwargs():
assert isinstance(sesh, OSSSession)
assert sesh.get_credential_options()['OSS_ACCESS_KEY_ID'] == 'foo'
assert sesh.get_credential_options()['OSS_SECRET_ACCESS_KEY'] == 'bar'
def test_gs_session_class():
"""GSSession works"""
gs_session = GSSession(
google_application_credentials='foo')
assert gs_session._creds
assert gs_session.get_credential_options()['GOOGLE_APPLICATION_CREDENTIALS'] == 'foo'