diff --git a/.travis.yml b/.travis.yml index 1ba79c7..e1f01b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ python: - 3.5 - 3.6 - 3.7 +- 3.8 install: - pip install nose - pip install flake8 diff --git a/esrijson/geometry.py b/esrijson/geometry.py index 1d65e3d..cf646da 100644 --- a/esrijson/geometry.py +++ b/esrijson/geometry.py @@ -99,11 +99,23 @@ def from_shape(obj, wkid=None): if type_ == 'GeometryCollection': # No concept of GeometryCollection in esri_json therefore we take # the first one only + # We also may have a collections of collections if len(obj['geometries']) == 0: return esri_geom first = obj['geometries'][0] - type_ = first.pop('type') - coords = first.pop('coordinates') + if type(first) == list: + types_ = [d['type'] for d in first] + coords = [d['coordinates'] for d in first] + if len(set(types_)) == 1 and \ + types_[0] in ('Point', 'LineString', 'Polygon'): + type_ = 'Multi' + types_[0] + else: + raise TypeError('Cannot convert collection of different ' + + 'types into an Esri Multi(Point|LineString' + + '|Polygon)') + else: + type_ = first.pop('type') + coords = first.pop('coordinates') else: coords = obj.pop('coordinates') if type_: diff --git a/setup.py b/setup.py index aca8f8e..873eae0 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ long_description = fh.read() setup(name='esrijson', - version='0.4.3', + version='0.4.4', description='Bindings and utilities for EsriJSON', long_description=long_description, long_description_content_type="text/markdown", @@ -21,6 +21,7 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Topic :: Scientific/Engineering :: GIS', 'Topic :: Software Development :: Libraries :: Python Modules' ],