From 4a824ca8452e546b1894647762055bb90a2c2493 Mon Sep 17 00:00:00 2001 From: Marc Date: Wed, 28 Sep 2011 23:58:34 +0200 Subject: [PATCH] bug fix: bad handling of Flight levels, bad handling of boolean field --- airspace/shp.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/airspace/shp.py b/airspace/shp.py index 5ef53a7..04e27ab 100644 --- a/airspace/shp.py +++ b/airspace/shp.py @@ -29,11 +29,11 @@ from datetime import date def setAlti(fieldName, dataDict, feature): upFN = fieldName.upper() - alti, unit = dataDict.get('basealti', (None,None)) + alti, unit = dataDict.get('basealti', ("","")) ref = dataDict.get('ref', "") flevel = dataDict.get('flevel', -1) - sfc = dataDict.get('fromground', 0) - unl = dataDict.get('nolimit', 0) + sfc = 1 if dataDict.get('fromground', False) else 0 + unl = 1 if dataDict.get('nolimit', False) else 0 if alti and unit: if unit == "M": @@ -42,6 +42,9 @@ def setAlti(fieldName, dataDict, feature): feature.SetField(upFN + "_ALTIM", int(alti) * 0.3048) feature.SetField(upFN + "_ALTI", str(alti) + " " + unit) + elif flevel != -1: + feature.SetField(upFN + "_ALTIM", flevel * 100 * 0.3048) + feature.SetField(upFN + "_ALTI", "") else: feature.SetField(upFN + "_ALTIM", -1) feature.SetField(upFN + "_ALTI", "") @@ -116,7 +119,6 @@ def writeToShp(filename, zones): for z in zones: meta,geometry = z.meta, z.geometry - buf = osgeo.ogr.CreateGeometryFromWkt(shapely.wkt.dumps(geometry)) feature = osgeo.ogr.Feature(dstLayer.GetLayerDefn()) feature.SetGeometry(buf)