[Git][debian-gis-team/fiona][upstream] New upstream version 1.8.9
Bas Couwenberg
gitlab at salsa.debian.org
Tue Oct 22 05:25:15 BST 2019
Bas Couwenberg pushed to branch upstream at Debian GIS Project / fiona
Commits:
bb128d7e by Bas Couwenberg at 2019-10-22T04:02:45Z
New upstream version 1.8.9
- - - - -
26 changed files:
- .travis.yml
- CHANGES.txt
- fiona/__init__.py
- fiona/_crs.pxd
- fiona/_crs.pyx
- fiona/_shim1.pxd
- fiona/_shim1.pyx
- fiona/_shim2.pxd
- fiona/_shim2.pyx
- fiona/_shim22.pxd
- fiona/_shim22.pyx
- + fiona/_shim3.pxd
- + fiona/_shim3.pyx
- fiona/_transform.pyx
- fiona/gdal.pxi
- fiona/ogrext.pyx
- fiona/ogrext1.pxd
- fiona/ogrext2.pxd
- + fiona/ogrext3.pxd
- scripts/travis_gdal_install.sh
- + scripts/travis_proj_install.sh
- setup.py
- tests/conftest.py
- tests/test__env.py
- tests/test_crs.py
- tests/test_geopackage.py
Changes:
=====================================
.travis.yml
=====================================
@@ -1,5 +1,11 @@
+dist: trusty
+
language: python
-sudo: false
+
+python:
+ - "2.7"
+ - "3.6"
+
cache:
directories:
- $GDALINST
@@ -11,50 +17,48 @@ env:
- 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="trunk" PROJVERSION="6.1.1"
matrix:
allow_failures:
- - env: GDALVERSION="trunk"
+ - env: GDALVERSION="trunk" 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]
+ - "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
=====================================
CHANGES.txt
=====================================
@@ -3,6 +3,14 @@ Changes
All issue numbers are relative to https://github.com/Toblerity/Fiona/issues.
+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)
------------------
=====================================
fiona/__init__.py
=====================================
@@ -101,7 +101,7 @@ import uuid
__all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width']
-__version__ = "1.8.8"
+__version__ = "1.8.9"
__gdal_version__ = get_gdal_release_name()
gdal_version = get_gdal_version_tuple()
=====================================
fiona/_crs.pxd
=====================================
@@ -12,7 +12,6 @@ cdef extern from "ogr_srs_api.h":
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)
=====================================
fiona/_crs.pyx
=====================================
@@ -10,16 +10,20 @@ import logging
from six import string_types
from fiona cimport _cpl
+from fiona._shim cimport osr_get_name, osr_set_traditional_axis_mapping_strategy
+
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)
@@ -31,6 +35,7 @@ def crs_to_wkt(crs):
proj_b = crs.encode('utf-8')
proj_c = proj_b
OSRSetFromUserInput(cogr_srs, proj_c)
+
elif isinstance(crs, dict):
# EPSG is a special case.
init = crs.get('init')
@@ -53,12 +58,11 @@ def crs_to_wkt(crs):
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)
-
+ osr_set_traditional_axis_mapping_strategy(cogr_srs)
OSRExportToWkt(cogr_srs, &proj_c)
if proj_c == NULL:
=====================================
fiona/_shim1.pxd
=====================================
@@ -19,6 +19,8 @@ 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)
from fiona._shim cimport OGR_F_GetFieldAsInteger as OGR_F_GetFieldAsInteger64
from fiona._shim cimport OGR_F_SetFieldInteger as OGR_F_SetFieldInteger64
=====================================
fiona/_shim1.pyx
=====================================
@@ -123,3 +123,11 @@ cdef bint check_capability_create_layer(void *cogr_ds):
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)
=====================================
fiona/_shim2.pxd
=====================================
@@ -12,3 +12,5 @@ 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)
=====================================
fiona/_shim2.pyx
=====================================
@@ -125,3 +125,8 @@ cdef bint check_capability_create_layer(void *cogr_ds):
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)
=====================================
fiona/_shim22.pxd
=====================================
@@ -12,3 +12,5 @@ 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)
=====================================
fiona/_shim22.pyx
=====================================
@@ -132,3 +132,9 @@ cdef bint check_capability_create_layer(void *cogr_ds):
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)
=====================================
fiona/_shim3.pxd
=====================================
@@ -0,0 +1,16 @@
+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)
=====================================
fiona/_shim3.pyx
=====================================
@@ -0,0 +1,149 @@
+"""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)
+
+
+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, <const char *>k, <const char *>v)
+
+ open_opts = CSLAddNameValue(open_opts, "VALIDATE_OPEN_OPTIONS", "NO")
+
+ try:
+ cogr_ds = exc_wrap_pointer(
+ GDALOpenEx(path_c, flags, <const char *const *>drvs, <const char *const *>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, <const char *>k, <const char *>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)
=====================================
fiona/_transform.pyx
=====================================
@@ -8,6 +8,7 @@ import logging
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 @@ cdef void *_crs_from_crs(object crs):
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 @@ cdef void *_crs_from_crs(object crs):
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')
=====================================
fiona/gdal.pxi
=====================================
@@ -88,7 +88,6 @@ cdef extern from "ogr_srs_api.h" nogil:
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)
=====================================
fiona/ogrext.pyx
=====================================
@@ -36,7 +36,7 @@ from fiona.rfc3339 import FionaDateType, FionaDateTimeType, FionaTimeType
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 class WritingSession(Session):
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
@@ -995,6 +995,7 @@ cdef class WritingSession(Session):
if auth.upper() == 'EPSG':
log.debug("Setting EPSG: %s", val)
OSRImportFromEPSG(cogr_srs, int(val))
+ osr_set_traditional_axis_mapping_strategy(cogr_srs)
else:
params = []
col_crs['wktext'] = True
@@ -1008,13 +1009,11 @@ cdef class WritingSession(Session):
proj_b = proj.encode('utf-8')
proj_c = proj_b
OSRImportFromProj4(cogr_srs, proj_c)
+ osr_set_traditional_axis_mapping_strategy(cogr_srs)
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:
OGRReleaseDataSource(self.cogr_ds)
self.cogr_ds = NULL
=====================================
fiona/ogrext1.pxd
=====================================
@@ -151,13 +151,13 @@ cdef extern from "ogr_srs_api.h":
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)
=====================================
fiona/ogrext2.pxd
=====================================
@@ -219,13 +219,13 @@ cdef extern from "ogr_srs_api.h":
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)
=====================================
fiona/ogrext3.pxd
=====================================
@@ -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)
=====================================
scripts/travis_gdal_install.sh
=====================================
@@ -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 @@ GDALOPTS=" --with-ogr \
--without-libgrass \
--without-cfitsio \
--without-pcraster \
- --without-netcdf \
+ --with-netcdf \
--with-png=internal \
--with-jpeg=internal \
--without-gif \
@@ -34,12 +37,11 @@ GDALOPTS=" --with-ogr \
--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 @@ fi
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
=====================================
scripts/travis_proj_install.sh
=====================================
@@ -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
=====================================
setup.py
=====================================
@@ -77,7 +77,8 @@ class sdist_multi_gdal(sdist):
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 @@ 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)
+
ext_options = dict(
include_dirs=include_dirs,
library_dirs=library_dirs,
@@ -223,6 +226,9 @@ if source_is_repo and "clean" not in sys.argv:
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),
=====================================
tests/conftest.py
=====================================
@@ -264,6 +264,10 @@ requires_gdal24 = pytest.mark.skipif(
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")
+
@pytest.fixture(scope="class")
def unittest_data_dir(data_dir, request):
=====================================
tests/test__env.py
=====================================
@@ -39,6 +39,7 @@ def mock_debian(tmpdir):
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/3.0/pcs.csv")
tmpdir.ensure("share/proj/epsg")
return tmpdir
=====================================
tests/test_crs.py
=====================================
@@ -1,5 +1,7 @@
from fiona import crs, _crs
+from .conftest import requires_gdal_lt_3
+
def test_proj_keys():
assert len(crs.all_proj_keys) == 87
@@ -89,6 +91,7 @@ def test_to_string_unicode():
assert 'NAD83' in val
+ at 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 +109,13 @@ def test_towgs84():
assert 'towgs84' in crs.from_string(proj4)
+ at 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)
=====================================
tests/test_geopackage.py
=====================================
@@ -59,7 +59,6 @@ def test_write_gpkg(tmpdir):
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 @@ def test_write_multilayer_gpkg(tmpdir):
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
View it on GitLab: https://salsa.debian.org/debian-gis-team/fiona/commit/bb128d7ed69adb54d57c5ff5a63401f0180f8bac
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/fiona/commit/bb128d7ed69adb54d57c5ff5a63401f0180f8bac
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20191022/f044cdaf/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list