Bug#1025610: mapproxy: Test failures with Shapely 2.0
Bas Couwenberg
sebastic at xs4all.nl
Tue Dec 6 15:45:27 GMT 2022
Source: mapproxy
Version: 1.15.1-2
Severity: important
Tags: upstream
User: debian-gis at lists.debian.org
Usertags: shapely-2.0
Control: forwarded -1 https://github.com/mapproxy/mapproxy/issues/611
Dear Maintainer,
Your package has test failure with Shapely 2.0:
mapproxy/test/unit/test_geom.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
datasource = '/tmp/tmp9u365ato'
def load_geojson(datasource):
with open(datasource) as f:
geojson = json.load(f)
t = geojson.get('type')
if not t:
raise CoverageReadError("not a GeoJSON")
geometries = []
if t == 'FeatureCollection':
for f in geojson.get('features'):
geom = f.get('geometry')
if geom:
geometries.append(geom)
elif t == 'Feature':
if 'geometry' in geojson:
geometries.append(geojson['geometry'])
elif t in ('Polygon', 'MultiPolygon'):
geometries.append(geojson)
else:
log_config.warning('skipping feature of type %s from %s: not a Polygon/MultiPolygon',
t, datasource)
polygons = []
for geom in geometries:
> geom = shapely.geometry.asShape(geom)
E AttributeError: module 'shapely.geometry' has no attribute 'asShape'
mapproxy/util/geom.py:147: AttributeError
_ TestGeoJSONLoading.test_geojson[{"type": "MultiPolygon", "coordinates": [[[[0, 0], [10, 0], [10, 10], [0, 0]]], [[[20, 0], [30, 0], [20, 10], [20, 0]]]]}-geometry1] _
self = <mapproxy.test.unit.test_geom.TestGeoJSONLoading object at 0x7fc1d8d7af80>
geojson = '{"type": "MultiPolygon", "coordinates": [[[[0, 0], [10, 0], [10, 10], [0, 0]]], [[[20, 0], [30, 0], [20, 10], [20, 0]]]]}'
geometry = <MULTIPOLYGON (((0 0, 10 0, 10 10, 0 0)), ((20 0, 30 0, 20 10, 20 0)))>
@pytest.mark.parametrize('geojson,geometry', [
[ '''{"type": "Polygon", "coordinates": [[[0, 0], [10, 0], [10, 10], [0, 0]]]}''',
shapely.geometry.Polygon([[0, 0], [10, 0], [10, 10], [0, 0]]), ],
[ '''{"type": "MultiPolygon", "coordinates": [[[[0, 0], [10, 0], [10, 10], [0, 0]]], [[[20, 0], [30, 0], [20, 10], [20, 0]]]]}''',
shapely.geometry.Polygon([[0, 0], [10, 0], [10, 10], [0, 0]]).union(shapely.geometry.Polygon([[20, 0], [30, 0], [20, 10], [20, 0]])), ],
[ '''{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[0, 0], [10, 0], [10, 10], [0, 0]]]}}''',
shapely.geometry.Polygon([[0, 0], [10, 0], [10, 10], [0, 0]]), ],
[ '''{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[0, 0], [10, 0], [10, 10], [0, 0]]]}}]}''',
shapely.geometry.Polygon([[0, 0], [10, 0], [10, 10], [0, 0]]), ],
])
def test_geojson(self, geojson, geometry):
with TempFile() as fname:
with open(fname, 'w') as f:
f.write(geojson)
> polygon = load_geojson(fname)
____________________ TestTransform.test_multipolygon_transf ____________________
self = <mapproxy.test.unit.test_geom.TestTransform object at 0x7fc1d8d7a860>
def test_multipolygon_transf(self):
p1 = shapely.geometry.Polygon([(0, 0), (10, 0), (10, 10), (0, 10)])
p2 = shapely.geometry.Polygon([(20, 20), (30, 20), (30, 30), (20, 30)])
mp1 = shapely.geometry.MultiPolygon([p1, p2])
> mp2 = transform_geometry(SRS(4326), SRS(900913), mp1)
mapproxy/test/unit/test_geom.py:191:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
mapproxy/util/geom.py:222: in transform_geometry
result = transform_multipolygon(transf, geometry)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
transf = functools.partial(<function transform_xy at 0x7fc1da670d30>, SRS('EPSG:4326'), SRS('EPSG:900913'))
multipolygon = <MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0)), ((20 20, 30 20, 30 30, 20 30...>
def transform_multipolygon(transf, multipolygon):
transformed_polygons = []
> for polygon in multipolygon:
E TypeError: 'MultiPolygon' object is not iterable
mapproxy/util/geom.py:237: TypeError
The build does not fail because test failures are ignored.
Kind Regards,
Bas
More information about the Pkg-grass-devel
mailing list