Colleted esri_wkt and esri_wkt parsing into one function which works, and added find() methods in each mod for easier name-to-obj parsing

This commit is contained in:
Karim Bahgat
2015-07-30 16:00:45 +02:00
parent 59007ef1fb
commit bf5802ae51
13 changed files with 350 additions and 66 deletions
+25
View File
@@ -1,5 +1,30 @@
def find(unitname, crstype, strict=False):
if not strict:
unitname = unitname.lower()
for itemname,item in globals().items():
if itemname.startswith("_"):
continue
try:
if hasattr(item, crstype):
itemname = getattr(item, crstype)
# compare
if not strict:
itemname = itemname.lower()
if unitname == itemname:
return item
# special handling of wkt meters which has multiple possibilities
elif isinstance(itemname, Meter) and crstype.endswith("wkt") and not strict and unitname in ("meters","meter","metre"):
return item
except:
pass
else:
return None
class Meter:
proj4 = "m"
ogc_wkt = "Meters" # or is it metre?? sometimes even Meter?