Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cligj/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def iter_features(geojsonfile, func=None):
newfeat = func(to_feature(json.loads(line)))
if newfeat:
yield newfeat
else:
raise TypeError("Invalid type")

# Indented or pretty-printed GeoJSON features or feature
# collections will fail out of the try clause above since
Expand Down
8 changes: 8 additions & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ def test_geometrypretty(expected_features):
features = normalize_feature_inputs(None, 'features', ["tests/point_pretty_geom.txt"])
assert _geoms(features)[0] == _geoms(expected_features)[0]


def test_invalid_type():
features = normalize_feature_inputs(None, 'features', ["tests/twopoints_invalid_type.txt"])
with pytest.raises(TypeError):
_geoms(features)


class MockGeo(object):
def __init__(self, feature):
self.__geo_interface__ = feature
Expand All @@ -149,6 +156,7 @@ def test_normalize_feature_objects_bad(expected_features):
with pytest.raises(ValueError):
list(normalize_feature_objects(objs))


def test_to_feature(expected_features):
geom = expected_features[0]['geometry']
feat = {'type': 'Feature', 'properties': {}, 'geometry': geom}
Expand Down
2 changes: 2 additions & 0 deletions tests/twopoints_invalid_type.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"type": "MultiPoint", "geometry": [[134.519974,34.084171],[134.546188,34.081322],[134.546219,34.078766],[134.542374,34.081287]]}
{"type": "MultiPoint", "geometry": [[130.405380,33.571598],[130.383682,33.567059],[130.486740,33.652233],[130.455490,33.597004],[130.437195,33.601784],[130.447998,33.654606],[130.409592,33.606941]]}