diff -Nru fiona-1.8.6/appveyor.yml fiona-1.8.11/appveyor.yml --- fiona-1.8.6/appveyor.yml 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/appveyor.yml 2019-11-08 02:24:40.000000000 +0000 @@ -125,7 +125,7 @@ # install the wheel - ps: python -m pip install --upgrade pip - - ps: python -m pip install --force-reinstall --ignore-installed (gci dist\*.whl | % { "$_" }) + - ps: python -m pip install (gci dist\*.whl | % { "$_" }) - ps: move fiona fiona.build diff -Nru fiona-1.8.6/CHANGES.txt fiona-1.8.11/CHANGES.txt --- fiona-1.8.6/CHANGES.txt 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/CHANGES.txt 2019-11-08 02:24:40.000000000 +0000 @@ -3,6 +3,79 @@ All issue numbers are relative to https://github.com/Toblerity/Fiona/issues. +1.8.11 (2019-11-07) +------------------- + +- Fix an access violation on Windows (#826). + +1.8.10 (2019-11-07) +------------------- + +Deprecations: + +- Use of vfs keyword argument with open or listlayers has been previously noted + as deprecated, but now triggers a deprecation warning. + +Bug fixes: + +- fiona.open() can now create new datasets using CRS URNs (#823). +- listlayers() now accepts file and Path objects, like open() (#825). +- Use new set_proj_search_path() function to set the PROJ data search path. For + GDAL versions before 3.0 this sets the PROJ_LIB environment variable. For + GDAL version 3.0 this calls OSRSetPROJSearchPaths(), which overrides + PROJ_LIB. +- Remove old and unused _drivers extension module. +- Check for header.dxf file instead of pcs.csv when looking for installed GDAL + data. The latter is gone with GDAL 3.0 but the former remains (#818). + +1.8.9.post2 (2019-10-22) +------------------------ + +- The 1.8.9.post1 release introduced a bug affecting builds of the package from + a source distribution using GDAL 2.x. This bug has been fixed in commit + 960568d. + +1.8.9.post1 (2019-10-22) +------------------------ + +- A change has been made to the package setup script so that the shim module + for GDAL 3 is used when building the package from a source distribution. + There are no other changes to the package. + +1.8.9 (2019-10-21) +------------------ + +- A shim module and support for GDAL 3.0 has been added. The package can now be + built and used with GDAL 3.0 and PROJ 6.1 or 6.2. Note that the 1.8.9 wheels + we will upload to PyPI will contain GDAL 2.4.2 and PROJ 4.9.3 as in the 1.8.8 + wheels. + +1.8.8 (2019-09-25) +------------------ + +- The schema of geopackage files with a geometry type code of 3000 could not be + reported using Fiona 1.8.7. This bug is fixed. + +1.8.7 (2019-09-24) +------------------ + +Bug fixes: + +- Regression in handling of polygons with M values noted under version 1.8.5 + below was in fact not fixed then (see new report #789), but is fixed in + version 1.8.7. +- Windows filenames containing "!" are now parsed correctly, fixing issue #742. + +Upcoming changes: + +- In version 1.9.0, the objects yielded when a Collection is iterated will be + mutable mappings but will no longer be instances of Python's dict. Version + 1.9 is intended to be backwards compatible with 1.8 except where user code + tests `isinstance(feature, dict)`. In version 2.0 the new Feature, Geometry, + and Properties classes will become immutable mappings. See + https://github.com/Toblerity/fiona-rfc/blob/master/rfc/0001-fiona-2-0-changes.md + for more discussion of the upcoming changes for version 2.0. + 1.8.6 (2019-03-18) ------------------ diff -Nru fiona-1.8.6/debian/changelog fiona-1.8.11/debian/changelog --- fiona-1.8.6/debian/changelog 2019-07-14 14:00:00.000000000 +0000 +++ fiona-1.8.11/debian/changelog 2019-11-25 13:00:00.000000000 +0000 @@ -1,14 +1,73 @@ -fiona (1.8.6-1~bionic1) bionic; urgency=medium +fiona (1.8.11-1~bionic0) bionic; urgency=medium - * No change rebuild for GDAL 2.4.2 transition. + * No change rebuild for Bionic. - -- Angelos Tzotsos Sun, 14 Jul 2019 16:00:00 +0200 + -- Angelos Tzotsos Mon, 25 Nov 2019 15:00:00 +0200 -fiona (1.8.6-1~bionic0) bionic; urgency=medium +fiona (1.8.11-1) unstable; urgency=medium - * No change rebuild for Bionic. + * Team upload. + * New upstream release. + * Refresh patches. + + -- Bas Couwenberg Fri, 08 Nov 2019 06:39:34 +0100 + +fiona (1.8.9-2) unstable; urgency=medium + + * Team upload. + + [ Bas Couwenberg ] + * Apply patch by Matthias Klose to fix FTBFS with multiple python3 versions. + (closes: #943513) + + [ Matthias Klose ] + * Call python{version} -m sphinx to build the documentation. + * Build the docs in a temporary directory. + + -- Bas Couwenberg Fri, 25 Oct 2019 19:55:22 +0200 + +fiona (1.8.9-1) unstable; urgency=medium + + * Team upload. + * New upstream release. + * Bump Standards-Version to 4.4.1, no changes. + * Drop gdal3.patch, fixed upstream. + * Refresh patches. + * Add patch to fix clean target. + + -- Bas Couwenberg Tue, 22 Oct 2019 06:06:34 +0200 + +fiona (1.8.8-1) unstable; urgency=medium + + * Team upload. + * New upstream release. + + -- Bas Couwenberg Fri, 27 Sep 2019 07:37:43 +0200 + +fiona (1.8.6-3) unstable; urgency=medium + + * Team upload. + * Add patch to fix FTBFS with GDAL 3. + (closes: #939872) + + -- Bas Couwenberg Wed, 11 Sep 2019 09:39:15 +0200 + +fiona (1.8.6-2) unstable; urgency=medium + + * Team upload. + * Bump Standards-Version to 4.4.0, no changes. + * Drop Python 2 support. + + -- Bas Couwenberg Sun, 21 Jul 2019 19:51:35 +0200 + +fiona (1.8.6-1) unstable; urgency=medium + + * Team upload. + * Update dh_install override to use --list-missing. + * Update gbp.conf to use --source-only-changes by default. + * Move from experimental to unstable. - -- Angelos Tzotsos Thu, 02 May 2019 12:00:00 +0200 + -- Bas Couwenberg Sun, 07 Jul 2019 08:00:48 +0200 fiona (1.8.6-1~exp1) experimental; urgency=medium diff -Nru fiona-1.8.6/debian/control fiona-1.8.11/debian/control --- fiona-1.8.6/debian/control 2019-03-16 07:46:46.000000000 +0000 +++ fiona-1.8.11/debian/control 2019-10-22 04:24:10.000000000 +0000 @@ -7,56 +7,24 @@ dh-python, gdal-bin, libgdal-dev, - cython (>= 0.21), cython3 (>= 0.21), - python-all, python3-all, - python-all-dev, python3-all-dev, - python-attr, python3-attr, - python-boto3, python3-boto3, - python-click-plugins, python3-click-plugins, - python-cligj, python3-cligj, - python-enum34, - python-mock, python3-mock, - python-munch, python3-munch, - python-pytest, python3-pytest, - python-setuptools, python3-setuptools, - python-six, python3-six, - python-sphinx, python3-sphinx -Standards-Version: 4.3.0 +Standards-Version: 4.4.1 Vcs-Browser: https://salsa.debian.org/debian-gis-team/fiona Vcs-Git: https://salsa.debian.org/debian-gis-team/fiona.git Homepage: https://github.com/Toblerity/Fiona -Package: python-fiona -Architecture: any -Depends: ${python:Depends}, - ${misc:Depends}, - ${shlibs:Depends} -Suggests: fiona-doc -Description: Python API for reading/writing vector geospatial data - Fiona is a Python wrapper around the OGR vector data abstraction library. - Fiona is designed to be simple and dependable. It focuses on reading - and writing data in standard Python IO style and relies upon familiar - Python types and protocols such as files, dictionaries, mappings, and - iterators instead of classes specific to OGR. Fiona can read and write - real-world data using multi-layered GIS formats and zipped virtual - file systems and integrates readily with other Python GIS packages - such as pyproj, Rtree, and Shapely. - . - This package provides the Python 2 API - Package: python3-fiona Architecture: any Depends: ${python3:Depends}, @@ -79,9 +47,9 @@ Architecture: any Section: science Depends: python3-fiona (= ${binary:Version}), + python3-click-plugins, ${python3:Depends}, - ${misc:Depends}, - python3-click-plugins + ${misc:Depends} Suggests: fiona-doc Description: Command line tool for reading/writing vector geospatial data Fiona is a Python wrapper around the OGR vector data abstraction library. diff -Nru fiona-1.8.6/debian/gbp.conf fiona-1.8.11/debian/gbp.conf --- fiona-1.8.6/debian/gbp.conf 2018-07-11 13:17:44.000000000 +0000 +++ fiona-1.8.11/debian/gbp.conf 2019-10-22 04:24:10.000000000 +0000 @@ -14,3 +14,6 @@ # Always use pristine-tar. pristine-tar = True + +[buildpackage] +pbuilder-options = --source-only-changes diff -Nru fiona-1.8.6/debian/patches/0001-Rename-fio-command-to-fiona-to-avoid-name-clash.patch fiona-1.8.11/debian/patches/0001-Rename-fio-command-to-fiona-to-avoid-name-clash.patch --- fiona-1.8.6/debian/patches/0001-Rename-fio-command-to-fiona-to-avoid-name-clash.patch 2019-03-16 07:33:36.000000000 +0000 +++ fiona-1.8.11/debian/patches/0001-Rename-fio-command-to-fiona-to-avoid-name-clash.patch 2019-11-08 05:38:55.000000000 +0000 @@ -9,7 +9,7 @@ --- a/setup.py +++ b/setup.py -@@ -309,7 +309,7 @@ setup_args = dict( +@@ -317,7 +317,7 @@ setup_args = dict( packages=['fiona', 'fiona.fio'], entry_points=''' [console_scripts] diff -Nru fiona-1.8.6/debian/patches/0006-Remove-unknown-distribution-options.patch fiona-1.8.11/debian/patches/0006-Remove-unknown-distribution-options.patch --- fiona-1.8.6/debian/patches/0006-Remove-unknown-distribution-options.patch 2019-03-16 07:33:40.000000000 +0000 +++ fiona-1.8.11/debian/patches/0006-Remove-unknown-distribution-options.patch 2019-11-08 05:38:57.000000000 +0000 @@ -6,7 +6,7 @@ --- a/setup.py +++ b/setup.py -@@ -291,11 +291,8 @@ extras_require['all'] = list(set(it.chai +@@ -299,11 +299,8 @@ extras_require['all'] = list(set(it.chai setup_args = dict( cmdclass={'sdist': sdist_multi_gdal}, diff -Nru fiona-1.8.6/debian/patches/clean-target.patch fiona-1.8.11/debian/patches/clean-target.patch --- fiona-1.8.6/debian/patches/clean-target.patch 1970-01-01 00:00:00.000000000 +0000 +++ fiona-1.8.11/debian/patches/clean-target.patch 2019-10-22 04:24:10.000000000 +0000 @@ -0,0 +1,15 @@ +Description: Fix clean target. + gdal_*_version undefined for `setup.py clean`. +Author: Bas Couwenberg + +--- a/setup.py ++++ b/setup.py +@@ -183,7 +183,7 @@ if 'clean' not in sys.argv: + gdal_major_version = int(gdal_version_parts[0]) + gdal_minor_version = int(gdal_version_parts[1]) + +-log.info("GDAL version major=%r minor=%r", gdal_major_version, gdal_minor_version) ++ log.info("GDAL version major=%r minor=%r", gdal_major_version, gdal_minor_version) + + ext_options = dict( + include_dirs=include_dirs, diff -Nru fiona-1.8.6/debian/patches/series fiona-1.8.11/debian/patches/series --- fiona-1.8.6/debian/patches/series 2018-07-11 13:17:44.000000000 +0000 +++ fiona-1.8.11/debian/patches/series 2019-10-22 04:24:10.000000000 +0000 @@ -1,3 +1,4 @@ 0001-Rename-fio-command-to-fiona-to-avoid-name-clash.patch 0002-Remove-outside-reference-possible-privacy-breach.patch 0006-Remove-unknown-distribution-options.patch +clean-target.patch diff -Nru fiona-1.8.6/debian/rules fiona-1.8.11/debian/rules --- fiona-1.8.6/debian/rules 2019-03-19 05:50:58.000000000 +0000 +++ fiona-1.8.11/debian/rules 2019-10-25 17:52:52.000000000 +0000 @@ -11,7 +11,7 @@ DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) export PYBUILD_NAME=fiona -export PYBUILD_AFTER_BUILD_python2 = PYTHONPATH={build_dir} http_proxy='127.0.0.1:9' /usr/share/sphinx/scripts/python2/sphinx-build -N -bhtml -D today="$(BUILD_DATE)" docs/ build/html +export PYBUILD_AFTER_BUILD_python3 = mkdir -p doc-build && cd doc-build && PYTHONPATH={build_dir} http_proxy='127.0.0.1:9' python{version} -m sphinx -N -bhtml -D today="$(BUILD_DATE)" ../docs/ ../build/html export PYBUILD_TEST_PYTEST=1 export PYBUILD_BEFORE_TEST=cp -r {dir}/tests {build_dir} export PYBUILD_AFTER_TEST=rm -rf {build_dir}/tests @@ -39,11 +39,12 @@ --ignore tests/test_vfs.py %: - dh $@ --with python2,python3,sphinxdoc --buildsystem pybuild + dh $@ --with python3,sphinxdoc --buildsystem pybuild override_dh_clean: dh_clean rm -rf fiona/*.so gdal-config.txt fiona/*.c VERSION.txt fiona/*.cpp Fiona.egg-info/ + rm -rf doc-build override_dh_auto_test: # Ignore test failures on problematic architectures only @@ -54,8 +55,7 @@ endif override_dh_install: - dh_install - rm -rf debian/python-fiona/usr/bin + dh_install --list-missing rm -rf debian/python3-fiona/usr/bin debian/fiona.1: diff -Nru fiona-1.8.6/fiona/collection.py fiona-1.8.11/fiona/collection.py --- fiona-1.8.6/fiona/collection.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/collection.py 2019-11-08 02:24:40.000000000 +0000 @@ -11,6 +11,7 @@ from fiona.ogrext import buffer_to_virtual_file, remove_virtual_file, GEOMETRY_TYPES from fiona.errors import (DriverError, SchemaError, CRSError, UnsupportedGeometryTypeError, DriverSupportError) from fiona.logutils import FieldSkipLogFilter +from fiona._crs import crs_to_wkt from fiona._env import get_gdal_release_name, get_gdal_version_tuple from fiona.env import env_ctx_if_needed from fiona.errors import FionaDeprecationWarning @@ -140,14 +141,8 @@ self._schema = schema self._check_schema_driver_support() - - if crs_wkt: - self._crs_wkt = crs_wkt - elif crs: - if 'init' in crs or 'proj' in crs or 'epsg' in crs.lower(): - self._crs = crs - else: - raise CRSError("crs lacks init or proj parameter") + if crs_wkt or crs: + self._crs_wkt = crs_to_wkt(crs_wkt or crs) self._driver = driver kwargs.update(encoding=encoding) diff -Nru fiona-1.8.6/fiona/_crs.pxd fiona-1.8.11/fiona/_crs.pxd --- fiona-1.8.6/fiona/_crs.pxd 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_crs.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -12,7 +12,6 @@ int OSRImportFromProj4 (OGRSpatialReferenceH srs, char *proj) int OSRSetFromUserInput (OGRSpatialReferenceH srs, char *input) int OSRAutoIdentifyEPSG (OGRSpatialReferenceH srs) - int OSRFixup(OGRSpatialReferenceH srs) const char * OSRGetAuthorityName (OGRSpatialReferenceH srs, const char *key) const char * OSRGetAuthorityCode (OGRSpatialReferenceH srs, const char *key) OGRSpatialReferenceH OSRNewSpatialReference (char *wkt) diff -Nru fiona-1.8.6/fiona/_crs.pyx fiona-1.8.11/fiona/_crs.pyx --- fiona-1.8.6/fiona/_crs.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_crs.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -10,28 +10,36 @@ from six import string_types from fiona cimport _cpl +from fiona._err cimport exc_wrap_pointer +from fiona._err import CPLE_BaseError +from fiona._shim cimport osr_get_name, osr_set_traditional_axis_mapping_strategy +from fiona.compat import DICT_TYPES from fiona.errors import CRSError logger = logging.getLogger(__name__) +cdef int OAMS_TRADITIONAL_GIS_ORDER = 0 + # Export a WKT string from input crs. def crs_to_wkt(crs): """Convert a Fiona CRS object to WKT format""" - cdef void *cogr_srs = NULL + cdef OGRSpatialReferenceH cogr_srs = NULL cdef char *proj_c = NULL - cogr_srs = OSRNewSpatialReference(NULL) - if cogr_srs == NULL: - raise CRSError("NULL spatial reference") + try: + cogr_srs = exc_wrap_pointer(OSRNewSpatialReference(NULL)) + except CPLE_BaseError as exc: + raise CRSError(u"{}".format(exc)) # First, check for CRS strings like "EPSG:3857". if isinstance(crs, string_types): proj_b = crs.encode('utf-8') proj_c = proj_b OSRSetFromUserInput(cogr_srs, proj_c) - elif isinstance(crs, dict): + + elif isinstance(crs, DICT_TYPES): # EPSG is a special case. init = crs.get('init') if init: @@ -53,18 +61,20 @@ proj_b = proj.encode('utf-8') proj_c = proj_b OSRImportFromProj4(cogr_srs, proj_c) - else: - raise ValueError("Invalid CRS") - # Fixup, export to WKT, and set the GDAL dataset's projection. - OSRFixup(cogr_srs) + else: + raise CRSError("Invalid input to create CRS: {}".format(crs)) + osr_set_traditional_axis_mapping_strategy(cogr_srs) OSRExportToWkt(cogr_srs, &proj_c) if proj_c == NULL: - raise CRSError("Null projection") + raise CRSError("Invalid input to create CRS: {}".format(crs)) proj_b = proj_c _cpl.CPLFree(proj_c) + if not proj_b: + raise CRSError("Invalid input to create CRS: {}".format(crs)) + return proj_b.decode('utf-8') diff -Nru fiona-1.8.6/fiona/_drivers.pyx fiona-1.8.11/fiona/_drivers.pyx --- fiona-1.8.6/fiona/_drivers.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_drivers.pyx 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -# The GDAL and OGR driver registry. -# GDAL driver management. - -from __future__ import absolute_import - -import os -import os.path -import logging -import sys - -from six import string_types - - -cdef extern from "cpl_conv.h": - void CPLFree (void *ptr) - void CPLSetThreadLocalConfigOption (char *key, char *val) - const char * CPLGetConfigOption ( const char *key, const char *default) - - -cdef extern from "cpl_error.h": - ctypedef void (*CPLErrorHandler)(int, int, const char*); - void CPLSetErrorHandler (CPLErrorHandler handler) - - -cdef extern from "gdal.h": - void GDALAllRegister() - void GDALDestroyDriverManager() - int GDALGetDriverCount() - void * GDALGetDriver(int i) - const char * GDALGetDriverShortName(void *driver) - const char * GDALGetDriverLongName(void *driver) - const char * GDALVersionInfo(const char *key) - - -cdef extern from "ogr_api.h": - void OGRRegisterDriver(void *driver) - void OGRDeregisterDriver(void *driver) - void OGRRegisterAll() - void OGRCleanupAll() - int OGRGetDriverCount() - void * OGRGetDriver(int i) - void * OGRGetDriverByName(const char *name) - const char * OGR_Dr_GetName(void *driver) - - -log = logging.getLogger(__name__) -class NullHandler(logging.Handler): - def emit(self, record): - pass -log.addHandler(NullHandler()) - - -level_map = { - 0: 0, - 1: logging.DEBUG, - 2: logging.WARNING, - 3: logging.ERROR, - 4: logging.CRITICAL } - -code_map = { - 0: 'CPLE_None', - 1: 'CPLE_AppDefined', - 2: 'CPLE_OutOfMemory', - 3: 'CPLE_FileIO', - 4: 'CPLE_OpenFailed', - 5: 'CPLE_IllegalArg', - 6: 'CPLE_NotSupported', - 7: 'CPLE_AssertionFailed', - 8: 'CPLE_NoWriteAccess', - 9: 'CPLE_UserInterrupt', - 10: 'CPLE_ObjectNull' -} - - -IF UNAME_SYSNAME == "Windows": - cdef void * __stdcall errorHandler(int eErrClass, int err_no, char *msg) with gil: - log.log(level_map[eErrClass], "%s in %s", code_map[err_no], msg) -ELSE: - cdef void * errorHandler(int eErrClass, int err_no, char *msg) with gil: - log.log(level_map[eErrClass], "%s in %s", code_map[err_no], msg) - - -def driver_count(): - return OGRGetDriverCount() - - -cdef class GDALEnv(object): - - cdef public object options - - def __init__(self, **options): - self.options = options.copy() - - def __enter__(self): - self.start() - return self - - def __exit__(self, exc_type=None, exc_val=None, exc_tb=None): - self.stop() - - def start(self): - cdef const char *key_c = NULL - cdef const char *val_c = NULL - - if GDALGetDriverCount() == 0: - GDALAllRegister() - if OGRGetDriverCount() == 0: - OGRRegisterAll() - CPLSetErrorHandler(errorHandler) - if OGRGetDriverCount() == 0: - raise ValueError("Drivers not registered") - - if 'GDAL_DATA' in os.environ: - log.debug("GDAL_DATA: %s", os.environ['GDAL_DATA']) - else: - # We will try a few well-known paths, starting with the - # official wheel path. - whl_datadir = os.path.abspath( - os.path.join(os.path.dirname(__file__), "gdal_data")) - fhs_share_datadir = os.path.join(sys.prefix, 'share/gdal') - - # Debian supports multiple GDAL installs. - gdal_release_name = GDALVersionInfo("RELEASE_NAME") - gdal_release_name = gdal_release_name.decode('utf-8') - deb_share_datadir = os.path.join( - fhs_share_datadir, - "{}.{}".format(*gdal_release_name.split('.')[:2])) - - # If we find GDAL data at the well-known paths, we will - # add a GDAL_DATA key to the config options dict. - if os.path.exists(os.path.join(whl_datadir, 'pcs.csv')): - log.debug("Set GDAL_DATA = %r", whl_datadir) - self.options['GDAL_DATA'] = whl_datadir - - elif os.path.exists(os.path.join(deb_share_datadir, 'pcs.csv')): - log.debug("Set GDAL_DATA = %r", deb_share_datadir) - self.options['GDAL_DATA'] = deb_share_datadir - - elif os.path.exists(os.path.join(fhs_share_datadir, 'pcs.csv')): - log.debug("Set GDAL_DATA = %r", fhs_share_datadir) - self.options['GDAL_DATA'] = fhs_share_datadir - - else: - log.warning("GDAL data files not located, GDAL_DATA not set") - - if 'PROJ_LIB' in os.environ: - log.debug("PROJ_LIB: %s", os.environ['PROJ_LIB']) - else: - whl_datadir = os.path.abspath( - os.path.join(os.path.dirname(__file__), "proj_data")) - share_datadir = os.path.join(sys.prefix, 'share/proj') - - if os.path.exists(whl_datadir): - log.debug("Set PROJ_LIB = %r", whl_datadir) - os.environ['PROJ_LIB'] = whl_datadir - - elif os.path.exists(share_datadir): - log.debug("Set PROJ_LIB = %r", share_datadir) - os.environ['PROJ_LIB'] = share_datadir - - else: - log.warning("PROJ data files not located, PROJ_LIB not set") - - for key, val in self.options.items(): - key_b = key.upper().encode('utf-8') - key_c = key_b - if isinstance(val, string_types): - val_b = val.encode('utf-8') - else: - val_b = ('ON' if val else 'OFF').encode('utf-8') - val_c = val_b - CPLSetThreadLocalConfigOption(key_c, val_c) - # Logging of config options has been disabled to prevent - # credential leakage and will be completely - # removed as soon as the Fiona driver environment and - # AWS authentication interactions are stable. - # log.debug("Option %s=%s", key, CPLGetConfigOption(key_c, NULL)) - return self - - def stop(self): - cdef const char *key_c = NULL - for key in self.options: - key_b = key.upper().encode('utf-8') - key_c = key_b - CPLSetThreadLocalConfigOption(key_c, NULL) - CPLSetErrorHandler(NULL) - - def drivers(self): - cdef void *drv = NULL - cdef const char *key = NULL - cdef const char *val = NULL - cdef int i - result = {} - for i in range(OGRGetDriverCount()): - drv = OGRGetDriver(i) - key = OGR_Dr_GetName(drv) - key_b = key - val = OGR_Dr_GetName(drv) - val_b = val - result[key_b.decode('utf-8')] = val_b.decode('utf-8') - return result diff -Nru fiona-1.8.6/fiona/env.py fiona-1.8.11/fiona/env.py --- fiona-1.8.6/fiona/env.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/env.py 2019-11-08 02:24:40.000000000 +0000 @@ -12,7 +12,8 @@ from fiona._env import ( GDALEnv, calc_gdal_version_num, get_gdal_version_num, get_gdal_config, - set_gdal_config, get_gdal_release_name, GDALDataFinder, PROJDataFinder) + set_gdal_config, get_gdal_release_name, GDALDataFinder, PROJDataFinder, + set_proj_data_search_path) from fiona.compat import getargspec from fiona.errors import EnvError, GDALVersionError from fiona.session import Session, DummySession @@ -586,7 +587,7 @@ # Patch the environment if needed, such as in the installed wheel case. -if 'GDAL_DATA' not in os.environ: +if "GDAL_DATA" not in os.environ: # See https://github.com/mapbox/rasterio/issues/1631. if GDALDataFinder().find_file("header.dxf"): @@ -599,15 +600,17 @@ os.environ['GDAL_DATA'] = path log.debug("GDAL_DATA not found in environment, set to %r.", path) -if 'PROJ_LIB' not in os.environ: - - # See https://github.com/mapbox/rasterio/issues/1631. - if PROJDataFinder().has_data(): - log.debug("PROJ data files are available at built-in paths") - - else: - path = PROJDataFinder().search() - - if path: - os.environ['PROJ_LIB'] = path - log.debug("PROJ data not found in environment, set to %r.", path) +if "PROJ_LIB" in os.environ: + path = os.environ["PROJ_LIB"] + set_proj_data_search_path(path) + +# See https://github.com/mapbox/rasterio/issues/1631. +elif PROJDataFinder().has_data(): + log.debug("PROJ data files are available at built-in paths") + +else: + path = PROJDataFinder().search() + + if path: + log.debug("PROJ data not found in environment, setting to %r.", path) + set_proj_data_search_path(path) diff -Nru fiona-1.8.6/fiona/_env.pyx fiona-1.8.11/fiona/_env.pyx --- fiona-1.8.6/fiona/_env.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_env.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -18,6 +18,7 @@ import threading from fiona._err cimport exc_wrap_int, exc_wrap_ogrerr +from fiona._shim cimport set_proj_search_path from fiona._err import CPLE_BaseError from fiona.errors import EnvError @@ -295,18 +296,18 @@ if prefix is None: prefix = __file__ datadir = os.path.abspath(os.path.join(os.path.dirname(prefix), "gdal_data")) - return datadir if os.path.exists(os.path.join(datadir, 'pcs.csv')) else None + return datadir if os.path.exists(os.path.join(datadir, 'header.dxf')) else None def search_prefix(self, prefix=sys.prefix): """Check sys.prefix location""" datadir = os.path.join(prefix, 'share', 'gdal') - return datadir if os.path.exists(os.path.join(datadir, 'pcs.csv')) else None + return datadir if os.path.exists(os.path.join(datadir, 'header.dxf')) else None def search_debian(self, prefix=sys.prefix): """Check Debian locations""" gdal_release_name = GDALVersionInfo("RELEASE_NAME") datadir = os.path.join(prefix, 'share', 'gdal', '{}.{}'.format(*gdal_release_name.split('.')[:2])) - return datadir if os.path.exists(os.path.join(datadir, 'pcs.csv')) else None + return datadir if os.path.exists(os.path.join(datadir, 'header.dxf')) else None class PROJDataFinder(object): @@ -326,7 +327,7 @@ cdef OGRSpatialReferenceH osr = OSRNewSpatialReference(NULL) try: - exc_wrap_ogrerr(exc_wrap_int(OSRImportFromProj4(osr, "+init=epsg:4326"))) + exc_wrap_ogrerr(exc_wrap_int(OSRImportFromEPSG(osr, 4326))) except CPLE_BaseError: return False else: @@ -402,6 +403,8 @@ if 'PROJ_LIB' in os.environ: log.debug("PROJ_LIB found in environment: %r.", os.environ['PROJ_LIB']) + path = os.environ["PROJ_LIB"] + set_proj_data_search_path(path) elif PROJDataFinder().has_data(): log.debug("PROJ data files are available at built-in paths") @@ -410,8 +413,8 @@ path = PROJDataFinder().search() if path: - os.environ['PROJ_LIB'] = path - log.debug("PROJ data not found in environment, set to %r.", path) + log.debug("PROJ data not found in environment, setting to %r.", path) + set_proj_data_search_path(path) if driver_count() == 0: CPLPopErrorHandler() @@ -447,3 +450,8 @@ result[key] = val return result + + +def set_proj_data_search_path(path): + """Set PROJ data search path""" + set_proj_search_path(path) diff -Nru fiona-1.8.6/fiona/gdal.pxi fiona-1.8.11/fiona/gdal.pxi --- fiona-1.8.6/fiona/gdal.pxi 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/gdal.pxi 2019-11-08 02:24:40.000000000 +0000 @@ -88,7 +88,6 @@ OGRSpatialReferenceH OSRClone(OGRSpatialReferenceH srs) int OSRExportToProj4(OGRSpatialReferenceH srs, char **params) int OSRExportToWkt(OGRSpatialReferenceH srs, char **params) - int OSRFixup(OGRSpatialReferenceH srs) const char *OSRGetAuthorityName(OGRSpatialReferenceH srs, const char *key) const char *OSRGetAuthorityCode(OGRSpatialReferenceH srs, const char *key) int OSRImportFromEPSG(OGRSpatialReferenceH srs, int code) diff -Nru fiona-1.8.6/fiona/_geometry.pyx fiona-1.8.11/fiona/_geometry.pyx --- fiona-1.8.6/fiona/_geometry.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_geometry.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -69,8 +69,10 @@ cdef object normalize_geometry_type_code(unsigned int code): """Normalize M geometry type codes.""" # Normalize 'M' types to 2D types. - if 2000 < code < 3000: + if 2000 <= code < 3000: code = code % 1000 + elif code == 3000: + code = 0 # Normalize 'ZM' types to 3D types. elif 3000 < code < 4000: code = (code % 1000) | 0x80000000 diff -Nru fiona-1.8.6/fiona/__init__.py fiona-1.8.11/fiona/__init__.py --- fiona-1.8.6/fiona/__init__.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/__init__.py 2019-11-08 02:24:40.000000000 +0000 @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -Fiona is OGR's neat, nimble, no-nonsense API. +Fiona is OGR's neat, nimble API. Fiona provides a minimal, uncomplicated Python interface to the open source GIS community's most trusted geodata access library and @@ -76,6 +76,7 @@ class Path: pass +# TODO: remove this? Or at least move it, flake8 complains. if sys.platform == "win32": libdir = os.path.join(os.path.dirname(__file__), ".libs") os.environ["PATH"] = os.environ["PATH"] + ";" + libdir @@ -101,7 +102,7 @@ __all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width'] -__version__ = "1.8.6" +__version__ = "1.8.11" __gdal_version__ = get_gdal_release_name() gdal_version = get_gdal_version_tuple() @@ -242,7 +243,7 @@ fp = str(fp) if vfs: - # Parse the vfs into a vsi and an archive path. + warnings.warn("The vfs keyword argument is deprecated. Instead, pass a URL that uses a zip or tar (for example) scheme.", FionaDeprecationWarning, stacklevel=2) path, scheme, archive = vfs_parse_paths(fp, vfs=vfs) path = ParsedPath(path, archive, scheme) else: @@ -267,6 +268,7 @@ return c + collection = open @@ -299,30 +301,47 @@ @ensure_env_with_credentials -def listlayers(path, vfs=None): - """Returns a list of layer names in their index order. +def listlayers(fp, vfs=None): + """List layer names in their index order + + Parameters + ---------- + fp : URI (str or pathlib.Path), or file-like object + A dataset resource identifier or file object. + vfs : str + This is a deprecated parameter. A URI scheme such as "zip://" + should be used instead. - The required ``path`` argument may be an absolute or relative file or - directory path. + Returns + ------- + list + A list of layer name strings. - A virtual filesystem can be specified. The ``vfs`` parameter may be - an Apache Commons VFS style string beginning with "zip://" or - "tar://"". In this case, the ``path`` must be an absolute path within - that container. """ - if not isinstance(path, string_types): - raise TypeError("invalid path: %r" % path) - if vfs and not isinstance(vfs, string_types): - raise TypeError("invalid vfs: %r" % vfs) - - if vfs: - pobj_vfs = parse_path(vfs) - pobj_path = parse_path(path) - pobj = ParsedPath(pobj_path.path, pobj_vfs.path, pobj_vfs.scheme) + if hasattr(fp, 'read'): + + with MemoryFile(fp.read()) as memfile: + return _listlayers(memfile.name) + else: - pobj = parse_path(path) - return _listlayers(vsi_path(pobj)) + if isinstance(fp, Path): + fp = str(fp) + + if not isinstance(fp, string_types): + raise TypeError("invalid path: %r" % fp) + if vfs and not isinstance(vfs, string_types): + raise TypeError("invalid vfs: %r" % vfs) + + if vfs: + warnings.warn("The vfs keyword argument is deprecated. Instead, pass a URL that uses a zip or tar (for example) scheme.", FionaDeprecationWarning, stacklevel=2) + pobj_vfs = parse_path(vfs) + pobj_path = parse_path(fp) + pobj = ParsedPath(pobj_path.path, pobj_vfs.path, pobj_vfs.scheme) + else: + pobj = parse_path(fp) + + return _listlayers(vsi_path(pobj)) def prop_width(val): diff -Nru fiona-1.8.6/fiona/ogrext1.pxd fiona-1.8.11/fiona/ogrext1.pxd --- fiona-1.8.6/fiona/ogrext1.pxd 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/ogrext1.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -151,13 +151,13 @@ void OSRCleanup () OGRSpatialReferenceH OSRClone (OGRSpatialReferenceH srs) + int OSRFixup (OGRSpatialReferenceH srs) int OSRExportToProj4 (OGRSpatialReferenceH srs, char **params) int OSRExportToWkt (OGRSpatialReferenceH srs, char **params) int OSRImportFromEPSG (OGRSpatialReferenceH, int code) int OSRImportFromProj4 (OGRSpatialReferenceH srs, const char *proj) int OSRSetFromUserInput (OGRSpatialReferenceH srs, const char *input) int OSRAutoIdentifyEPSG (OGRSpatialReferenceH srs) - int OSRFixup(OGRSpatialReferenceH srs) const char * OSRGetAuthorityName (OGRSpatialReferenceH srs, const char *key) const char * OSRGetAuthorityCode (OGRSpatialReferenceH srs, const char *key) OGRSpatialReferenceH OSRNewSpatialReference (char *wkt) diff -Nru fiona-1.8.6/fiona/ogrext2.pxd fiona-1.8.11/fiona/ogrext2.pxd --- fiona-1.8.6/fiona/ogrext2.pxd 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/ogrext2.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -219,13 +219,13 @@ void OSRCleanup () OGRSpatialReferenceH OSRClone (OGRSpatialReferenceH srs) + int OSRFixup (OGRSpatialReferenceH srs) int OSRExportToProj4 (OGRSpatialReferenceH srs, char **params) int OSRExportToWkt (OGRSpatialReferenceH srs, char **params) int OSRImportFromEPSG (OGRSpatialReferenceH, int code) int OSRImportFromProj4 (OGRSpatialReferenceH srs, const char *proj) int OSRSetFromUserInput (OGRSpatialReferenceH srs, const char *input) int OSRAutoIdentifyEPSG (OGRSpatialReferenceH srs) - int OSRFixup(OGRSpatialReferenceH srs) const char * OSRGetAuthorityName (OGRSpatialReferenceH srs, const char *key) const char * OSRGetAuthorityCode (OGRSpatialReferenceH srs, const char *key) OGRSpatialReferenceH OSRNewSpatialReference (char *wkt) diff -Nru fiona-1.8.6/fiona/ogrext3.pxd fiona-1.8.11/fiona/ogrext3.pxd --- fiona-1.8.6/fiona/ogrext3.pxd 1970-01-01 00:00:00.000000000 +0000 +++ fiona-1.8.11/fiona/ogrext3.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -0,0 +1,327 @@ +# Copyright (c) 2007, Sean C. Gillies +# All rights reserved. +# See ../LICENSE.txt + +from libc.stdio cimport FILE + + +cdef extern from "ogr_core.h": + + ctypedef int OGRErr + + ctypedef enum OGRwkbGeometryType: + wkbUnknown + wkbPoint + wkbLineString + wkbPolygon + wkbMultiPoint + wkbMultiLineString + wkbMultiPolygon + wkbGeometryCollection + wkbCircularString + wkbCompoundCurve + wkbCurvePolygon + wkbMultiCurve + wkbMultiSurface + wkbCurve + wkbSurface + wkbPolyhedralSurface + wkbTIN + wkbTriangle + wkbNone + wkbLinearRing + wkbCircularStringZ + wkbCompoundCurveZ + wkbCurvePolygonZ + wkbMultiCurveZ + wkbMultiSurfaceZ + wkbCurveZ + wkbSurfaceZ + wkbPolyhedralSurfaceZ + wkbTINZ + wkbTriangleZ + wkbPointM + wkbLineStringM + wkbPolygonM + wkbMultiPointM + wkbMultiLineStringM + wkbMultiPolygonM + wkbGeometryCollectionM + wkbCircularStringM + wkbCompoundCurveM + wkbCurvePolygonM + wkbMultiCurveM + wkbMultiSurfaceM + wkbCurveM + wkbSurfaceM + wkbPolyhedralSurfaceM + wkbTINM + wkbTriangleM + wkbPointZM + wkbLineStringZM + wkbPolygonZM + wkbMultiPointZM + wkbMultiLineStringZM + wkbMultiPolygonZM + wkbGeometryCollectionZM + wkbCircularStringZM + wkbCompoundCurveZM + wkbCurvePolygonZM + wkbMultiCurveZM + wkbMultiSurfaceZM + wkbCurveZM + wkbSurfaceZM + wkbPolyhedralSurfaceZM + wkbTINZM + wkbTriangleZM + wkbPoint25D + wkbLineString25D + wkbPolygon25D + wkbMultiPoint25D + wkbMultiLineString25D + wkbMultiPolygon25D + wkbGeometryCollection25D + + ctypedef enum OGRFieldType: + OFTInteger + OFTIntegerList + OFTReal + OFTRealList + OFTString + OFTStringList + OFTWideString + OFTWideStringList + OFTBinary + OFTDate + OFTTime + OFTDateTime + OFTInteger64 + OFTInteger64List + OFTMaxType + + ctypedef int OGRFieldSubType + cdef int OFSTNone = 0 + cdef int OFSTBoolean = 1 + cdef int OFSTInt16 = 2 + cdef int OFSTFloat32 = 3 + cdef int OFSTMaxSubType = 3 + + ctypedef struct OGREnvelope: + double MinX + double MaxX + double MinY + double MaxY + + char * OGRGeometryTypeToName(int) + + + char * ODsCCreateLayer = "CreateLayer" + char * ODsCDeleteLayer = "DeleteLayer" + + +cdef extern from "gdal.h": + char * GDALVersionInfo (char *pszRequest) + void * GDALGetDriverByName(const char * pszName) + void * GDALOpenEx(const char * pszFilename, + unsigned int nOpenFlags, + const char *const *papszAllowedDrivers, + const char *const *papszOpenOptions, + const char *const *papszSiblingFiles + ) + int GDAL_OF_UPDATE + int GDAL_OF_READONLY + int GDAL_OF_VECTOR + int GDAL_OF_VERBOSE_ERROR + int GDALDatasetGetLayerCount(void * hds) + void * GDALDatasetGetLayer(void * hDS, int iLayer) + void * GDALDatasetGetLayerByName(void * hDS, char * pszName) + void GDALClose(void * hDS) + void * GDALCreate(void * hDriver, + const char * pszFilename, + int nXSize, + int nYSize, + int nBands, + GDALDataType eBandType, + char ** papszOptions) + void * GDALDatasetCreateLayer(void * hDS, + const char * pszName, + void * hSpatialRef, + int eType, + char ** papszOptions) + int GDALDatasetDeleteLayer(void * hDS, int iLayer) + void GDALFlushCache(void * hDS) + char * GDALGetDriverShortName(void * hDriver) + char * GDALGetDatasetDriver (void * hDataset) + int GDALDeleteDataset(void * hDriver, const char * pszFilename) + OGRErr GDALDatasetStartTransaction (void * hDataset, int bForce) + OGRErr GDALDatasetCommitTransaction (void * hDataset) + OGRErr GDALDatasetRollbackTransaction (void * hDataset) + int GDALDatasetTestCapability (void * hDataset, char *) + + + ctypedef enum GDALDataType: + GDT_Unknown + GDT_Byte + GDT_UInt16 + GDT_Int16 + GDT_UInt32 + GDT_Int32 + GDT_Float32 + GDT_Float64 + GDT_CInt16 + GDT_CInt32 + GDT_CFloat32 + GDT_CFloat64 + GDT_TypeCount + +cdef extern from "gdal_version.h": + int GDAL_COMPUTE_VERSION(int maj, int min, int rev) + +cdef extern from "cpl_conv.h": + void * CPLMalloc (size_t) + void CPLFree (void *ptr) + void CPLSetThreadLocalConfigOption (char *key, char *val) + const char *CPLGetConfigOption (char *, char *) + + +cdef extern from "cpl_string.h": + char ** CSLAddNameValue (char **list, const char *name, const char *value) + char ** CSLSetNameValue (char **list, const char *name, const char *value) + void CSLDestroy (char **list) + char ** CSLAddString(char **list, const char *string) + + +cdef extern from "cpl_vsi.h" nogil: + ctypedef int vsi_l_offset + ctypedef FILE VSILFILE + + unsigned char *VSIGetMemFileBuffer(const char *path, + vsi_l_offset *data_len, + int take_ownership) + VSILFILE *VSIFileFromMemBuffer(const char *path, void *data, + vsi_l_offset data_len, int take_ownership) + VSILFILE* VSIFOpenL(const char *path, const char *mode) + int VSIFCloseL(VSILFILE *fp) + int VSIUnlink(const char *path) + + int VSIFFlushL(VSILFILE *fp) + size_t VSIFReadL(void *buffer, size_t nSize, size_t nCount, VSILFILE *fp) + int VSIFSeekL(VSILFILE *fp, vsi_l_offset nOffset, int nWhence) + vsi_l_offset VSIFTellL(VSILFILE *fp) + int VSIFTruncateL(VSILFILE *fp, vsi_l_offset nNewSize) + size_t VSIFWriteL(void *buffer, size_t nSize, size_t nCount, VSILFILE *fp) + int VSIUnlink (const char * pathname) + + +cdef extern from "ogr_srs_api.h": + + ctypedef void * OGRSpatialReferenceH + + void OSRCleanup () + OGRSpatialReferenceH OSRClone (OGRSpatialReferenceH srs) + int OSRExportToProj4 (OGRSpatialReferenceH srs, char **params) + int OSRExportToWkt (OGRSpatialReferenceH srs, char **params) + int OSRImportFromEPSG (OGRSpatialReferenceH, int code) + int OSRImportFromProj4 (OGRSpatialReferenceH srs, const char *proj) + int OSRSetFromUserInput (OGRSpatialReferenceH srs, const char *input) + int OSRAutoIdentifyEPSG (OGRSpatialReferenceH srs) + const char * OSRGetAuthorityName (OGRSpatialReferenceH srs, const char *key) + const char * OSRGetAuthorityCode (OGRSpatialReferenceH srs, const char *key) + OGRSpatialReferenceH OSRNewSpatialReference (char *wkt) + void OSRRelease (OGRSpatialReferenceH srs) + void * OCTNewCoordinateTransformation (OGRSpatialReferenceH source, OGRSpatialReferenceH dest) + void OCTDestroyCoordinateTransformation (void *source) + int OCTTransform (void *ct, int nCount, double *x, double *y, double *z) + +cdef extern from "ogr_api.h": + + const char * OGR_Dr_GetName (void *driver) + void * OGR_Dr_CreateDataSource (void *driver, const char *path, char **options) + int OGR_Dr_DeleteDataSource (void *driver, char *) + void * OGR_Dr_Open (void *driver, const char *path, int bupdate) + int OGR_Dr_TestCapability (void *driver, const char *) + int OGR_DS_DeleteLayer (void *datasource, int n) + void * OGR_F_Create (void *featuredefn) + void OGR_F_Destroy (void *feature) + long OGR_F_GetFID (void *feature) + int OGR_F_IsFieldSet (void *feature, int n) + int OGR_F_GetFieldAsDateTime (void *feature, int n, int *y, int *m, int *d, int *h, int *m, int *s, int *z) + double OGR_F_GetFieldAsDouble (void *feature, int n) + int OGR_F_GetFieldAsInteger (void *feature, int n) + char * OGR_F_GetFieldAsString (void *feature, int n) + unsigned char * OGR_F_GetFieldAsBinary(void *feature, int n, int *s) + int OGR_F_GetFieldCount (void *feature) + void * OGR_F_GetFieldDefnRef (void *feature, int n) + int OGR_F_GetFieldIndex (void *feature, char *name) + void * OGR_F_GetGeometryRef (void *feature) + void * OGR_F_StealGeometry (void *feature) + void OGR_F_SetFieldDateTime (void *feature, int n, int y, int m, int d, int hh, int mm, int ss, int tz) + void OGR_F_SetFieldDouble (void *feature, int n, double value) + void OGR_F_SetFieldInteger (void *feature, int n, int value) + void OGR_F_SetFieldString (void *feature, int n, char *value) + void OGR_F_SetFieldBinary (void *feature, int n, int l, unsigned char *value) + void OGR_F_SetFieldNull (void *feature, int n) # new in GDAL 2.2 + int OGR_F_SetGeometryDirectly (void *feature, void *geometry) + void * OGR_FD_Create (char *name) + int OGR_FD_GetFieldCount (void *featuredefn) + void * OGR_FD_GetFieldDefn (void *featuredefn, int n) + int OGR_FD_GetGeomType (void *featuredefn) + char * OGR_FD_GetName (void *featuredefn) + void * OGR_Fld_Create (char *name, OGRFieldType fieldtype) + void OGR_Fld_Destroy (void *fielddefn) + char * OGR_Fld_GetNameRef (void *fielddefn) + int OGR_Fld_GetPrecision (void *fielddefn) + int OGR_Fld_GetType (void *fielddefn) + int OGR_Fld_GetWidth (void *fielddefn) + void OGR_Fld_Set (void *fielddefn, char *name, int fieldtype, int width, int precision, int justification) + void OGR_Fld_SetPrecision (void *fielddefn, int n) + void OGR_Fld_SetWidth (void *fielddefn, int n) + OGRFieldSubType OGR_Fld_GetSubType(void *fielddefn) + void OGR_Fld_SetSubType(void *fielddefn, OGRFieldSubType subtype) + OGRErr OGR_G_AddGeometryDirectly (void *geometry, void *part) + void OGR_G_AddPoint (void *geometry, double x, double y, double z) + void OGR_G_AddPoint_2D (void *geometry, double x, double y) + void OGR_G_CloseRings (void *geometry) + void * OGR_G_CreateGeometry (int wkbtypecode) + void OGR_G_DestroyGeometry (void *geometry) + unsigned char * OGR_G_ExportToJson (void *geometry) + void OGR_G_ExportToWkb (void *geometry, int endianness, char *buffer) + int OGR_G_GetCoordinateDimension (void *geometry) + int OGR_G_GetGeometryCount (void *geometry) + unsigned char * OGR_G_GetGeometryName (void *geometry) + int OGR_G_GetGeometryType (void *geometry) + void * OGR_G_GetGeometryRef (void *geometry, int n) + int OGR_G_GetPointCount (void *geometry) + double OGR_G_GetX (void *geometry, int n) + double OGR_G_GetY (void *geometry, int n) + double OGR_G_GetZ (void *geometry, int n) + void OGR_G_ImportFromWkb (void *geometry, unsigned char *bytes, int nbytes) + int OGR_G_WkbSize (void *geometry) + void * OGR_G_ForceToMultiPolygon (void *geometry) + void * OGR_G_ForceToPolygon (void *geometry) + void * OGR_G_Clone(void *geometry) + OGRErr OGR_L_CreateFeature (void *layer, void *feature) + OGRErr OGR_L_CreateField (void *layer, void *fielddefn, int flexible) + OGRErr OGR_L_GetExtent (void *layer, void *extent, int force) + void * OGR_L_GetFeature (void *layer, int n) + int OGR_L_GetFeatureCount (void *layer, int m) + void * OGR_G_GetLinearGeometry (void *hGeom, double dfMaxAngleStepSizeDegrees, char **papszOptions) + void * OGR_L_GetLayerDefn (void *layer) + char * OGR_L_GetName (void *layer) + void * OGR_L_GetNextFeature (void *layer) + void * OGR_L_GetSpatialFilter (void *layer) + void * OGR_L_GetSpatialRef (void *layer) + void OGR_L_ResetReading (void *layer) + void OGR_L_SetSpatialFilter (void *layer, void *geometry) + void OGR_L_SetSpatialFilterRect ( + void *layer, double minx, double miny, double maxx, double maxy + ) + int OGR_L_TestCapability (void *layer, char *name) + void * OGRGetDriverByName (char *) + void * OGROpen (char *path, int mode, void *x) + void * OGROpenShared (char *path, int mode, void *x) + int OGRReleaseDataSource (void *datasource) + OGRErr OGR_L_SetIgnoredFields (void *layer, const char **papszFields) + OGRErr OGR_L_SetNextByIndex (void *layer, long nIndex) + long long OGR_F_GetFieldAsInteger64 (void *feature, int n) + void OGR_F_SetFieldInteger64 (void *feature, int n, long long value) diff -Nru fiona-1.8.6/fiona/ogrext.pyx fiona-1.8.11/fiona/ogrext.pyx --- fiona-1.8.6/fiona/ogrext.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/ogrext.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -36,7 +36,7 @@ from fiona.schema import FIELD_TYPES, FIELD_TYPES_MAP, normalize_field_type from fiona.path import vsi_path -from fiona._shim cimport is_field_null +from fiona._shim cimport is_field_null, osr_get_name, osr_set_traditional_axis_mapping_strategy from libc.stdlib cimport malloc, free from libc.string cimport strcmp @@ -877,7 +877,7 @@ cdef object _schema_mapping def start(self, collection, **kwargs): - cdef void *cogr_srs = NULL + cdef OGRSpatialReferenceH cogr_srs = NULL cdef char **options = NULL cdef const char *path_c = NULL cdef const char *driver_c = NULL @@ -970,52 +970,18 @@ self.cogr_ds = cogr_ds # Set the spatial reference system from the crs given to the - # collection constructor. We by-pass the crs_wkt and crs + # collection constructor. We by-pass the crs_wkt # properties because they aren't accessible until the layer # is constructed (later). try: - - col_crs = collection._crs_wkt or collection._crs - + col_crs = collection._crs_wkt if col_crs: cogr_srs = exc_wrap_pointer(OSRNewSpatialReference(NULL)) - - # First, check for CRS strings like "EPSG:3857". - if isinstance(col_crs, string_types): - proj_b = col_crs.encode('utf-8') - proj_c = proj_b - OSRSetFromUserInput(cogr_srs, proj_c) - - elif isinstance(col_crs, compat.DICT_TYPES): - # EPSG is a special case. - init = col_crs.get('init') - if init: - log.debug("Init: %s", init) - auth, val = init.split(':') - if auth.upper() == 'EPSG': - log.debug("Setting EPSG: %s", val) - OSRImportFromEPSG(cogr_srs, int(val)) - else: - params = [] - col_crs['wktext'] = True - for k, v in col_crs.items(): - if v is True or (k in ('no_defs', 'wktext') and v): - params.append("+%s" % k) - else: - params.append("+%s=%s" % (k, v)) - proj = " ".join(params) - log.debug("PROJ.4 to be imported: %r", proj) - proj_b = proj.encode('utf-8') - proj_c = proj_b - OSRImportFromProj4(cogr_srs, proj_c) - - else: - raise ValueError("Invalid CRS") - - # Fixup, export to WKT, and set the GDAL dataset's projection. - OSRFixup(cogr_srs) - - except (ValueError, CPLE_BaseError) as exc: + proj_b = col_crs.encode('utf-8') + proj_c = proj_b + OSRSetFromUserInput(cogr_srs, proj_c) + osr_set_traditional_axis_mapping_strategy(cogr_srs) + except CPLE_BaseError as exc: OGRReleaseDataSource(self.cogr_ds) self.cogr_ds = NULL self.cogr_layer = NULL diff -Nru fiona-1.8.6/fiona/path.py fiona-1.8.11/fiona/path.py --- fiona-1.8.6/fiona/path.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/path.py 2019-11-08 02:24:40.000000000 +0000 @@ -132,7 +132,7 @@ elif path.startswith('/vsi'): return UnparsedPath(path) - else: + elif re.match("^[a-z0-9\\+]*://", path): parts = urlparse(path) # if the scheme is not one of Rasterio's supported schemes, we @@ -143,6 +143,9 @@ else: return ParsedPath.from_uri(path) + else: + return UnparsedPath(path) + def vsi_path(path): """Convert a parsed path to a GDAL VSI path diff -Nru fiona-1.8.6/fiona/_shim1.pxd fiona-1.8.11/fiona/_shim1.pxd --- fiona-1.8.6/fiona/_shim1.pxd 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_shim1.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -19,6 +19,9 @@ cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype) cdef bint check_capability_create_layer(void *cogr_ds) cdef void *get_linear_geometry(void *geom) +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs) +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs) +cdef void set_proj_search_path(object path) from fiona._shim cimport OGR_F_GetFieldAsInteger as OGR_F_GetFieldAsInteger64 from fiona._shim cimport OGR_F_SetFieldInteger as OGR_F_SetFieldInteger64 diff -Nru fiona-1.8.6/fiona/_shim1.pyx fiona-1.8.11/fiona/_shim1.pyx --- fiona-1.8.6/fiona/_shim1.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_shim1.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -1,6 +1,6 @@ """Shims on top of ogrext for GDAL versions < 2""" -import logging +import os from fiona.ogrext1 cimport * from fiona._err cimport exc_wrap_pointer @@ -8,8 +8,6 @@ from fiona.errors import DriverError -log = logging.getLogger(__name__) - cdef int OGRERR_NONE = 0 @@ -80,7 +78,6 @@ v = ('ON' if v else 'OFF').encode('utf-8') else: v = str(v).encode('utf-8') - log.debug("Set option %r: %r", k, v) opts = CSLAddNameValue(opts, k, v) try: @@ -123,3 +120,15 @@ cdef void *get_linear_geometry(void *geom): return geom + + +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs): + return '' + + +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs): + OSRFixup(hSrs) + + +cdef void set_proj_search_path(object path): + os.environ["PROJ_LIB"] = path diff -Nru fiona-1.8.6/fiona/_shim22.pxd fiona-1.8.11/fiona/_shim22.pxd --- fiona-1.8.6/fiona/_shim22.pxd 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_shim22.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -12,3 +12,6 @@ cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype) cdef bint check_capability_create_layer(void *cogr_ds) cdef void *get_linear_geometry(void *geom) +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs) +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs) +cdef void set_proj_search_path(object path) diff -Nru fiona-1.8.6/fiona/_shim22.pyx fiona-1.8.11/fiona/_shim22.pyx --- fiona-1.8.6/fiona/_shim22.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_shim22.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -4,14 +4,15 @@ int OGR_F_IsFieldNull(void *feature, int n) +import logging +import os from fiona.ogrext2 cimport * from fiona._err cimport exc_wrap_pointer + from fiona._err import cpl_errs, CPLE_BaseError, FionaNullPointerError from fiona.errors import DriverError -import logging - log = logging.getLogger(__name__) @@ -132,3 +133,14 @@ cdef void *get_linear_geometry(void *geom): return OGR_G_GetLinearGeometry(geom, 0.0, NULL) + + +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs): + return '' + + +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs): + OSRFixup(hSrs) + +cdef void set_proj_search_path(object path): + os.environ["PROJ_LIB"] = path diff -Nru fiona-1.8.6/fiona/_shim2.pxd fiona-1.8.11/fiona/_shim2.pxd --- fiona-1.8.6/fiona/_shim2.pxd 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_shim2.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -12,3 +12,6 @@ cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype) cdef bint check_capability_create_layer(void *cogr_ds) cdef void *get_linear_geometry(void *geom) +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs) +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs) +cdef void set_proj_search_path(object path) diff -Nru fiona-1.8.6/fiona/_shim2.pyx fiona-1.8.11/fiona/_shim2.pyx --- fiona-1.8.6/fiona/_shim2.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_shim2.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -1,12 +1,13 @@ """Shims on top of ogrext for GDAL versions > 2""" +import logging +import os + from fiona.ogrext2 cimport * from fiona._err cimport exc_wrap_pointer from fiona._err import cpl_errs, CPLE_BaseError, FionaNullPointerError from fiona.errors import DriverError -import logging - log = logging.getLogger(__name__) @@ -42,7 +43,6 @@ for name in drivers: name_b = name.encode() name_c = name_b - #log.debug("Trying driver: %s", name) drv = GDALGetDriverByName(name_c) if drv != NULL: drvs = CSLAddString(drvs, name_c) @@ -125,3 +125,12 @@ cdef void *get_linear_geometry(void *geom): return OGR_G_GetLinearGeometry(geom, 0.0, NULL) +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs): + return '' + +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs): + OSRFixup(hSrs) + + +cdef void set_proj_search_path(object path): + os.environ["PROJ_LIB"] = path diff -Nru fiona-1.8.6/fiona/_shim3.pxd fiona-1.8.11/fiona/_shim3.pxd --- fiona-1.8.6/fiona/_shim3.pxd 1970-01-01 00:00:00.000000000 +0000 +++ fiona-1.8.11/fiona/_shim3.pxd 2019-11-08 02:24:40.000000000 +0000 @@ -0,0 +1,17 @@ +include "ogrext3.pxd" + +cdef bint is_field_null(void *feature, int n) +cdef void set_field_null(void *feature, int n) +cdef void gdal_flush_cache(void *cogr_ds) +cdef void* gdal_open_vector(const char *path_c, int mode, drivers, options) except NULL +cdef void* gdal_create(void* cogr_driver, const char *path_c, options) except NULL +cdef OGRErr gdal_start_transaction(void *cogr_ds, int force) +cdef OGRErr gdal_commit_transaction(void *cogr_ds) +cdef OGRErr gdal_rollback_transaction(void *cogr_ds) +cdef OGRFieldSubType get_field_subtype(void *fielddefn) +cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype) +cdef bint check_capability_create_layer(void *cogr_ds) +cdef void *get_linear_geometry(void *geom) +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs) +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs) +cdef void set_proj_search_path(object path) diff -Nru fiona-1.8.6/fiona/_shim3.pyx fiona-1.8.11/fiona/_shim3.pyx --- fiona-1.8.6/fiona/_shim3.pyx 1970-01-01 00:00:00.000000000 +0000 +++ fiona-1.8.11/fiona/_shim3.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -0,0 +1,161 @@ +"""Shims on top of ogrext for GDAL versions >= 3.0""" + +cdef extern from "ogr_api.h": + + int OGR_F_IsFieldNull(void *feature, int n) + + +cdef extern from "ogr_srs_api.h" nogil: + + ctypedef enum OSRAxisMappingStrategy: + OAMS_TRADITIONAL_GIS_ORDER + + const char* OSRGetName(OGRSpatialReferenceH hSRS) + void OSRSetAxisMappingStrategy(OGRSpatialReferenceH hSRS, OSRAxisMappingStrategy) + void OSRSetPROJSearchPaths(const char *const *papszPaths) + + +from fiona.ogrext2 cimport * +from fiona._err cimport exc_wrap_pointer +from fiona._err import cpl_errs, CPLE_BaseError, FionaNullPointerError +from fiona.errors import DriverError + +import logging + + +log = logging.getLogger(__name__) + + +cdef bint is_field_null(void *feature, int n): + if OGR_F_IsFieldNull(feature, n): + return True + elif not OGR_F_IsFieldSet(feature, n): + return True + else: + return False + + +cdef void set_field_null(void *feature, int n): + OGR_F_SetFieldNull(feature, n) + + +cdef void gdal_flush_cache(void *cogr_ds): + with cpl_errs: + GDALFlushCache(cogr_ds) + + +cdef void* gdal_open_vector(char* path_c, int mode, drivers, options) except NULL: + cdef void* cogr_ds = NULL + cdef char **drvs = NULL + cdef void* drv = NULL + cdef char **open_opts = NULL + + flags = GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR + if mode == 1: + flags |= GDAL_OF_UPDATE + else: + flags |= GDAL_OF_READONLY + + if drivers: + for name in drivers: + name_b = name.encode() + name_c = name_b + drv = GDALGetDriverByName(name_c) + if drv != NULL: + drvs = CSLAddString(drvs, name_c) + + for k, v in options.items(): + + if v is None: + continue + + k = k.upper().encode('utf-8') + if isinstance(v, bool): + v = ('ON' if v else 'OFF').encode('utf-8') + else: + v = str(v).encode('utf-8') + log.debug("Set option %r: %r", k, v) + open_opts = CSLAddNameValue(open_opts, k, v) + + open_opts = CSLAddNameValue(open_opts, "VALIDATE_OPEN_OPTIONS", "NO") + + try: + cogr_ds = exc_wrap_pointer( + GDALOpenEx(path_c, flags, drvs, open_opts, NULL) + ) + return cogr_ds + except FionaNullPointerError: + raise DriverError("Failed to open dataset (mode={}): {}".format(mode, path_c.decode("utf-8"))) + except CPLE_BaseError as exc: + raise DriverError(str(exc)) + finally: + CSLDestroy(drvs) + CSLDestroy(open_opts) + + +cdef void* gdal_create(void* cogr_driver, const char *path_c, options) except NULL: + cdef char **creation_opts = NULL + cdef void *cogr_ds = NULL + + for k, v in options.items(): + k = k.upper().encode('utf-8') + if isinstance(v, bool): + v = ('ON' if v else 'OFF').encode('utf-8') + else: + v = str(v).encode('utf-8') + log.debug("Set option %r: %r", k, v) + creation_opts = CSLAddNameValue(creation_opts, k, v) + + try: + return exc_wrap_pointer(GDALCreate(cogr_driver, path_c, 0, 0, 0, GDT_Unknown, creation_opts)) + except FionaNullPointerError: + raise DriverError("Failed to create dataset: {}".format(path_c.decode("utf-8"))) + except CPLE_BaseError as exc: + raise DriverError(str(exc)) + finally: + CSLDestroy(creation_opts) + + +cdef OGRErr gdal_start_transaction(void* cogr_ds, int force): + return GDALDatasetStartTransaction(cogr_ds, force) + + +cdef OGRErr gdal_commit_transaction(void* cogr_ds): + return GDALDatasetCommitTransaction(cogr_ds) + + +cdef OGRErr gdal_rollback_transaction(void* cogr_ds): + return GDALDatasetRollbackTransaction(cogr_ds) + + +cdef OGRFieldSubType get_field_subtype(void *fielddefn): + return OGR_Fld_GetSubType(fielddefn) + + +cdef void set_field_subtype(void *fielddefn, OGRFieldSubType subtype): + OGR_Fld_SetSubType(fielddefn, subtype) + + +cdef bint check_capability_create_layer(void *cogr_ds): + return GDALDatasetTestCapability(cogr_ds, ODsCCreateLayer) + + +cdef void *get_linear_geometry(void *geom): + return OGR_G_GetLinearGeometry(geom, 0.0, NULL) + + +cdef const char* osr_get_name(OGRSpatialReferenceH hSrs): + return OSRGetName(hSrs) + + +cdef void osr_set_traditional_axis_mapping_strategy(OGRSpatialReferenceH hSrs): + OSRSetAxisMappingStrategy(hSrs, OAMS_TRADITIONAL_GIS_ORDER) + + +cdef void set_proj_search_path(object path): + cdef char **paths = NULL + cdef const char *path_c = NULL + path_b = path.encode("utf-8") + path_c = path_b + paths = CSLAddString(paths, path_c) + OSRSetPROJSearchPaths(paths) diff -Nru fiona-1.8.6/fiona/_transform.pyx fiona-1.8.11/fiona/_transform.pyx --- fiona-1.8.6/fiona/_transform.pyx 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/fiona/_transform.pyx 2019-11-08 02:24:40.000000000 +0000 @@ -8,6 +8,7 @@ from fiona cimport _cpl, _crs, _csl, _geometry from fiona._crs cimport OGRSpatialReferenceH +from fiona._shim cimport osr_set_traditional_axis_mapping_strategy from fiona.compat import UserDict @@ -52,6 +53,7 @@ auth, val = init.split(':') if auth.upper() == 'EPSG': _crs.OSRImportFromEPSG(osr, int(val)) + osr_set_traditional_axis_mapping_strategy(osr) else: crs['wktext'] = True for k, v in crs.items(): @@ -64,6 +66,7 @@ proj_b = proj.encode('utf-8') proj_c = proj_b _crs.OSRImportFromProj4(osr, proj_c) + osr_set_traditional_axis_mapping_strategy(osr) # Fall back for CRS strings like "EPSG:3857." else: proj_b = crs.encode('utf-8') diff -Nru fiona-1.8.6/scripts/travis_gdal_install.sh fiona-1.8.11/scripts/travis_gdal_install.sh --- fiona-1.8.6/scripts/travis_gdal_install.sh 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/scripts/travis_gdal_install.sh 2019-11-08 02:24:40.000000000 +0000 @@ -1,10 +1,13 @@ -#!/bin/sh +#!/bin/bash +# +# originally contributed by @rbuffat to Toblerity/Fiona set -e GDALOPTS=" --with-ogr \ --with-geos \ --with-expat \ --without-libtool \ + --with-libz=internal \ --with-libtiff=internal \ --with-geotiff=internal \ --without-gif \ @@ -13,7 +16,7 @@ --without-libgrass \ --without-cfitsio \ --without-pcraster \ - --without-netcdf \ + --with-netcdf \ --with-png=internal \ --with-jpeg=internal \ --without-gif \ @@ -34,12 +37,11 @@ --without-odbc \ --with-curl \ --with-sqlite3 \ - --without-dwgdirect \ --without-idb \ --without-sde \ + --without-ruby \ --without-perl \ --without-php \ - --without-ruby \ --without-python" # Create build dir if not exists @@ -53,22 +55,62 @@ ls -l $GDALINST -if [ "$GDALVERSION" = "trunk" ]; then - # always rebuild trunk - git clone -b master --single-branch --depth=1 https://github.com/OSGeo/gdal.git $GDALBUILD/trunk - cd $GDALBUILD/trunk/gdal - ./configure --prefix=$GDALINST/gdal-$GDALVERSION $GDALOPTS - make -j 2 - make install -elif [ ! -d "$GDALINST/gdal-$GDALVERSION" ]; then - # only build if not already installed - cd $GDALBUILD - wget http://download.osgeo.org/gdal/$GDALVERSION/gdal-$GDALVERSION.tar.gz - tar -xzf gdal-$GDALVERSION.tar.gz - cd gdal-$GDALVERSION - ./configure --prefix=$GDALINST/gdal-$GDALVERSION $GDALOPTS - make -j 2 - make install +if [ "$GDALVERSION" = "master" ]; then + PROJOPT="--with-proj=$GDALINST/gdal-$GDALVERSION" + cd $GDALBUILD + git clone --depth 1 https://github.com/OSGeo/gdal gdal-$GDALVERSION + cd gdal-$GDALVERSION/gdal + git rev-parse HEAD > newrev.txt + BUILD=no + # Only build if nothing cached or if the GDAL revision changed + if test ! -f $GDALINST/gdal-$GDALVERSION/rev.txt; then + BUILD=yes + elif ! diff newrev.txt $GDALINST/gdal-$GDALVERSION/rev.txt >/dev/null; then + BUILD=yes + fi + if test "$BUILD" = "yes"; then + mkdir -p $GDALINST/gdal-$GDALVERSION + cp newrev.txt $GDALINST/gdal-$GDALVERSION/rev.txt + ./configure --prefix=$GDALINST/gdal-$GDALVERSION $GDALOPTS $PROJOPT + make -j 4 + make install + fi + +else + case "$GDALVERSION" in + 3*) + PROJOPT="--with-proj=$GDALINST/gdal-$GDALVERSION" + ;; + 2.4*) + PROJOPT="--with-proj=$GDALINST/gdal-$GDALVERSION" + ;; + 2.3*) + PROJOPT="--with-proj=$GDALINST/gdal-$GDALVERSION" + ;; + 2.2*) + PROJOPT="--with-static-proj4=$GDALINST/gdal-$GDALVERSION" + ;; + 2.1*) + PROJOPT="--with-static-proj4=$GDALINST/gdal-$GDALVERSION" + ;; + 2.0*) + PROJOPT="--with-static-proj4=$GDALINST/gdal-$GDALVERSION" + ;; + 1*) + PROJOPT="--with-static-proj4=$GDALINST/gdal-$GDALVERSION" + ;; + esac + + if [ ! -d "$GDALINST/gdal-$GDALVERSION/share/gdal" ]; then + cd $GDALBUILD + gdalver=$(expr "$GDALVERSION" : '\([0-9]*.[0-9]*.[0-9]*\)') + wget -q http://download.osgeo.org/gdal/$gdalver/gdal-$GDALVERSION.tar.gz + tar -xzf gdal-$GDALVERSION.tar.gz + cd gdal-$gdalver + ./configure --prefix=$GDALINST/gdal-$GDALVERSION $GDALOPTS $PROJOPT + make -j 4 + make install + fi fi # change back to travis build dir diff -Nru fiona-1.8.6/scripts/travis_proj_install.sh fiona-1.8.11/scripts/travis_proj_install.sh --- fiona-1.8.6/scripts/travis_proj_install.sh 1970-01-01 00:00:00.000000000 +0000 +++ fiona-1.8.11/scripts/travis_proj_install.sh 2019-11-08 02:24:40.000000000 +0000 @@ -0,0 +1,28 @@ +#!/bin/sh +set -e + +# Create build dir if not exists +if [ ! -d "$PROJBUILD" ]; then + mkdir $PROJBUILD; +fi + +if [ ! -d "$PROJINST" ]; then + mkdir $PROJINST; +fi + +ls -l $PROJINST + +echo "PROJ VERSION: $PROJVERSION" + +if [ ! -d "$PROJINST/gdal-$GDALVERSION/share/proj" ]; then + cd $PROJBUILD + wget -q https://download.osgeo.org/proj/proj-$PROJVERSION.tar.gz + tar -xzf proj-$PROJVERSION.tar.gz + cd proj-$PROJVERSION + ./configure --prefix=$PROJINST/gdal-$GDALVERSION + make -s -j 2 + make install +fi + +# change back to travis build dir +cd $TRAVIS_BUILD_DIR diff -Nru fiona-1.8.6/setup.py fiona-1.8.11/setup.py --- fiona-1.8.6/setup.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/setup.py 2019-11-08 02:24:40.000000000 +0000 @@ -77,7 +77,8 @@ sources = { "_shim1": "_shim", "_shim2": "_shim", - "_shim22": "_shim" + "_shim22": "_shim", + "_shim3": "_shim" } for src_a, src_b in sources.items(): shutil.copy('fiona/{}.pyx'.format(src_a), 'fiona/{}.pyx'.format(src_b)) @@ -182,6 +183,8 @@ gdal_major_version = int(gdal_version_parts[0]) gdal_minor_version = int(gdal_version_parts[1]) +log.info("GDAL version major=%r minor=%r", gdal_major_version, gdal_minor_version) + ext_options = dict( include_dirs=include_dirs, library_dirs=library_dirs, @@ -223,6 +226,9 @@ log.info("Building Fiona for gdal 2.0.x-2.1.x: {0}".format(gdalversion)) shutil.copy('fiona/_shim2.pyx', 'fiona/_shim.pyx') shutil.copy('fiona/_shim2.pxd', 'fiona/_shim.pxd') + elif gdal_major_version == 3: + shutil.copy('fiona/_shim3.pyx', 'fiona/_shim.pyx') + shutil.copy('fiona/_shim3.pxd', 'fiona/_shim.pxd') ext_modules = cythonize([ Extension('fiona._geometry', ['fiona/_geometry.pyx'], **ext_options), @@ -230,7 +236,6 @@ Extension('fiona._transform', ['fiona/_transform.pyx'], **ext_options_cpp), Extension('fiona._crs', ['fiona/_crs.pyx'], **ext_options), Extension('fiona._env', ['fiona/_env.pyx'], **ext_options), - Extension('fiona._drivers', ['fiona/_drivers.pyx'], **ext_options), Extension('fiona._err', ['fiona/_err.pyx'], **ext_options), Extension('fiona._shim', ['fiona/_shim.pyx'], **ext_options), Extension('fiona.ogrext', ['fiona/ogrext.pyx'], **ext_options) @@ -246,7 +251,6 @@ Extension('fiona._geometry', ['fiona/_geometry.c'], **ext_options), Extension('fiona._crs', ['fiona/_crs.c'], **ext_options), Extension('fiona._env', ['fiona/_env.c'], **ext_options), - Extension('fiona._drivers', ['fiona/_drivers.c'], **ext_options), Extension('fiona._err', ['fiona/_err.c'], **ext_options), Extension('fiona.ogrext', ['fiona/ogrext.c'], **ext_options), ] @@ -255,7 +259,7 @@ log.info("Building Fiona for gdal 1.x: {0}".format(gdalversion)) ext_modules.append( Extension('fiona._shim', ['fiona/_shim1.c'], **ext_options)) - else: + elif gdal_major_version == 2: if gdal_minor_version >= 2: log.info("Building Fiona for gdal 2.2+: {0}".format(gdalversion)) ext_modules.append( @@ -264,6 +268,10 @@ log.info("Building Fiona for gdal 2.0.x-2.1.x: {0}".format(gdalversion)) ext_modules.append( Extension('fiona._shim', ['fiona/_shim2.c'], **ext_options)) + elif gdal_major_version == 3: + log.info("Building Fiona for gdal >= 3.0.x: {0}".format(gdalversion)) + ext_modules.append( + Extension('fiona._shim', ['fiona/_shim3.c'], **ext_options)) requirements = [ 'attrs>=17', diff -Nru fiona-1.8.6/tests/conftest.py fiona-1.8.11/tests/conftest.py --- fiona-1.8.6/tests/conftest.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/conftest.py 2019-11-08 02:24:40.000000000 +0000 @@ -264,6 +264,14 @@ not gdal_version.at_least('2.4'), reason="Requires GDAL 2.4.x") +requires_gdal_lt_3 = pytest.mark.skipif( + not gdal_version.major < 3, + reason="Requires GDAL < 3") + +requires_gdal3 = pytest.mark.skipif( + not gdal_version.major >= 3, + reason="Requires GDAL 3.x") + @pytest.fixture(scope="class") def unittest_data_dir(data_dir, request): diff -Nru fiona-1.8.6/tests/data/!test.geojson fiona-1.8.11/tests/data/!test.geojson --- fiona-1.8.6/tests/data/!test.geojson 1970-01-01 00:00:00.000000000 +0000 +++ fiona-1.8.11/tests/data/!test.geojson 2019-11-08 02:24:40.000000000 +0000 @@ -0,0 +1 @@ +{"features":[{"geometry":{"coordinates":[[[[-61.173214300000005,12.516654800000001],[-61.3827217,12.5301363],[-61.665747100000004,12.5966532],[-61.6661847,12.596],[-61.66814250000001,12.593],[-61.6700247,12.59],[-61.6718337,12.587],[-61.673571700000004,12.584],[-61.6752407,12.581],[-61.6768427,12.578],[-61.678379400000004,12.575000000000001],[-61.6803295,12.571],[-61.6830501,12.565000000000001],[-61.68553430000001,12.559000000000001],[-61.687063699999996,12.555000000000001],[-61.6884946,12.551],[-61.6898391,12.546999999999999],[-61.69209600000001,12.540999999999999],[-61.69413360000001,12.535],[-61.69595870000001,12.529],[-61.697577200000005,12.523],[-61.69899410000001,12.517],[-61.700213700000006,12.511],[-61.7012395,12.505],[-61.7020744,12.499],[-61.702626200000005,12.494],[-61.7033841,12.493],[-61.706211800000005,12.491],[-61.7089415,12.489],[-61.7141311,12.485000000000001],[-61.718995500000005,12.481],[-61.72356890000001,12.477],[-61.727879200000004,12.473],[-61.7319495,12.469000000000001],[-61.73579920000001,12.465000000000002],[-61.74032590000001,12.46],[-61.74373590000001,12.456000000000001],[-61.746971,12.452000000000002],[-61.7500412,12.447999999999999],[-61.75295580000001,12.443999999999999],[-61.753784499999995,12.443],[-61.756858300000005,12.44],[-61.7598054,12.437],[-61.762633400000006,12.434],[-61.76534870000001,12.431],[-61.767957200000005,12.427999999999999],[-61.7704641,12.425],[-61.7728741,12.422],[-61.775191500000005,12.419],[-61.7774201,12.416],[-61.7802595,12.412],[-61.782954800000006,12.408],[-61.78551270000001,12.404],[-61.7873446,12.401],[-61.789675900000006,12.397],[-61.7918847,12.393],[-61.79397550000001,12.389000000000001],[-61.794998400000004,12.388],[-61.79830060000001,12.386000000000001],[-61.8030062,12.383000000000001],[-61.8059936,12.381],[-61.810272399999995,12.378],[-61.8130009,12.376000000000001],[-61.815637599999995,12.374],[-61.8181882,12.372000000000002],[-61.82186339999999,12.369000000000002],[-61.8265048,12.365000000000002],[-61.830876599999996,12.361],[-61.8329692,12.359000000000002],[-61.835999,12.356000000000002],[-61.8413082,12.351],[-61.845319800000006,12.347],[-61.8464439,12.346],[-61.8501187,12.343],[-61.853625699999995,12.34],[-61.85697739999999,12.337],[-61.86122339999999,12.333],[-61.864252900000004,12.33],[-61.8671584,12.327],[-61.8699469,12.324],[-61.872645999999996,12.321],[-61.8754727,12.318],[-61.87906749999999,12.314],[-61.8833,12.309000000000001],[-61.88726319999999,12.304],[-61.88952,12.301],[-61.891690399999995,12.297999999999998],[-61.8937778,12.295],[-61.895785200000006,12.292],[-61.89771530000001,12.289],[-61.899570800000006,12.286],[-61.90251490000001,12.280999999999999],[-61.904753,12.277],[-61.9068719,12.273],[-61.908875900000005,12.269],[-61.911674299999994,12.263],[-61.9134062,12.259],[-61.9150578,12.255],[-61.9179797,12.248999999999999],[-61.920656900000004,12.242999999999999],[-61.92290190000001,12.238999999999999],[-61.925082,12.235],[-61.92666,12.232],[-61.9286637,12.227999999999998],[-61.930556100000004,12.223999999999998],[-61.9332651,12.217999999999998],[-61.936145100000005,12.212],[-61.938782200000006,12.206],[-61.943587599999994,12.193999999999999],[-61.94511500000001,12.19],[-61.9465439,12.186],[-61.9485074,12.18],[-61.95028749999999,12.174],[-61.95186999999999,12.168],[-61.9532519,12.162],[-61.95443739999999,12.156],[-61.954975999999995,12.154],[-61.9570107,12.147999999999998],[-61.9594482,12.139999999999999],[-61.961132600000006,12.133999999999999],[-61.962614,12.127999999999998],[-61.96295200000001,12.126999999999999],[-61.9668105,12.122],[-61.9704259,12.116999999999999],[-61.9738135,12.112],[-61.9769866,12.107],[-61.9799566,12.102],[-61.9827336,12.097],[-61.9853262,12.092],[-61.9882048,12.086],[-61.990875800000005,12.08],[-61.99252880000001,12.076],[-61.994819,12.07],[-61.996888999999996,12.064],[-61.99874590000001,12.058],[-62.000395600000004,12.052000000000001],[-62.0018433,12.046],[-62.0030933,12.04],[-62.003818700000004,12.036],[-62.0047472,12.03],[-62.0052609,12.026],[-62.005875200000006,12.02],[-62.0061812,12.016],[-62.0064861,12.01],[-62.0065868,12.006],[-62.006584499999995,12],[-62.006398100000006,11.994],[-62.0061714,11.99],[-62.0056768,11.984],[-62.0052436,11.98],[-62.004436999999996,11.974],[-62.003794,11.97],[-62.0026693,11.964],[-62.001811399999994,11.96],[-62.0003595,11.954],[-61.999279800000004,11.950000000000001],[-61.9974886,11.943999999999999],[-61.9961776,11.94],[-61.9940313,11.934],[-61.9924772,11.93],[-61.9908218,11.926],[-61.989062399999995,11.922],[-61.9871961,11.918],[-61.984707699999994,11.913],[-61.9825882,11.909],[-61.9803498,11.905000000000001],[-61.9773776,11.9],[-61.9748543,11.896],[-61.972195400000004,11.892000000000001],[-61.9693945,11.888],[-61.9664442,11.884],[-61.9641286,11.881],[-61.9617206,11.878],[-61.959215900000004,11.875000000000002],[-61.9557177,11.871],[-61.9520267,11.867],[-61.9496952,11.864],[-61.94728729999999,11.861],[-61.9430571,11.856000000000002],[-61.93853550000001,11.851],[-61.934690599999996,11.847],[-61.9306255,11.843],[-61.9274208,11.84],[-61.922921800000005,11.836],[-61.9193636,11.833],[-61.9156332,11.83],[-61.911715,11.827],[-61.9075906,11.824],[-61.903238,11.821],[-61.89863020000001,11.818],[-61.8937341,11.815000000000001],[-61.888507499999996,11.812000000000001],[-61.88481339999999,11.81],[-61.8789067,11.807],[-61.87468659999999,11.805000000000001],[-61.870200499999996,11.803],[-61.86540230000001,11.801],[-61.8602301,11.799],[-61.854597299999995,11.796999999999999],[-61.848375600000004,11.795],[-61.84498479999999,11.793999999999999],[-61.8413608,11.793],[-61.8374527,11.792],[-61.8331873,11.790999999999999],[-61.828452500000004,11.79],[-61.8230605,11.789],[-61.81664609999999,11.787999999999998],[-61.808274399999995,11.786999999999999],[-61.790283900000006,11.786],[-61.7840631,11.786],[-61.76607270000001,11.786999999999999],[-61.7573236,11.787999999999998],[-61.73933300000001,11.789],[-61.730961300000004,11.79],[-61.72079310000001,11.790999999999999],[-61.70280230000001,11.792],[-61.6944305,11.793],[-61.688016000000005,11.793999999999999],[-61.6826238,11.795],[-61.6732043,11.796999999999999],[-61.667812100000006,11.797999999999998],[-61.663077200000004,11.799],[-61.6588117,11.8],[-61.654903499999996,11.801],[-61.6512793,11.802000000000001],[-61.64788839999999,11.803],[-61.644693499999995,11.804],[-61.63878580000001,11.806000000000001],[-61.636033600000005,11.807],[-61.6308613,11.809000000000001],[-61.62841970000001,11.81],[-61.623784,11.812000000000001],[-61.621576700000006,11.813],[-61.6173564,11.815000000000001],[-61.6133668,11.817],[-61.60957990000001,11.819],[-61.6042318,11.822000000000001],[-61.6008621,11.824],[-61.5976324,11.826],[-61.5930244,11.829],[-61.590096,11.831],[-61.5872727,11.833],[-61.585739600000004,11.834],[-61.5816382,11.836],[-61.5758831,11.839],[-61.5705345,11.842],[-61.565532900000015,11.845],[-61.56375870000001,11.846],[-61.55785109999999,11.849],[-61.552374300000004,11.852000000000002],[-61.5472238,11.855000000000002],[-61.543925300000005,11.857000000000001],[-61.5407605,11.859000000000002],[-61.5362404,11.862000000000002],[-61.533365200000006,11.864],[-61.530591300000005,11.866000000000001],[-61.52791200000001,11.868],[-61.5240577,11.871],[-61.5215904,11.873000000000001],[-61.5180317,11.876000000000001],[-61.515748300000006,11.878],[-61.5124482,11.881],[-61.5103269,11.883000000000001],[-61.5072563,11.886000000000001],[-61.49835930000001,11.895000000000001],[-61.494617399999996,11.899000000000001],[-61.4902146,11.904],[-61.48533390000001,11.909],[-61.4816423,11.913],[-61.47729749999999,11.918],[-61.4732301,11.923],[-61.4694197,11.927999999999999],[-61.464353900000006,11.935],[-61.4615887,11.939],[-61.458328800000004,11.943999999999999],[-61.4552762,11.949],[-61.452420399999994,11.954],[-61.450271099999995,11.958],[-61.4482377,11.962000000000002],[-61.4454269,11.967],[-61.4438039,11.97],[-61.4412339,11.975000000000001],[-61.4388714,11.979000000000001],[-61.436091399999995,11.984],[-61.43451230000001,11.987],[-61.4329978,11.99],[-61.4310762,11.994],[-61.428396400000004,12],[-61.42595080000001,12.006],[-61.423730500000005,12.012],[-61.42313910000001,12.013],[-61.4211047,12.016],[-61.41851320000001,12.02],[-61.4166569,12.023],[-61.41487299999999,12.026],[-61.4131591,12.029],[-61.4109797,12.033],[-61.409422,12.036],[-61.40744449999999,12.04],[-61.405577300000004,12.043999999999999],[-61.4038171,12.047999999999998],[-61.402161,12.052000000000001],[-61.399865999999996,12.058],[-61.39845880000001,12.062000000000001],[-61.3971473,12.066],[-61.3959295,12.07],[-61.394275,12.076],[-61.393596300000006,12.078],[-61.3910564,12.081],[-61.38782199999999,12.085],[-61.3855047,12.088],[-61.382552100000005,12.092],[-61.3804362,12.095],[-61.37774039999999,12.099],[-61.3758089,12.102],[-61.3733493,12.106],[-61.37158839999999,12.109],[-61.369348200000005,12.113],[-61.367746499999996,12.116],[-61.36571180000001,12.12],[-61.3637893,12.123999999999999],[-61.3619754,12.127999999999998],[-61.360267099999994,12.132],[-61.35866139999999,12.136],[-61.35643999999999,12.142],[-61.35508039999999,12.145999999999999],[-61.3538123,12.15],[-61.3520543,12.156],[-61.3509963,12.16],[-61.35002769999999,12.164],[-61.3487397,12.17],[-61.34798939999999,12.174],[-61.34732449999999,12.177999999999999],[-61.3464859,12.184],[-61.346031399999994,12.187999999999999],[-61.345660099999996,12.192],[-61.3452579,12.197999999999999],[-61.3450925,12.202],[-61.3450091,12.206],[-61.345007599999995,12.209999999999999],[-61.345087899999996,12.213999999999999],[-61.3452502,12.217999999999998],[-61.345494599999995,12.222],[-61.34582149999999,12.225999999999999],[-61.3462313,12.229999999999999],[-61.347002499999995,12.235999999999999],[-61.34762189999999,12.239999999999998],[-61.3483264,12.243999999999998],[-61.3495448,12.25],[-61.345779300000004,12.253],[-61.3421596,12.256],[-61.339838,12.258],[-61.3364839,12.261],[-61.333273999999996,12.264],[-61.330199,12.267],[-61.3272505,12.27],[-61.324421099999995,12.273],[-61.3217043,12.276],[-61.31824699999999,12.28],[-61.3157713,12.283],[-61.3126179,12.286999999999999],[-61.30962449999999,12.290999999999999],[-61.3067826,12.295],[-61.30408469999999,12.299],[-61.301524099999995,12.303],[-61.300435,12.304],[-61.297963700000004,12.306000000000001],[-61.29439910000001,12.309000000000001],[-61.29211200000002,12.311],[-61.2888064,12.314],[-61.286681699999995,12.316],[-61.283606,12.319],[-61.280656900000004,12.322000000000001],[-61.277826999999995,12.325000000000001],[-61.27510960000001,12.328],[-61.272499,12.331],[-61.26999000000001,12.334],[-61.267577800000005,12.337],[-61.26525820000001,12.34],[-61.262302800000015,12.344],[-61.260184900000006,12.347],[-61.25748639999999,12.351],[-61.256502700000006,12.352000000000002],[-61.25251010000001,12.355000000000002],[-61.248711400000005,12.358],[-61.245090100000006,12.361],[-61.2416324,12.364],[-61.23832620000001,12.367],[-61.235161000000005,12.370000000000001],[-61.23212780000001,12.373000000000001],[-61.22827520000001,12.377],[-61.22552040000001,12.38],[-61.22287430000001,12.383000000000001],[-61.220331400000006,12.386000000000001],[-61.2170932,12.39],[-61.2147732,12.393],[-61.2118172,12.397],[-61.209698800000005,12.4],[-61.206999800000006,12.404],[-61.205066,12.407],[-61.20258810000001,12.411],[-61.2008015,12.414],[-61.199085100000005,12.417],[-61.19743690000001,12.42],[-61.19585520000001,12.423],[-61.19433810000001,12.426],[-61.19241330000001,12.43],[-61.1897291,12.436],[-61.1872793,12.442],[-61.18505530000001,12.447999999999999],[-61.1836941,12.452000000000002],[-61.1824277,12.456000000000001],[-61.18125439999999,12.46],[-61.180172500000005,12.464],[-61.1791805,12.468],[-61.178277,12.472000000000001],[-61.1770853,12.478],[-61.17603230000001,12.484],[-61.175387900000004,12.488],[-61.1745797,12.494],[-61.1741456,12.498],[-61.1737945,12.502],[-61.173526,12.506],[-61.17333980000001,12.51],[-61.17323580000001,12.514],[-61.173214300000005,12.516654800000001]]]],"type":"MultiPolygon"},"id":550727,"osm_type":"relation","type":"Feature","name":"Grenada","properties":{"flag":"http://upload.wikimedia.org/wikipedia/commons/b/bc/Flag_of_Grenada.svg","name":"Grenada","name:cs":"Grenada","name:de":"Grenada","name:en":"Grenada","name:eo":"Grenado","name:fr":"Grenade","name:fy":"Grenada","name:hr":"Grenada","name:nl":"Grenada","name:ru":"Гренада","name:sl":"Grenada","name:ta":"கிரெனடா","name:uk":"Гренада","boundary":"administrative","name:tzl":"Grenada","timezone":"America/Grenada","wikidata":"Q769","ISO3166-1":"GD","wikipedia":"en:Grenada","admin_level":"2","is_in:continent":"North America","ISO3166-1:alpha2":"GD","ISO3166-1:alpha3":"GRD","ISO3166-1:numeric":"308"}}],"type":"FeatureCollection","geocoding":{"creation_date":"2016-10-12","generator":{"author":{"name":"Mapzen"},"package":"fences-builder","version":"0.1.2"},"license":"ODbL (see http://www.openstreetmap.org/copyright)"}} diff -Nru fiona-1.8.6/tests/test_collection_crs.py fiona-1.8.11/tests/test_collection_crs.py --- fiona-1.8.6/tests/test_collection_crs.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_collection_crs.py 2019-11-08 02:24:40.000000000 +0000 @@ -1,10 +1,12 @@ import os import re +import pytest + import fiona import fiona.crs - -from .conftest import WGS84PATTERN, requires_gdal2 +from fiona.errors import CRSError +from .conftest import WGS84PATTERN, requires_gdal2, requires_gdal3 def test_collection_crs_wkt(path_coutwildrnp_shp): @@ -27,10 +29,35 @@ @requires_gdal2 def test_collection_create_crs_wkt(tmpdir): """A collection can be created using crs_wkt""" - filename = str(tmpdir.join("test.shp")) + filename = str(tmpdir.join("test.geojson")) wkt = 'GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295],AUTHORITY["EPSG","4326"]]' with fiona.open(filename, 'w', schema={'geometry': 'Point', 'properties': {'foo': 'int'}}, crs_wkt=wkt, driver='GeoJSON') as dst: - assert dst.crs_wkt == wkt + assert dst.crs_wkt.startswith('GEOGCS["WGS 84') or dst.crs_wkt.startswith('GEOGCS["GCS_WGS_1984') + + with fiona.open(filename) as col: + assert col.crs_wkt.startswith('GEOGCS["WGS 84') or col.crs_wkt.startswith('GEOGCS["GCS_WGS_1984') + + +@requires_gdal3 +def test_collection_urn_crs(tmpdir): + filename = str(tmpdir.join("test.geojson")) + crs = "urn:ogc:def:crs:OGC:1.3:CRS84" + with fiona.open(filename, 'w', schema={'geometry': 'Point', 'properties': {'foo': 'int'}}, crs=crs, driver='GeoJSON') as dst: + assert dst.crs_wkt.startswith('GEOGCS["WGS 84') with fiona.open(filename) as col: assert col.crs_wkt.startswith('GEOGCS["WGS 84') + + + +def test_collection_invalid_crs(tmpdir): + filename = str(tmpdir.join("test.geojson")) + with pytest.raises(CRSError): + with fiona.open(filename, 'w', schema={'geometry': 'Point', 'properties': {'foo': 'int'}}, crs="12ab-invalid", driver='GeoJSON') as dst: + pass + +def test_collection_invalid_crs_wkt(tmpdir): + filename = str(tmpdir.join("test.geojson")) + with pytest.raises(CRSError): + with fiona.open(filename, 'w', schema={'geometry': 'Point', 'properties': {'foo': 'int'}}, crs_wkt="12ab-invalid", driver='GeoJSON') as dst: + pass diff -Nru fiona-1.8.6/tests/test_collection.py fiona-1.8.11/tests/test_collection.py --- fiona-1.8.6/tests/test_collection.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_collection.py 2019-11-08 02:24:40.000000000 +0000 @@ -9,7 +9,7 @@ import fiona from fiona.collection import Collection, supported_drivers from fiona.env import getenv -from fiona.errors import FionaValueError, DriverError +from fiona.errors import FionaValueError, DriverError, FionaDeprecationWarning from .conftest import WGS84PATTERN @@ -80,7 +80,7 @@ class TestOpenException(object): def test_no_archive(self): - with pytest.raises(DriverError): + with pytest.warns(FionaDeprecationWarning), pytest.raises(DriverError): fiona.open("/", mode='r', vfs="zip:///foo.zip") diff -Nru fiona-1.8.6/tests/test_crs.py fiona-1.8.11/tests/test_crs.py --- fiona-1.8.6/tests/test_crs.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_crs.py 2019-11-08 02:24:40.000000000 +0000 @@ -1,4 +1,9 @@ +import pytest + from fiona import crs, _crs +from fiona.errors import CRSError + +from .conftest import requires_gdal_lt_3 def test_proj_keys(): @@ -89,6 +94,7 @@ assert 'NAD83' in val +@requires_gdal_lt_3 def test_wktext(): """Test +wktext parameter is preserved.""" proj4 = ('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 ' @@ -106,11 +112,23 @@ assert 'towgs84' in crs.from_string(proj4) +@requires_gdal_lt_3 def test_towgs84_wkt(): """+towgs84 +wktext are preserved in WKT""" proj4 = ('+proj=lcc +lat_1=49 +lat_2=46 +lat_0=47.5 ' '+lon_0=13.33333333333333 +x_0=400000 +y_0=400000 +ellps=bessel ' '+towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 ' '+units=m +wktext +no_defs') - assert 'towgs84' in _crs.crs_to_wkt(proj4) + wkt = _crs.crs_to_wkt(proj4) + assert 'towgs84' in wkt assert 'wktext' in _crs.crs_to_wkt(proj4) + + +@pytest.mark.parametrize("invalid_input", [ + "a random string that is invalid", + ("a", "tuple"), + "-48567=409 =2095" +]) +def test_invalid_crs(invalid_input): + with pytest.raises(CRSError): + _crs.crs_to_wkt(invalid_input) diff -Nru fiona-1.8.6/tests/test__env.py fiona-1.8.11/tests/test__env.py --- fiona-1.8.6/tests/test__env.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test__env.py 2019-11-08 02:24:40.000000000 +0000 @@ -17,7 +17,7 @@ moduledir = tmpdir.mkdir("rasterio") moduledir.ensure("__init__.py") moduledir.ensure("_env.py") - moduledir.ensure("gdal_data/pcs.csv") + moduledir.ensure("gdal_data/header.dxf") moduledir.ensure("proj_data/epsg") return moduledir @@ -25,7 +25,7 @@ @pytest.fixture def mock_fhs(tmpdir): """A fake FHS system""" - tmpdir.ensure("share/gdal/pcs.csv") + tmpdir.ensure("share/gdal/header.dxf") tmpdir.ensure("share/proj/epsg") return tmpdir @@ -33,12 +33,13 @@ @pytest.fixture def mock_debian(tmpdir): """A fake Debian multi-install system""" - tmpdir.ensure("share/gdal/1.11/pcs.csv") - tmpdir.ensure("share/gdal/2.0/pcs.csv") - tmpdir.ensure("share/gdal/2.1/pcs.csv") - tmpdir.ensure("share/gdal/2.2/pcs.csv") - tmpdir.ensure("share/gdal/2.3/pcs.csv") - tmpdir.ensure("share/gdal/2.4/pcs.csv") + tmpdir.ensure("share/gdal/1.11/header.dxf") + tmpdir.ensure("share/gdal/2.0/header.dxf") + tmpdir.ensure("share/gdal/2.1/header.dxf") + tmpdir.ensure("share/gdal/2.2/header.dxf") + tmpdir.ensure("share/gdal/2.3/header.dxf") + tmpdir.ensure("share/gdal/2.4/header.dxf") + tmpdir.ensure("share/gdal/3.0/header.dxf") tmpdir.ensure("share/proj/epsg") return tmpdir diff -Nru fiona-1.8.6/tests/test_env.py fiona-1.8.11/tests/test_env.py --- fiona-1.8.6/tests/test_env.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_env.py 2019-11-08 02:24:40.000000000 +0000 @@ -58,7 +58,7 @@ return getenv()['GDAL_DATA'] find_file.return_value = None - tmpdir.ensure("share/gdal/pcs.csv") + tmpdir.ensure("share/gdal/header.dxf") monkeypatch.delenv('GDAL_DATA', raising=False) monkeypatch.setattr(_env, '__file__', str(tmpdir.join("fake.py"))) monkeypatch.setattr(sys, 'prefix', str(tmpdir)) @@ -74,7 +74,7 @@ return getenv()['GDAL_DATA'] find_file.return_value = None - tmpdir.ensure("gdal_data/pcs.csv") + tmpdir.ensure("gdal_data/header.dxf") monkeypatch.delenv('GDAL_DATA', raising=False) monkeypatch.setattr(_env, '__file__', str(tmpdir.join(os.path.basename(_env.__file__)))) @@ -89,7 +89,7 @@ return getenv()['GDAL_DATA'] find_file.return_value = None - tmpdir.ensure("gdal_data/pcs.csv") + tmpdir.ensure("gdal_data/header.dxf") monkeypatch.delenv('GDAL_DATA', raising=False) monkeypatch.setattr(_env, '__file__', str(tmpdir.join(os.path.basename(_env.__file__)))) diff -Nru fiona-1.8.6/tests/test_geopackage.py fiona-1.8.11/tests/test_geopackage.py --- fiona-1.8.6/tests/test_geopackage.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_geopackage.py 2019-11-08 02:24:40.000000000 +0000 @@ -59,7 +59,6 @@ with fiona.open(path) as src: assert src.schema['geometry'] == 'Point' - assert src.crs == example_crs assert len(src) == 3 @requires_gpkg @@ -86,10 +85,8 @@ with fiona.open(path, layer="layer1") as src: assert src.schema['geometry'] == 'Point' - assert src.crs == example_crs assert len(src) == 2 with fiona.open(path, layer="layer2") as src: assert src.schema['geometry'] == 'Point' - assert src.crs == example_crs assert len(src) == 1 diff -Nru fiona-1.8.6/tests/test_listing.py fiona-1.8.11/tests/test_listing.py --- fiona-1.8.6/tests/test_listing.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_listing.py 2019-11-08 02:24:40.000000000 +0000 @@ -8,7 +8,7 @@ import fiona import fiona.ogrext -from fiona.errors import DriverError +from fiona.errors import DriverError, FionaDeprecationWarning def test_single_file_private(path_coutwildrnp_shp): @@ -36,7 +36,8 @@ def test_zip_path_arch(path_coutwildrnp_zip): vfs = 'zip://{}'.format(path_coutwildrnp_zip) - assert fiona.listlayers('/coutwildrnp.shp', vfs=vfs) == ['coutwildrnp'] + with pytest.warns(FionaDeprecationWarning): + assert fiona.listlayers('/coutwildrnp.shp', vfs=vfs) == ['coutwildrnp'] def test_list_not_existing(data_dir): @@ -59,3 +60,15 @@ def test_invalid_path_ioerror(): with pytest.raises(DriverError): fiona.listlayers("foobar") + + +def test_listing_file(path_coutwildrnp_json): + """list layers from an open file object""" + with open(path_coutwildrnp_json, "rb") as f: + assert len(fiona.listlayers(f)) == 1 + + +def test_listing_pathobj(path_coutwildrnp_json): + """list layers from a Path object""" + pathlib = pytest.importorskip("pathlib") + assert len(fiona.listlayers(pathlib.Path(path_coutwildrnp_json))) == 1 diff -Nru fiona-1.8.6/tests/test_open.py fiona-1.8.11/tests/test_open.py --- fiona-1.8.6/tests/test_open.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_open.py 2019-11-08 02:24:40.000000000 +0000 @@ -1,8 +1,15 @@ """Tests of file opening""" +import os import fiona def test_open_shp(path_coutwildrnp_shp): """Open a shapefile""" assert fiona.open(path_coutwildrnp_shp) + + +def test_open_filename_with_exclamation(data_dir): + path = os.path.relpath(os.path.join(data_dir, "!test.geojson")) + assert os.path.exists(path), "Missing test data" + assert fiona.open(path), "Failed to open !test.geojson" diff -Nru fiona-1.8.6/tests/test_vfs.py fiona-1.8.11/tests/test_vfs.py --- fiona-1.8.6/tests/test_vfs.py 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/tests/test_vfs.py 2019-11-08 02:24:40.000000000 +0000 @@ -6,6 +6,7 @@ import boto3 import fiona +from fiona.errors import FionaDeprecationWarning from fiona.vfs import vsi_path, parse_paths from .test_collection import TestReading @@ -92,7 +93,7 @@ @pytest.fixture(autouse=True) def zipfile(self, data_dir, path_coutwildrnp_zip): vfs = 'zip://{}'.format(path_coutwildrnp_zip) - self.c = fiona.open("/coutwildrnp.shp", "r", vfs=vfs) + self.c = fiona.open(vfs + "!coutwildrnp.shp", "r") self.path = os.path.join(data_dir, 'coutwildrnp.zip') yield self.c.close() @@ -123,7 +124,7 @@ @pytest.fixture(autouse=True) def zipfile(self, path_coutwildrnp_zip): vfs = 'zip://{}'.format(os.path.abspath(path_coutwildrnp_zip)) - self.c = fiona.open("/coutwildrnp.shp", "r", vfs=vfs) + self.c = fiona.open(vfs + "!coutwildrnp.shp", "r") yield self.c.close() @@ -138,19 +139,12 @@ assert self.c.path.startswith('/vsizip/') -#class TestTarArchiveReading(TestVsiReading): -# @pytest.fixture(autouse=True) -# def tarfile(self, data_dir, path_coutwildrnp_tar): -# vfs = "tar://{}".format(path_coutwildrnp_tar) -# self.c = fiona.open("/testing/coutwildrnp.shp", "r", vfs=vfs) -# self.path = os.path.join(data_dir, 'coutwildrnp.tar') -# yield @pytest.mark.usefixtures('uttc_path_coutwildrnp_tar', 'uttc_data_dir') class TarArchiveReadingTest(VsiReadingTest): def setUp(self): vfs = "tar://{}".format(self.path_coutwildrnp_tar) - self.c = fiona.open("/testing/coutwildrnp.shp", "r", vfs=vfs) + self.c = fiona.open(vfs + "!testing/coutwildrnp.shp", "r") self.path = os.path.join(self.data_dir, 'coutwildrnp.tar') def tearDown(self): diff -Nru fiona-1.8.6/.travis.yml fiona-1.8.11/.travis.yml --- fiona-1.8.6/.travis.yml 2019-03-19 04:25:07.000000000 +0000 +++ fiona-1.8.11/.travis.yml 2019-11-08 02:24:40.000000000 +0000 @@ -1,5 +1,11 @@ +dist: trusty + language: python -sudo: false + +python: + - "2.7" + - "3.6" + cache: directories: - $GDALINST @@ -11,50 +17,48 @@ - PIP_FIND_LINKS=file://$HOME/.cache/pip/wheels - GDALINST=$HOME/gdalinstall - GDALBUILD=$HOME/gdalbuild + - PROJINST=$HOME/gdalinstall + - PROJBUILD=$HOME/projbuild matrix: - - GDALVERSION="1.11.5" - - GDALVERSION="2.0.3" - - GDALVERSION="2.1.4" - - GDALVERSION="2.2.4" - - GDALVERSION="2.3.2" - - GDALVERSION="trunk" + - GDALVERSION="1.11.5" PROJVERSION="4.8.0" + - GDALVERSION="2.0.3" PROJVERSION="4.9.3" + - GDALVERSION="2.1.4" PROJVERSION="4.9.3" + - GDALVERSION="2.2.4" PROJVERSION="4.9.3" + - GDALVERSION="2.3.3" PROJVERSION="4.9.3" + - GDALVERSION="2.4.2" PROJVERSION="4.9.3" + - GDALVERSION="3.0.1" PROJVERSION="6.1.1" + - GDALVERSION="master" PROJVERSION="6.1.1" matrix: allow_failures: - - env: GDALVERSION="trunk" + - env: GDALVERSION="master" PROJVERSION="6.1.1" addons: apt: packages: - - gdal-bin - - libproj-dev - - libhdf5-serial-dev - libgdal-dev - libatlas-dev - libatlas-base-dev - gfortran -python: - - "2.7" - - "3.6" - before_install: - pip install -U pip - pip install wheel coveralls>=1.1 --upgrade - pip install setuptools==36.0.1 - pip install wheel + - . ./scripts/travis_proj_install.sh - . ./scripts/travis_gdal_install.sh - export PATH=$GDALINST/gdal-$GDALVERSION/bin:$PATH - export LD_LIBRARY_PATH=$GDALINST/gdal-$GDALVERSION/lib:$LD_LIBRARY_PATH - export GDAL_DATA=$GDALINST/gdal-$GDALVERSION/share/gdal - - export PROJ_LIB=/usr/share/proj + - export PROJ_LIB=$GDALINST/gdal-$GDALVERSION/share/proj - gdal-config --version install: - - pip install -r requirements-dev.txt - - if [ "$GDALVERSION" = "trunk" ]; then echo "Using gdal trunk"; elif [ $(gdal-config --version) == "$GDALVERSION" ]; then echo "Using gdal $GDALVERSION"; else echo "NOT using gdal $GDALVERSION as expected; aborting"; exit 1; fi - - pip install --upgrade --force-reinstall --global-option=build_ext --global-option='-I$GDALINST/gdal-$GDALVERSION/include' --global-option='-L$GDALINST/gdal-$GDALVERSION/lib' --global-option='-R$GDALINST/gdal-$GDALVERSION/lib' -e . - - pip install -e .[test] + - if [ "$GDALVERSION" = "master" ]; then echo "Using gdal master"; elif [ $(gdal-config --version) == "$GDALVERSION" ]; then echo "Using gdal $GDALVERSION"; else echo "NOT using gdal $GDALVERSION as expected; aborting"; exit 1; fi + - "python -m pip wheel -r requirements-dev.txt" + - "python -m pip install -r requirements-dev.txt" + - "GDAL_CONFIG=$GDALINST/gdal-$GDALVERSION/bin/gdal-config python -m pip install --upgrade --force-reinstall --no-use-pep517 -e .[test]" - fio --version - gdal-config --version - fio --gdal-version