[Git][debian-gis-team/fiona][master] 4 commits: New upstream version 1.8.4

Bas Couwenberg gitlab at salsa.debian.org
Tue Dec 11 09:09:33 GMT 2018


Bas Couwenberg pushed to branch master at Debian GIS Project / fiona


Commits:
94b7ee6f by Bas Couwenberg at 2018-12-11T08:47:34Z
New upstream version 1.8.4
- - - - -
3b22b5e7 by Bas Couwenberg at 2018-12-11T08:47:35Z
Merge tag 'upstream/1.8.4'

Upstream version 1.8.4

- - - - -
099e72de by Bas Couwenberg at 2018-12-11T08:47:51Z
New upstream release.

- - - - -
6427a422 by Bas Couwenberg at 2018-12-11T08:49:09Z
Set distribution to unstable.

- - - - -


8 changed files:

- CHANGES.txt
- debian/changelog
- fiona/__init__.py
- fiona/_env.pyx
- fiona/_transform.pyx
- fiona/collection.py
- tests/test_schema.py
- + tests/test_transform.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -3,8 +3,17 @@ Changes
 
 All issue numbers are relative to https://github.com/Toblerity/Fiona/issues.
 
-1.8.3 (TBD)
------------
+1.8.4 (2018-12-10)
+------------------
+
+- 3D geometries can now be transformed with a specified precision (#523).
+- A bug producing a spurious DriverSupportError for Shapefiles with a "time"
+  field (#692) has been fixed.
+- Patching of the GDAL_DATA environment variable was accidentally left in place
+  in 1.8.3 and now has been removed.
+
+1.8.3 (2018-11-30)
+------------------
 
 - The RASTERIO_ENV config environment marker this project picked up from
   Rasterio has been renamed to FIONA_ENV (#665).


=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+fiona (1.8.4-1) unstable; urgency=medium
+
+  * Team upload.
+  * New upstream release.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Tue, 11 Dec 2018 09:48:55 +0100
+
 fiona (1.8.3-1) unstable; urgency=medium
 
   * Team upload.


=====================================
fiona/__init__.py
=====================================
@@ -101,7 +101,7 @@ import uuid
 
 
 __all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width']
-__version__ = "1.8.3"
+__version__ = "1.8.4"
 __gdal_version__ = get_gdal_release_name()
 
 gdal_version = get_gdal_version_tuple()


=====================================
fiona/_env.pyx
=====================================
@@ -327,7 +327,6 @@ cdef class GDALEnv(ConfigEnv):
 
                         if path:
                             self.update_config_options(GDAL_DATA=path)
-                            os.environ['GDAL_DATA'] = path
                             log.debug("GDAL_DATA not found in environment, set to %r.", path)
 
                     if 'PROJ_LIB' not in os.environ:


=====================================
fiona/_transform.pyx
=====================================
@@ -154,37 +154,66 @@ def _transform_geom(
             _csl.CSLDestroy(options)
         _crs.OSRRelease(src)
         _crs.OSRRelease(dst)
+
     else:
         g = geom
+
     if precision >= 0:
+
         if g['type'] == 'Point':
-            x, y = g['coordinates']
+            coords = list(g['coordinates'])
+            x, y = coords[:2]
             x = round(x, precision)
             y = round(y, precision)
             new_coords = [x, y]
+            if len(coords) == 3:
+                z = coords[2]
+                new_coords.append(round(z, precision))
+
         elif g['type'] in ['LineString', 'MultiPoint']:
-            xp, yp = zip(*g['coordinates'])
+            coords = list(zip(*g['coordinates']))
+            xp, yp = coords[:2]
             xp = [round(v, precision) for v in xp]
             yp = [round(v, precision) for v in yp]
-            new_coords = list(zip(xp, yp))
+            if len(coords) == 3:
+                zp = coords[2]
+                zp = [round(v, precision) for v in zp]
+                new_coords = list(zip(xp, yp, zp))
+            else:
+                new_coords = list(zip(xp, yp))
+
         elif g['type'] in ['Polygon', 'MultiLineString']:
             new_coords = []
             for piece in g['coordinates']:
-                xp, yp = zip(*piece)
+                coords = list(zip(*piece))
+                xp, yp = coords[:2]
                 xp = [round(v, precision) for v in xp]
                 yp = [round(v, precision) for v in yp]
-                new_coords.append(list(zip(xp, yp)))
+                if len(coords) == 3:
+                    zp = coords[2]
+                    zp = [round(v, precision) for v in zp]
+                    new_coords.append(list(zip(xp, yp, zp)))
+                else:
+                    new_coords.append(list(zip(xp, yp)))
+
         elif g['type'] == 'MultiPolygon':
             parts = g['coordinates']
             new_coords = []
             for part in parts:
                 inner_coords = []
                 for ring in part:
-                    xp, yp = zip(*ring)
+                    coords = list(zip(*ring))
+                    xp, yp = coords[:2]
                     xp = [round(v, precision) for v in xp]
                     yp = [round(v, precision) for v in yp]
-                    inner_coords.append(list(zip(xp, yp)))
+                    if len(coords) == 3:
+                        zp = coords[2]
+                        zp = [round(v, precision) for v in zp]
+                        inner_coords.append(list(zip(xp, yp, zp)))
+                    else:
+                        inner_coords.append(list(zip(xp, yp)))
                 new_coords.append(inner_coords)
+
         g['coordinates'] = new_coords
 
     return g


=====================================
fiona/collection.py
=====================================
@@ -11,9 +11,7 @@ from fiona.ogrext import Session, WritingSession
 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._env import driver_count
-from fiona._env import (
-    calc_gdal_version_num, get_gdal_version_num, get_gdal_release_name)
+from fiona._env import driver_count, get_gdal_release_name, get_gdal_version_tuple
 from fiona.env import Env
 from fiona.errors import FionaDeprecationWarning
 from fiona.drvsupport import supported_drivers
@@ -77,8 +75,7 @@ class Collection(object):
             raise TypeError("invalid archive: %r" % archive)
 
         # Check GDAL version against drivers
-        if (driver == "GPKG" and
-                get_gdal_version_num() < calc_gdal_version_num(1, 11, 0)):
+        if (driver == "GPKG" and get_gdal_version_tuple() < (1, 11, 0)):
             raise DriverError(
                 "GPKG driver requires GDAL 1.11.0, fiona was compiled "
                 "against: {}".format(get_gdal_release_name()))
@@ -409,8 +406,9 @@ class Collection(object):
 
         See GH#572 for discussion.
         """
-        gdal_version_major = get_gdal_version_num() // 1000000
-        for field in self._schema["properties"]:
+        gdal_version_major = get_gdal_version_tuple().major
+
+        for field in self._schema["properties"].values():
             field_type = field.split(":")[0]
             if self._driver == "ESRI Shapefile":
                 if field_type == "datetime":


=====================================
tests/test_schema.py
=====================================
@@ -1,12 +1,13 @@
+import fiona
+from fiona.errors import SchemaError, UnsupportedGeometryTypeError, \
+    DriverSupportError
+from fiona.schema import FIELD_TYPES, normalize_field_type
 import os
 import tempfile
 
 import pytest
 
-import fiona
-from fiona.errors import SchemaError, UnsupportedGeometryTypeError
-from fiona.schema import FIELD_TYPES, normalize_field_type
-from fiona.env import calc_gdal_version_num, get_gdal_version_num
+from .conftest import requires_only_gdal1, requires_gdal2
 
 
 def test_schema_ordering_items(tmpdir):
@@ -147,10 +148,8 @@ def test_unsupported_geometry_type():
             'geometry': 'BOGUS',
             'properties': {}}}
 
-    try:
+    with pytest.raises(UnsupportedGeometryTypeError):
         fiona.open(tmpfile, 'w', **profile)
-    except UnsupportedGeometryTypeError:
-        assert True
 
 
 @pytest.mark.parametrize('x', list(range(1, 10)))
@@ -158,8 +157,7 @@ def test_normalize_int32(x):
     assert normalize_field_type('int:{}'.format(x)) == 'int32'
 
 
- at pytest.mark.skipif(get_gdal_version_num() < calc_gdal_version_num(2, 0, 0),
-                    reason="64-bit integer fields require GDAL 2+")
+ at requires_gdal2
 @pytest.mark.parametrize('x', list(range(10, 20)))
 def test_normalize_int64(x):
     assert normalize_field_type('int:{}'.format(x)) == 'int64'
@@ -197,3 +195,31 @@ def test_normalize_std(x):
 def test_normalize_error():
     with pytest.raises(SchemaError):
         assert normalize_field_type('thingy')
+
+
+ at requires_only_gdal1
+ at pytest.mark.parametrize('field_type', ['time', 'datetime'])
+def test_check_schema_driver_support_shp(tmpdir, field_type):
+
+    with pytest.raises(DriverSupportError):
+            name = str(tmpdir.join('test_scheme.shp'))
+            items = [('field1', field_type)]
+            with fiona.open(name, 'w',
+                            driver="ESRI Shapefile",
+                            schema={
+                                'geometry': 'LineString',
+                                'properties': items}) as c:
+                pass
+
+
+ at requires_only_gdal1
+def test_check_schema_driver_support_gpkg(tmpdir):
+    with pytest.raises(DriverSupportError):
+        name = str(tmpdir.join('test_scheme.gpkg'))
+        items = [('field1', 'time')]
+        with fiona.open(name, 'w',
+                        driver="GPKG",
+                        schema={
+                            'geometry': 'LineString',
+                            'properties': items}) as c:
+            pass


=====================================
tests/test_transform.py
=====================================
@@ -0,0 +1,50 @@
+"""Tests of the transform submodule"""
+
+import math
+
+import pytest
+
+from fiona import transform
+
+
+ at pytest.mark.parametrize(
+    "geom",
+    [
+        {"type": "Point", "coordinates": [0.0, 0.0, 1000.0]},
+        {
+            "type": "LineString",
+            "coordinates": [[0.0, 0.0, 1000.0], [0.1, 0.1, -1000.0]],
+        },
+        {
+            "type": "MultiPoint",
+            "coordinates": [[0.0, 0.0, 1000.0], [0.1, 0.1, -1000.0]],
+        },
+        {
+            "type": "Polygon",
+            "coordinates": [
+                [
+                    [0.0, 0.0, 1000.0],
+                    [0.1, 0.1, -1000.0],
+                    [0.1, -0.1, math.pi],
+                    [0.0, 0.0, 1000.0],
+                ]
+            ],
+        },
+        {
+            "type": "MultiPolygon",
+            "coordinates": [
+                [
+                    [
+                        [0.0, 0.0, 1000.0],
+                        [0.1, 0.1, -1000.0],
+                        [0.1, -0.1, math.pi],
+                        [0.0, 0.0, 1000.0],
+                    ]
+                ]
+            ],
+        },
+    ],
+)
+def test_transform_geom_with_z(geom):
+    """Transforming a geom with Z succeeds"""
+    g2 = transform.transform_geom("epsg:4326", "epsg:3857", geom, precision=3)



View it on GitLab: https://salsa.debian.org/debian-gis-team/fiona/compare/862cfdc78d6dc476c35c05792ba2391c6102edee...6427a4224eb7e26f5082a3c748475f564f78675a

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/fiona/compare/862cfdc78d6dc476c35c05792ba2391c6102edee...6427a4224eb7e26f5082a3c748475f564f78675a
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/20181211/17f9abe3/attachment-0001.html>


More information about the Pkg-grass-devel mailing list