]> git.openstreetmap.org Git - nominatim.git/commitdiff
Tiger 2017 data no longer contains -divroad- field
authormarc tobias <mtmail@gmx.net>
Fri, 20 Oct 2017 13:17:51 +0000 (15:17 +0200)
committermarc tobias <mtmail@gmx.net>
Fri, 20 Oct 2017 13:17:51 +0000 (15:17 +0200)
utils/tigerAddressImport.py

index 5499f50ea03663d4bab441b7b3c986fccc109056..bdbf3b25eb11372bba7deeb85dd1464f78e8f998 100755 (executable)
@@ -3469,6 +3469,12 @@ def parse_shp_for_osm( filename ):
 
     poLayer = poDS.GetLayer( 0 )
 
+    fieldNameList = []
+    layerDefinition = poLayer.GetLayerDefn()
+    for i in range(layerDefinition.GetFieldCount()):
+        fieldNameList.append(layerDefinition.GetFieldDefn(i).GetName())
+    # sys.stderr.write(",".join(fieldNameList))
+
     poLayer.ResetReading()
 
     ret = []
@@ -3561,11 +3567,13 @@ def parse_shp_for_osm( filename ):
                 if tags["highway"] != "primary":
                     tags["highway"] = "secondary"
 
-        divroad = poFeature.GetField("DIVROAD")
-        if divroad != None:
-            if divroad == "Y" and "highway" in tags and tags["highway"] == "residential":
-                tags["highway"] = "tertiary"
-            tags["tiger:separated"] = divroad
+        # TIGER 2017 no longer contains this field
+        if 'DIVROAD' in fieldNameList:
+            divroad = poFeature.GetField("DIVROAD")
+            if divroad != None:
+                if divroad == "Y" and "highway" in tags and tags["highway"] == "residential":
+                    tags["highway"] = "tertiary"
+                tags["tiger:separated"] = divroad
 
         statefp = poFeature.GetField("STATEFP")
         countyfp = poFeature.GetField("COUNTYFP")