Newer
Older
def is_valid(resource, file):
"""Check if the content is a readable GeoJSON file."""
with open(file.name, "rb") as f:
try:
geojson_data = geojson.load(f)
if isinstance(geojson_data, dict) and "type" in geojson_data:
return True
else:
resource["error"] = "JSON is not GeoJSON."
return False
except Exception as e:
resource["error"] = str(e)