Basic ogc wkt parsing into crsobj works.

Next:
- Comb through to smooth out kinks, like how to handle default values
such as datum (not always needed) or unit when not specified (on parsing
or on outputting). Or handling basic lat long crs without proj. Adding
wkt axis parsing. Cleaning messy wkt parsing maybe.
- And finally add esri wkt, copy paste mostly, but some small
differences.
This commit is contained in:
Karim Bahgat
2015-07-07 02:57:40 +02:00
parent ebccfc38dc
commit 59007ef1fb
9 changed files with 239 additions and 70 deletions
+18 -11
View File
@@ -33,18 +33,25 @@ def from_file(filepath):
return parser.from_esri_wkt(string)
elif filepath.endswith((".geojson",".json")):
crsinfo = json.load(filepath)["crs"]
if crsinfo["type"] == "name":
string = crsinfo["properties"]["name"]
return parser.from_unknown_text(string)
raw = open(filepath).read()
geoj = json.loads(raw)
if "crs" in geoj:
crsinfo = geoj["crs"]
elif crsinfo["type"] == "link":
url = crsinfo["properties"]["name"]
type = crsinfo["properties"].get("type")
return from_url(url, format=type)
else: raise Exception("invalid geojson crs type: must be either name or link")
if crsinfo["type"] == "name":
string = crsinfo["properties"]["name"]
return parser.from_unknown_text(string)
elif crsinfo["type"] == "link":
url = crsinfo["properties"]["name"]
type = crsinfo["properties"].get("type")
return loader.from_url(url, format=type)
else: raise Exception("invalid geojson crs type: must be either name or link")
else:
# assume default wgs84 as per the spec
return parser.from_epsg_code("4326")
## elif filepath.endswith((".tif",".tiff",".geotiff")):
## pass