forked from hans/Nominatim
amke Tiger import script work with python3
This commit is contained in:
@@ -3433,7 +3433,7 @@ def fipsstate(fips,countyfp):
|
|||||||
return tags
|
return tags
|
||||||
|
|
||||||
if fips not in fipscodes:
|
if fips not in fipscodes:
|
||||||
raise KeyError, 'missing FIPS code', fips
|
raise KeyError('missing FIPS code', fips)
|
||||||
|
|
||||||
state, statecode, isocode = fipscodes[fips]
|
state, statecode, isocode = fipscodes[fips]
|
||||||
county_fips_code = fips + "" + countyfp
|
county_fips_code = fips + "" + countyfp
|
||||||
@@ -3657,7 +3657,7 @@ def addressways(waylist, nodelist, first_id):
|
|||||||
distance = float(address_distance)
|
distance = float(address_distance)
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
for waykey, segments in waylist.iteritems():
|
for waykey, segments in waylist.items():
|
||||||
waykey = dict(waykey)
|
waykey = dict(waykey)
|
||||||
rsegments = []
|
rsegments = []
|
||||||
lsegments = []
|
lsegments = []
|
||||||
@@ -4023,7 +4023,7 @@ def compile_waylist( parsed_gisdata, blank_way_id ):
|
|||||||
#Group by iSource:way_id
|
#Group by iSource:way_id
|
||||||
for geom, tags in parsed_gisdata:
|
for geom, tags in parsed_gisdata:
|
||||||
way_key = tags.copy()
|
way_key = tags.copy()
|
||||||
way_key = ( way_key[iSource + ':way_id'], tuple( [(k,v) for k,v in way_key.iteritems()] ) )
|
way_key = ( way_key[iSource + ':way_id'], tuple( [(k,v) for k,v in way_key.items()] ) )
|
||||||
|
|
||||||
if way_key not in waylist:
|
if way_key not in waylist:
|
||||||
waylist[way_key] = []
|
waylist[way_key] = []
|
||||||
@@ -4031,7 +4031,7 @@ def compile_waylist( parsed_gisdata, blank_way_id ):
|
|||||||
waylist[way_key].append( geom )
|
waylist[way_key].append( geom )
|
||||||
|
|
||||||
ret = {}
|
ret = {}
|
||||||
for (way_id, way_key), segments in waylist.iteritems():
|
for (way_id, way_key), segments in waylist.items():
|
||||||
|
|
||||||
if way_id != blank_way_id:
|
if way_id != blank_way_id:
|
||||||
ret[way_key] = glom_all( segments )
|
ret[way_key] = glom_all( segments )
|
||||||
@@ -4047,35 +4047,35 @@ def shape_to_osm( shp_filename, base_filename, blank_way_id ):
|
|||||||
|
|
||||||
import_guid = time.strftime( '%Y%m%d%H%M%S' )
|
import_guid = time.strftime( '%Y%m%d%H%M%S' )
|
||||||
|
|
||||||
print "parsing shpfile"
|
print("parsing shpfile")
|
||||||
parsed_features = parse_shp_for_osm( shp_filename )
|
parsed_features = parse_shp_for_osm( shp_filename )
|
||||||
|
|
||||||
print "compiling nodelist"
|
print("compiling nodelist")
|
||||||
i, nodelist = compile_nodelist( parsed_features )
|
i, nodelist = compile_nodelist( parsed_features )
|
||||||
|
|
||||||
print "compiling waylist"
|
print("compiling waylist")
|
||||||
waylist = compile_waylist( parsed_features, blank_way_id )
|
waylist = compile_waylist( parsed_features, blank_way_id )
|
||||||
|
|
||||||
filenumber = 1
|
filenumber = 1
|
||||||
objectcount = 0
|
objectcount = 0
|
||||||
seen = {}
|
seen = {}
|
||||||
|
|
||||||
print "preparing address ways"
|
print("preparing address ways")
|
||||||
ret = addressways(waylist, nodelist, i)
|
ret = addressways(waylist, nodelist, i)
|
||||||
osm_filename = "%s%d.osm" % (base_filename, filenumber)
|
osm_filename = "%s%d.osm" % (base_filename, filenumber)
|
||||||
print "writing %s" %osm_filename
|
print("writing %s" %osm_filename)
|
||||||
fp = open( osm_filename, "w" )
|
fp = open( osm_filename, "w" )
|
||||||
fp.write( "\n".join( ret ) )
|
fp.write( "\n".join( ret ) )
|
||||||
fp.close()
|
fp.close()
|
||||||
filenumber += 1
|
filenumber += 1
|
||||||
|
|
||||||
|
|
||||||
print "constructing osm xml file"
|
print("constructing osm xml file")
|
||||||
ret = []
|
ret = []
|
||||||
ret.append( "<?xml version='1.0' encoding='UTF-8'?>" )
|
ret.append( "<?xml version='1.0' encoding='UTF-8'?>" )
|
||||||
ret.append( "<osm version='0.6' generator='shape_to_osm.py'>" )
|
ret.append( "<osm version='0.6' generator='shape_to_osm.py'>" )
|
||||||
|
|
||||||
for waykey, segments in waylist.iteritems():
|
for waykey, segments in waylist.items():
|
||||||
for segment in segments:
|
for segment in segments:
|
||||||
#write the nodes
|
#write the nodes
|
||||||
for point in segment:
|
for point in segment:
|
||||||
@@ -4124,7 +4124,7 @@ def shape_to_osm( shp_filename, base_filename, blank_way_id ):
|
|||||||
if objectcount > maxNodes: #Write a file
|
if objectcount > maxNodes: #Write a file
|
||||||
ret.append( "</osm>" )
|
ret.append( "</osm>" )
|
||||||
osm_filename = "%s%d.osm" % (base_filename, filenumber)
|
osm_filename = "%s%d.osm" % (base_filename, filenumber)
|
||||||
print "writing %s" %osm_filename
|
print("writing %s" %osm_filename)
|
||||||
fp = open( osm_filename, "w" )
|
fp = open( osm_filename, "w" )
|
||||||
fp.write( "\n".join( ret ) )
|
fp.write( "\n".join( ret ) )
|
||||||
fp.close()
|
fp.close()
|
||||||
@@ -4139,7 +4139,7 @@ def shape_to_osm( shp_filename, base_filename, blank_way_id ):
|
|||||||
ret.append( "</osm>" )
|
ret.append( "</osm>" )
|
||||||
|
|
||||||
osm_filename = "%s%d.osm" % (base_filename, filenumber)
|
osm_filename = "%s%d.osm" % (base_filename, filenumber)
|
||||||
print "writing %s" %osm_filename
|
print("writing %s" %osm_filename)
|
||||||
fp = open( osm_filename, "w" )
|
fp = open( osm_filename, "w" )
|
||||||
fp.write( "\n".join( ret ) )
|
fp.write( "\n".join( ret ) )
|
||||||
fp.close()
|
fp.close()
|
||||||
@@ -4147,7 +4147,7 @@ def shape_to_osm( shp_filename, base_filename, blank_way_id ):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys, os.path
|
import sys, os.path
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print "%s filename.shp [filename.osm]" % sys.argv[0]
|
print("%s filename.shp [filename.osm]" % sys.argv[0])
|
||||||
sys.exit()
|
sys.exit()
|
||||||
shape = sys.argv[1]
|
shape = sys.argv[1]
|
||||||
if len(sys.argv) > 2:
|
if len(sys.argv) > 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user