for updated_route_system in updated_route_systems_list: # Header feature class: header = updated_route_system[0][0] header_updated = updated_route_system[0][1] arcpy.AddMessage('-- ' + header + '...') arcpy.TruncateTable_management(header) arcpy.Delete_management(header) arcpy.CopyFeatures_management(header_updated, header) arcpy.Delete_management(header_updated) # Itinerary table: itin = updated_route_system[1][0] itin_updated = updated_route_system[1][1] arcpy.AddMessage('-- ' + itin + '...') arcpy.TruncateTable_management(itin) arcpy.Delete_management(itin) itin_path = MHN.break_path(itin) # CreateTable & Append because CopyFeatures crashes randomly with large tables. arcpy.CreateTable_management(itin_path['dir'], itin_path['name'], itin_updated) arcpy.Append_management(itin_updated, itin, 'TEST') arcpy.Delete_management(itin_updated) # Replace old nodes. arcpy.AddMessage('-- ' + MHN.node + '...') arcpy.Delete_management(MHN.node) arcpy.CopyFeatures_management(new_nodes_CZ, MHN.node) arcpy.Delete_management(new_nodes_CZ) # Replace old arcs. arcpy.AddMessage('-- ' + MHN.arc + '...') arcpy.Delete_management(MHN.arc) arcpy.CopyFeatures_management(temp_arcs, MHN.arc)
arcpy.AddMessage('\nSaving changes to disk...') # Replace header feature class. arcpy.AddMessage('-- ' + MHN.bus_future + '...') arcpy.TruncateTable_management(MHN.bus_future) arcpy.Delete_management(MHN.bus_future) arcpy.CopyFeatures_management(updated_routes_fc, MHN.bus_future) arcpy.Delete_management(updated_routes_fc) # Replace itinerary table. itin_table = MHN.route_systems[MHN.bus_future][0] arcpy.AddMessage('-- ' + itin_table + '...') arcpy.TruncateTable_management(itin_table) arcpy.Delete_management(itin_table) itin_path = MHN.break_path(itin_table) arcpy.CreateTable_management(itin_path['dir'], itin_path['name'], updated_itin_table) arcpy.Append_management(updated_itin_table, itin_table, 'TEST') arcpy.Delete_management(updated_itin_table) # Rebuild relationship class. arcpy.AddMessage('{0}Rebuilding relationship classes...'.format('\n')) bus_future_name = MHN.break_path(MHN.bus_future)['name'] itin_table_name = MHN.break_path(itin_table)['name'] rel_arcs = os.path.join(MHN.gdb, 'rel_arcs_to_{0}'.format(itin_table_name)) rel_sys = os.path.join( MHN.gdb, 'rel_{0}_to_{1}'.format( itin_table_name.rsplit('_', 1)[0], itin_table_name.rsplit('_', 1)[1])) arcpy.CreateRelationshipClass_management(MHN.arc, itin_table, rel_arcs,
arcpy.AddMessage('\nSaving changes to disk...') # Replace header feature class. arcpy.AddMessage('-- ' + MHN.bus_future + '...') arcpy.TruncateTable_management(MHN.bus_future) arcpy.Delete_management(MHN.bus_future) arcpy.CopyFeatures_management(updated_routes_fc, MHN.bus_future) arcpy.Delete_management(updated_routes_fc) # Replace itinerary table. itin_table = MHN.route_systems[MHN.bus_future][0] arcpy.AddMessage('-- ' + itin_table + '...') arcpy.TruncateTable_management(itin_table) arcpy.Delete_management(itin_table) itin_path = MHN.break_path(itin_table) arcpy.CreateTable_management(itin_path['dir'], itin_path['name'], updated_itin_table) arcpy.Append_management(updated_itin_table, itin_table, 'TEST') arcpy.Delete_management(updated_itin_table) # Rebuild relationship class. arcpy.AddMessage('{0}Rebuilding relationship classes...'.format('\n')) bus_future_name = MHN.break_path(MHN.bus_future)['name'] itin_table_name = MHN.break_path(itin_table)['name'] rel_arcs = os.path.join(MHN.gdb, 'rel_arcs_to_{0}'.format(itin_table_name)) rel_sys = os.path.join(MHN.gdb, 'rel_{0}_to_{1}'.format(itin_table_name.rsplit('_',1)[0], itin_table_name.rsplit('_',1)[1])) arcpy.CreateRelationshipClass_management(MHN.arc, itin_table, rel_arcs, 'SIMPLE', itin_table_name, MHN.arc_name, 'NONE', 'ONE_TO_MANY', 'NONE', 'ABB', 'ABB') arcpy.CreateRelationshipClass_management(MHN.bus_future, itin_table, rel_sys, 'COMPOSITE', itin_table_name, bus_future_name, 'FORWARD', 'ONE_TO_MANY', 'NONE', common_id_field, common_id_field) # Clean up. arcpy.Compact_management(MHN.gdb)
arcpy.AddMessage('\nSaving changes to disk...') # Replace header feature class. arcpy.AddMessage('-- ' + routes_fc + '...') arcpy.TruncateTable_management(routes_fc) arcpy.Delete_management(routes_fc) arcpy.CopyFeatures_management(temp_routes_fc, routes_fc) arcpy.Delete_management(temp_routes_fc) # Replace itinerary table. itin_table = MHN.route_systems[routes_fc][0] arcpy.AddMessage('-- ' + itin_table + '...') arcpy.TruncateTable_management(itin_table) arcpy.Delete_management(itin_table) itin_path = MHN.break_path(itin_table) arcpy.CreateTable_management(itin_path['dir'], itin_path['name'], temp_itin_table) arcpy.Append_management(temp_itin_table, itin_table, 'TEST') arcpy.Delete_management(temp_itin_table) # Rebuild relationship class. arcpy.AddMessage('{0}Rebuilding relationship classes...'.format('\n')) bus_future_name = MHN.break_path(routes_fc)['name'] itin_table_name = MHN.break_path(itin_table)['name'] rel_arcs = os.path.join(MHN.gdb, 'rel_arcs_to_{0}'.format(itin_table_name)) rel_sys = os.path.join(MHN.gdb, 'rel_{0}_to_{1}'.format(itin_table_name.rsplit('_',1)[0], itin_table_name.rsplit('_',1)[1])) arcpy.CreateRelationshipClass_management(MHN.arc, itin_table, rel_arcs, 'SIMPLE', itin_table_name, MHN.arc_name, 'NONE', 'ONE_TO_MANY', 'NONE', 'ABB', 'ABB') arcpy.CreateRelationshipClass_management(routes_fc, itin_table, rel_sys, 'COMPOSITE', itin_table_name, bus_future_name, 'FORWARD', 'ONE_TO_MANY', 'NONE', common_id_field, common_id_field) # Clean up. arcpy.Compact_management(MHN.gdb)
arcpy.AddMessage('{0}Saving changes to disk...'.format('\n')) # Replace hwyproj feature class: arcpy.AddMessage('-- ' + MHN.hwyproj + '...') arcpy.TruncateTable_management(MHN.hwyproj) arcpy.Delete_management(MHN.hwyproj) arcpy.CopyFeatures_management(updated_projects_fc, MHN.hwyproj) arcpy.Delete_management(updated_projects_fc) # Replace hwyproj_coding table: coding_table = MHN.route_systems[MHN.hwyproj][0] arcpy.AddMessage('-- ' + coding_table + '...') arcpy.TruncateTable_management(coding_table) arcpy.Delete_management(coding_table) coding_table_path = MHN.break_path(coding_table) arcpy.CreateTable_management(coding_table_path['dir'], coding_table_path['name'], updated_coding_table) arcpy.Append_management(updated_coding_table, coding_table, 'TEST') arcpy.Delete_management(updated_coding_table) # Rebuild relationship classes. arcpy.AddMessage('{0}Rebuilding relationship classes...'.format('\n')) hwyproj_name = MHN.break_path(MHN.hwyproj)['name'] coding_table_name = MHN.break_path(coding_table)['name'] rel_arcs = os.path.join(MHN.gdb, 'rel_arcs_to_{0}'.format(coding_table_name)) rel_sys = os.path.join(MHN.gdb, 'rel_{0}_to_{1}'.format(coding_table_name.rsplit('_',1)[0], coding_table_name.rsplit('_',1)[1])) arcpy.CreateRelationshipClass_management(MHN.arc, coding_table, rel_arcs, 'SIMPLE', coding_table_name, MHN.arc_name, 'NONE', 'ONE_TO_MANY', 'NONE', 'ABB', 'ABB') arcpy.CreateRelationshipClass_management(MHN.hwyproj, coding_table, rel_sys, 'COMPOSITE', coding_table_name, hwyproj_name, 'FORWARD', 'ONE_TO_MANY', 'NONE', common_id_field, common_id_field) # Clean up. arcpy.Compact_management(MHN.gdb)
arcpy.AddMessage('\nSaving changes to disk...') # Replace header feature class. arcpy.AddMessage('-- ' + routes_fc + '...') arcpy.TruncateTable_management(routes_fc) arcpy.Delete_management(routes_fc) arcpy.CopyFeatures_management(temp_routes_fc, routes_fc) arcpy.Delete_management(temp_routes_fc) # Replace itinerary table. itin_table = MHN.route_systems[routes_fc][0] arcpy.AddMessage('-- ' + itin_table + '...') arcpy.TruncateTable_management(itin_table) arcpy.Delete_management(itin_table) itin_path = MHN.break_path(itin_table) arcpy.CreateTable_management(itin_path['dir'], itin_path['name'], temp_itin_table) arcpy.Append_management(temp_itin_table, itin_table, 'TEST') arcpy.Delete_management(temp_itin_table) # Rebuild relationship class. arcpy.AddMessage('{0}Rebuilding relationship classes...'.format('\n')) bus_future_name = MHN.break_path(routes_fc)['name'] itin_table_name = MHN.break_path(itin_table)['name'] rel_arcs = os.path.join(MHN.gdb, 'rel_arcs_to_{0}'.format(itin_table_name)) rel_sys = os.path.join(MHN.gdb, 'rel_{0}_to_{1}'.format(itin_table_name.rsplit('_',1)[0], itin_table_name.rsplit('_',1)[1])) arcpy.CreateRelationshipClass_management(MHN.arc, itin_table, rel_arcs, 'SIMPLE', itin_table_name, MHN.arc_name, 'NONE', 'ONE_TO_MANY', 'NONE', 'ABB', 'ABB') arcpy.CreateRelationshipClass_management(routes_fc, itin_table, rel_sys, 'COMPOSITE', itin_table_name, bus_future_name, 'FORWARD', 'ONE_TO_MANY', 'NONE', common_id_field, common_id_field) # Clean up. arcpy.Compact_management(MHN.gdb)
for updated_route_system in updated_route_systems_list: # Header feature class: header = updated_route_system[0][0] header_updated = updated_route_system[0][1] arcpy.AddMessage('-- ' + header + '...') arcpy.TruncateTable_management(header) arcpy.Delete_management(header) arcpy.CopyFeatures_management(header_updated, header) arcpy.Delete_management(header_updated) # Itinerary table: itin = updated_route_system[1][0] itin_updated = updated_route_system[1][1] arcpy.AddMessage('-- ' + itin + '...') arcpy.TruncateTable_management(itin) arcpy.Delete_management(itin) itin_path = MHN.break_path(itin) # CreateTable & Append because CopyFeatures crashes randomly with large tables. arcpy.CreateTable_management(itin_path['dir'], itin_path['name'], itin_updated) arcpy.Append_management(itin_updated, itin, 'TEST') arcpy.Delete_management(itin_updated) # Replace old nodes. arcpy.AddMessage('-- ' + MHN.node + '...') arcpy.Delete_management(MHN.node) arcpy.CopyFeatures_management(new_nodes_CZ, MHN.node) arcpy.Delete_management(new_nodes_CZ) # Replace old arcs. arcpy.AddMessage('-- ' + MHN.arc + '...') arcpy.Delete_management(MHN.arc)
arcpy.AddMessage('{0}Saving changes to disk...'.format('\n')) # Replace hwyproj feature class: arcpy.AddMessage('-- ' + MHN.hwyproj + '...') arcpy.TruncateTable_management(MHN.hwyproj) arcpy.Delete_management(MHN.hwyproj) arcpy.CopyFeatures_management(updated_projects_fc, MHN.hwyproj) arcpy.Delete_management(updated_projects_fc) # Replace hwyproj_coding table: coding_table = MHN.route_systems[MHN.hwyproj][0] arcpy.AddMessage('-- ' + coding_table + '...') arcpy.TruncateTable_management(coding_table) arcpy.Delete_management(coding_table) coding_table_path = MHN.break_path(coding_table) arcpy.CreateTable_management(coding_table_path['dir'], coding_table_path['name'], updated_coding_table) arcpy.Append_management(updated_coding_table, coding_table, 'TEST') arcpy.Delete_management(updated_coding_table) # Rebuild relationship classes. arcpy.AddMessage('{0}Rebuilding relationship classes...'.format('\n')) hwyproj_name = MHN.break_path(MHN.hwyproj)['name'] coding_table_name = MHN.break_path(coding_table)['name'] rel_arcs = os.path.join(MHN.gdb, 'rel_arcs_to_{0}'.format(coding_table_name)) rel_sys = os.path.join( MHN.gdb, 'rel_{0}_to_{1}'.format( coding_table_name.rsplit('_', 1)[0], coding_table_name.rsplit('_', 1)[1])) arcpy.CreateRelationshipClass_management(MHN.arc, coding_table, rel_arcs,