]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/tigerAddressImport.py
use Result class in reverse geocoding
[nominatim.git] / utils / tigerAddressImport.py
index 1eb10d76c6c4216aa1420179429d6889e36f6af7..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")
@@ -3893,8 +3901,8 @@ def addressways(waylist, nodelist, first_id):
   #                  ret.append( "<tag k=\"source\" v=\"%s_import_v%s_%s\" />" % (iSource, VERSION, import_guid) )
  #                   ret.append( "<tag k=\"attribution\" v=\"%s\" />" % (iAttrib) )
 #                    ret.append( "</way>" )
-
-                    ret.append( "select tigger_create_interpolation(ST_GeomFromText('LINESTRING(%s)',4326), '%s', '%s', '%s', '%s', '%s', '%s');" %
+                    # call new tiger_line_import function to save the lines in the DB.
+                    ret.append( "select tiger_line_import(ST_GeomFromText('LINESTRING(%s)',4326), '%s', '%s', '%s', '%s', '%s', '%s');" %
                                 ( ",".join(rlinestring), rfromadd.replace("'", "''"), rtoadd.replace("'", "''"), interpolationtype.replace("'", "''"), name.replace("'", "''"), county.replace("'", "''"), zipr.replace("'", "''") ) )
 
                 if left:
@@ -3919,7 +3927,7 @@ def addressways(waylist, nodelist, first_id):
                             interpolationtype = "all";
                     else:
                         interpolationtype = "all";
-                    ret.append( "select tigger_create_interpolation(ST_GeomFromText('LINESTRING(%s)',4326), '%s', '%s', '%s', '%s', '%s', '%s');" %
+                    ret.append( "select tiger_line_import(ST_GeomFromText('LINESTRING(%s)',4326), '%s', '%s', '%s', '%s', '%s', '%s');" %
                                 ( ",".join(llinestring), lfromadd.replace("'", "''"), ltoadd.replace("'", "''"), interpolationtype.replace("'", "''"), name.replace("'", "''"), county.replace("'", "''"), zipl.replace("'", "''") ) )
 
     return ret