---------------------------------------------------------------------------
    Import future bus route coding from an Excel spreadsheet, with "header" and
    "itinerary" worksheets. SAS can currently only handle .xls and not .xlsx.

'''
import csv
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
xls = arcpy.GetParameterAsText(1)           # Spreadsheet containing future bus coding
sas1_name = 'import_future_bus_routes_2'

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))


# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
sas1_log = os.path.join(MHN.temp_dir, '{0}.log'.format(sas1_name))
sas1_lst = os.path.join(MHN.temp_dir, '{0}.lst'.format(sas1_name))
year_csv = os.path.join(MHN.temp_dir, 'year.csv')
transact_csv = os.path.join(MHN.temp_dir, 'transact.csv')
network_csv = os.path.join(MHN.temp_dir, 'network.csv')
future_itin_csv = os.path.join(MHN.temp_dir, 'future_itin.csv')
       MHN.hwyproj (excluding those in uncodable CSV).
    2. Output/in_mhn_not_year.txt: projects coded in MHN.hwyproj with
       COMPLETION_YEAR != 9999 that should not be included in Conformity.

'''
import os
import csv
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)           # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
mrn_gdb_path = arcpy.GetParameterAsText(1)           # MRN geodatabase
mrn_future_fc = os.path.join(mrn_gdb_path, 'railnet', 'future')
people_mover_table = os.path.join(mrn_gdb_path, 'people_mover')
tipid_conformed_csv = arcpy.GetParameterAsText(2)    # CSV of coded conformed projects
tipid_exempt_csv = arcpy.GetParameterAsText(3)       # CSV of coded exempt projects
tipid_uncodable_csv = arcpy.GetParameterAsText(4)    # CSV of uncodable projects

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))

if not arcpy.Exists(mrn_gdb_path):
    MHN.die("{0} doesn't exist!".format(mrn_gdb_path))
if not arcpy.Exists(mrn_future_fc):
    MHN.die("{0} doesn't exist!".format(mrn_future_fc))
if not arcpy.Exists(people_mover_table):
    MHN.die("{0} doesn't exist!".format(people_mover_table))
    2. Output/in_mhn_not_year.txt: projects coded in MHN.hwyproj with
       COMPLETION_YEAR != 9999 that should not be included in Conformity.

'''
import os
import csv
import re
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)           # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
mrn_gdb_path = arcpy.GetParameterAsText(1)           # MRN geodatabase
mrn_future_fc = os.path.join(mrn_gdb_path, 'railnet', 'future')
people_mover_table = os.path.join(mrn_gdb_path, 'people_mover')
tipid_conformed_csv = arcpy.GetParameterAsText(2)    # CSV of coded conformed projects
tipid_exempt_csv = arcpy.GetParameterAsText(3)       # CSV of coded exempt projects
tipid_uncodable_csv = arcpy.GetParameterAsText(4)    # CSV of uncodable projects

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))

if not arcpy.Exists(mrn_gdb_path):
    MHN.die("{0} doesn't exist!".format(mrn_gdb_path))
if not arcpy.Exists(mrn_future_fc):
    MHN.die("{0} doesn't exist!".format(mrn_future_fc))
if not arcpy.Exists(people_mover_table):
    MHN.die("{0} doesn't exist!".format(people_mover_table))
Example #4
0
    scenario network. The scenario, output path and CT-RAMP flag are passed to
    the script as arguments from the tool. Creates l1, l2, n1, n2 files for all
    TOD periods, as well as highway.linkshape.

'''
import os
import sys
import arcpy
from operator import itemgetter
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
scen_list = arcpy.GetParameterAsText(1).split(
    ';')  # Semicolon-delimited string, e.g. '100;200'
root_path = arcpy.GetParameterAsText(2)  # String, no default
create_tollsys_flag = arcpy.GetParameter(3)  # Boolean, default = True
abm_output = arcpy.GetParameter(4)  # Boolean, default = False
if os.path.exists(root_path):
    hwy_path = MHN.ensure_dir(os.path.join(root_path, 'highway'))
else:
    MHN.die("{0} doesn't exist!".format(root_path))
sas1_name = 'coding_overlap'
sas2_name = 'generate_highway_files_2'

# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
    ---------------------------------------------------------------------------
    Import future bus route coding from an Excel spreadsheet, with "header" and
    "itinerary" worksheets. SAS can currently only handle .xls and not .xlsx.

'''
import csv
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
xls = arcpy.GetParameterAsText(1)  # Spreadsheet containing future bus coding
sas1_name = 'import_future_bus_routes_2'

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))

# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
sas1_log = os.path.join(MHN.temp_dir, '{0}.log'.format(sas1_name))
sas1_lst = os.path.join(MHN.temp_dir, '{0}.lst'.format(sas1_name))
year_csv = os.path.join(MHN.temp_dir, 'year.csv')
transact_csv = os.path.join(MHN.temp_dir, 'transact.csv')
network_csv = os.path.join(MHN.temp_dir, 'network.csv')
future_itin_csv = os.path.join(MHN.temp_dir, 'future_itin.csv')
future_route_csv = os.path.join(MHN.temp_dir, 'future_route.csv')
Example #6
0
    {root folder}/linkshape. This file will allow correct link geometry to be
    viewed in Emme, after the scenario has been initialized.

'''
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
arcpy.env.qualifiedFieldNames = False  # Joined attributes will not have fc name prefix

mhn_gdb_path = arcpy.GetParameterAsText(0)          # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
scen_list = arcpy.GetParameterAsText(1).split(';')  # Semicolon-delimited string, e.g. '100;200'
root_path = arcpy.GetParameterAsText(2)             # String, no default
abm_output = arcpy.GetParameter(3)                  # Boolean, default = False

out_tod_periods = sorted(MHN.tod_periods.keys())

if not os.path.exists(root_path):
    MHN.die("{0} doesn't exist!".format(root_path))
hwy_path = os.path.join(root_path, 'highway')
if not os.path.exists(hwy_path):
    MHN.die('{0} contains no highway folder! Please run the Generate Highway Files tool first.'.format(root_path))
tran_path = os.path.join(root_path, 'transit')
if not os.path.exists(tran_path):
    MHN.die("{0} contains no transit folder! Please run the Master Rail Network's Create Emme Scenario Files tool first.".format(root_path))
Example #7
0
      - Ensure that all nodes have a unique ID (maintaining existing IDs
        whenever possible) and that no nodes overlap each other.

    Requires an ArcGIS for Desktop 10.1+ Advanced license!

'''
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))

# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
bad_arcs_shp = os.path.join(MHN.temp_dir, 'bad_arcs.shp')
duplicate_nodes_shp = os.path.join(MHN.temp_dir, 'duplicate_nodes.shp')
overlapping_nodes_shp = os.path.join(MHN.temp_dir, 'overlapping_nodes.shp')

# -----------------------------------------------------------------------------
#  Clean up old temp files, if necessary.
# -----------------------------------------------------------------------------
MHN.delete_if_exists(bad_arcs_shp)
MHN.delete_if_exists(duplicate_nodes_shp)
    Edits tool should also be run to rebuild all of the relationship classes
    and ensure nodes, highway project geometries, etc. are correct.

'''
import os
import sys
import arcpy

sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..')))  # Add mhn_programs dir to path, so MHN.py can be imported
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # Input MHN gdb path
in_mhn = MasterHighwayNetwork(mhn_gdb_path)  # Initialize input MHN object

# Get the build year, and verify that it can actually be built.
build_year = arcpy.GetParameter(1)  # Integer, default = 2015
if build_year <= in_mhn.base_year:
    in_mhn.die(('The MHN currently has a base year of {0}. Try a year later than {0}.').format(in_mhn.base_year))

# Get the output GDB and feature dataset, and create if non-existent.
gdb_path = arcpy.GetParameterAsText(2)  # Folder, no default
gdb_name = arcpy.GetParameterAsText(3)  # String, no default
if not gdb_name.endswith('.gdb'):
    gdb_name = '{}.gdb'.format(gdb_name)
out_gdb = os.path.join(gdb_path, gdb_name)  # Output MHN gdb path

# Other parameters
sas1_name = 'process_highway_coding'  # Also used by export_future_network.py
    ---------------------------------------------------------------------------
    This program is used to update the itineraries of bus routes, with data
    from specified header & itinerary coding CSVs.

'''
import csv
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)    # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
raw_header_csv = arcpy.GetParameterAsText(1)  # Bus header coding CSV
raw_itin_csv = arcpy.GetParameterAsText(2)    # Bus itin coding CSV
which_bus = arcpy.GetParameterAsText(3)       # Import to base or current?
sas1_name = 'import_gtfs_bus_routes_2'

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))


# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
sas1_log = os.path.join(MHN.temp_dir, '{0}.log'.format(sas1_name))
sas1_lst = os.path.join(MHN.temp_dir, '{0}.lst'.format(sas1_name))
transact_csv = os.path.join(MHN.temp_dir, 'transact.csv')
network_csv = os.path.join(MHN.temp_dir, 'network.csv')
    ---------------------------------------------------------------------------
    Import highway project coding from an Excel spreadsheet. SAS can currently
    only handle .xls and not .xlsx.

'''
import csv
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
xls = arcpy.GetParameterAsText(1)           # Spreadsheet containing project coding
sas1_name = 'import_highway_projects_2'


# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
sas1_log = os.path.join(MHN.temp_dir, '{0}.log'.format(sas1_name))
sas1_lst = os.path.join(MHN.temp_dir, '{0}.lst'.format(sas1_name))
mhn_links_csv = os.path.join(MHN.temp_dir, 'mhn_links.csv')
projects_csv = os.path.join(MHN.temp_dir, 'projects.csv')


# -----------------------------------------------------------------------------
#  Clean up old temp files, if necessary.
import os
import sys
import math
import arcpy
from fuzzywuzzy import fuzz  # Fuzzy string matching <https://github.com/seatgeek/fuzzywuzzy>

sys.path.append(os.path.abspath(os.path.join(
    sys.path[0],
    '..')))  # Add mhn_programs dir to path, so MHN.py can be imported
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# ---------------------------------------------------------------------
#  Set parameters.
# ---------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN gdb path
MHN = MasterHighwayNetwork(mhn_gdb_path)  # Initialize MHN object
iris_fc = arcpy.GetParameterAsText(1)  # Full path to IRIS shapefile
iris_id_field = arcpy.GetParameterAsText(2)  # IRIS unique ID field
mhn_id_field = 'ABB'  # MHN unique ID field
out_workspace = arcpy.GetParameterAsText(3)  # Output directory
table_name = 'mhn2iris_{0}.dbf'  # Output match table; format with timestamp at time of creation

mhn_buffer_dist = 150  # Only match IRIS links coming within this distance (ft) of an MHN link
densify_distance = 25  # Minimum distance (ft) between road vertices
near_distance = 60  # Maximum distance (ft) between IRIS/MHN vertices to consider match
min_match_count = 5  # Minimum number of vertex matches to consider line match
min_fuzz_score = 60  # Minimum fuzzy string match score for IRIS/MHN names to consider line match

#arcpy.AddWarning('\nCurrently generating IRIS correspondence for {0}.'.format(MHN.gdb))

if near_distance < densify_distance * 2:
Example #12
0
    ---------------------------------------------------------------------------
    This program is used to update the itineraries of bus routes, with data
    from specified header & itinerary coding CSVs.

'''
import csv
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)    # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
which_bus = arcpy.GetParameterAsText(1)       # Import to base or current?
raw_header_csv = arcpy.GetParameterAsText(2)  # Bus header coding CSV
raw_itin_csv = arcpy.GetParameterAsText(3)    # Bus itin coding CSV
pseudo_csv = arcpy.GetParameterAsText(4)	  # Bus pseudonode CSV
sas1_name = 'import_gtfs_bus_routes_2'

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))


# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
sas1_log = os.path.join(MHN.temp_dir, '{0}.log'.format(sas1_name))
sas1_lst = os.path.join(MHN.temp_dir, '{0}.lst'.format(sas1_name))
transact_csv = os.path.join(MHN.temp_dir, 'transact.csv')
      - Ensure that all nodes have a unique ID (maintaining existing IDs
        whenever possible) and that no nodes overlap each other.

    Requires an ArcGIS for Desktop 10.1+ Advanced license!

'''
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)


# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
bad_arcs_shp = os.path.join(MHN.temp_dir, 'bad_arcs.shp')
duplicate_nodes_shp = os.path.join(MHN.temp_dir, 'duplicate_nodes.shp')
overlapping_nodes_shp = os.path.join(MHN.temp_dir, 'overlapping_nodes.shp')


# -----------------------------------------------------------------------------
#  Clean up old temp files, if necessary.
# -----------------------------------------------------------------------------
MHN.delete_if_exists(bad_arcs_shp)
MHN.delete_if_exists(duplicate_nodes_shp)
    ---------------------------------------------------------------------------
    Import highway project coding from an Excel spreadsheet. SAS can currently
    only handle .xls and not .xlsx.

"""
import csv
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
xls = arcpy.GetParameterAsText(1)  # Spreadsheet containing project coding
sas1_name = "import_highway_projects_2"


# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
sas1_log = os.path.join(MHN.temp_dir, "{0}.log".format(sas1_name))
sas1_lst = os.path.join(MHN.temp_dir, "{0}.lst".format(sas1_name))
mhn_links_csv = os.path.join(MHN.temp_dir, "mhn_links.csv")
projects_csv = os.path.join(MHN.temp_dir, "projects.csv")


# -----------------------------------------------------------------------------
#  Clean up old temp files, if necessary.
Example #15
0
      - Ensure that all nodes have a unique ID (maintaining existing IDs
        whenever possible) and that no nodes overlap each other.

    Requires an ArcGIS for Desktop 10.1+ Advanced license!

'''
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)

#arcpy.AddWarning('\nCurrently updating {0}.'.format(MHN.gdb))

# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
bad_arcs_shp = os.path.join(MHN.temp_dir, 'bad_arcs.shp')
duplicate_nodes_shp = os.path.join(MHN.temp_dir, 'duplicate_nodes.shp')
overlapping_nodes_shp = os.path.join(MHN.temp_dir, 'overlapping_nodes.shp')


# -----------------------------------------------------------------------------
#  Clean up old temp files, if necessary.
# -----------------------------------------------------------------------------
MHN.delete_if_exists(bad_arcs_shp)
Example #16
0
'''
import os
import sys
import arcpy

sys.path.append(os.path.abspath(os.path.join(
    sys.path[0],
    '..')))  # Add mhn_programs dir to path, so MHN.py can be imported
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN gdb path
MHN = MasterHighwayNetwork(mhn_gdb_path)  # Initialize MHN object

# Get the build year, and verify that it can actually be built.
build_year = arcpy.GetParameter(1)  # Integer, default = 2013
if build_year < MHN.base_year:
    MHN.die(('The MHN currently has a base year of {0}, so its prior state is '
             'unknown. Please try {0} or later.').format(MHN.base_year))

# Get the output GDB and feature dataset, and create if non-existent.
gdb_path = arcpy.GetParameterAsText(2)  # Folder, no default
gdb_name = arcpy.GetParameterAsText(3)  # String, no default
if not gdb_name.endswith('.gdb'):
    gdb_name = '{0}.gdb'.format(gdb_name)
out_gdb = os.path.join(gdb_path, gdb_name)
if not arcpy.Exists(out_gdb):
    arcpy.CreateFileGDB_management(gdb_path, gdb_name)
    arcs and nodes in a specified GDB. This is particularly for building the
    networks for processing current GTFS bus runs.

'''
import os
import sys
import arcpy

sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..')))  # Add mhn_programs dir to path, so MHN.py can be imported
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)   # MHN gdb path
MHN = MasterHighwayNetwork(mhn_gdb_path)     # Initialize MHN object

# Get the build year, and verify that it can actually be built.
build_year = arcpy.GetParameter(1)  # Integer, default = 2013
if build_year < MHN.base_year:
    MHN.die(('The MHN currently has a base year of {0}, so its prior state is '
             'unknown. Please try {0} or later.').format(MHN.base_year))

# Get the output GDB and feature dataset, and create if non-existent.
gdb_path = arcpy.GetParameterAsText(2)  # Folder, no default
gdb_name = arcpy.GetParameterAsText(3)  # String, no default
if not gdb_name.endswith('.gdb'):
    gdb_name = '{0}.gdb'.format(gdb_name)
out_gdb = os.path.join(gdb_path, gdb_name)
if not arcpy.Exists(out_gdb):
    arcpy.CreateFileGDB_management(gdb_path, gdb_name)
'''
import os
import sys
import math
import arcpy
from fuzzywuzzy import fuzz  # Fuzzy string matching <https://github.com/seatgeek/fuzzywuzzy>

sys.path.append(os.path.abspath(os.path.join(sys.path[0], '..')))  # Add mhn_programs dir to path, so MHN.py can be imported
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# ---------------------------------------------------------------------
#  Set parameters.
# ---------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)   # MHN gdb path
MHN = MasterHighwayNetwork(mhn_gdb_path)     # Initialize MHN object
iris_fc = arcpy.GetParameterAsText(1)        # Full path to IRIS shapefile
iris_id_field = arcpy.GetParameterAsText(2)  # IRIS unique ID field
mhn_id_field = 'ABB'                         # MHN unique ID field
out_workspace = arcpy.GetParameterAsText(3)  # Output directory
table_name = 'mhn2iris_{0}.dbf'              # Output match table; format with timestamp at time of creation

mhn_buffer_dist = 150  # Only match IRIS links coming within this distance (ft) of a HERE link
densify_distance = 25  # Minimum distance (ft) between road vertices
near_distance = 60     # Maximum distance (ft) between IRIS/HERE vertices to consider match
min_match_count = 5    # Minimum number of vertex matches to consider line match
min_fuzz_score = 60    # Minimum fuzzy string match score for IRIS/HERE names to consider line match

#arcpy.AddWarning('\nCurrently generating IRIS correspondence for {0}.'.format(MHN.gdb))

if near_distance < densify_distance * 2:
    scenario network. The scenario, output path and CT-RAMP flag are passed to
    the script as arguments from the tool. Creates l1, l2, n1, n2 files for all
    TOD periods, as well as highway.linkshape.

"""
import os
import sys
import arcpy
from operator import itemgetter
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
scen_list = arcpy.GetParameterAsText(1).split(";")  # Semicolon-delimited string, e.g. '100;200'
root_path = arcpy.GetParameterAsText(2)  # String, no default
create_tollsys_flag = arcpy.GetParameter(3)  # Boolean, default = True
if os.path.exists(root_path):
    hwy_path = MHN.ensure_dir(os.path.join(root_path, "highway"))
else:
    MHN.die("{0} doesn't exist!".format(root_path))
sas1_name = "coding_overlap"
sas2_name = "generate_highway_files_2"


# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
overlap_year_csv = os.path.join(MHN.temp_dir, "overlap_year.csv")
    ---------------------------------------------------------------------------
    Import highway project coding from an Excel spreadsheet. SAS can currently
    only handle .xls and not .xlsx.

'''
import csv
import os
import sys
import arcpy
from MHN import MasterHighwayNetwork  # Custom class for MHN processing functionality

# -----------------------------------------------------------------------------
#  Set parameters.
# -----------------------------------------------------------------------------
mhn_gdb_path = arcpy.GetParameterAsText(0)  # MHN geodatabase
MHN = MasterHighwayNetwork(mhn_gdb_path)
xls = arcpy.GetParameterAsText(1)  # Spreadsheet containing project coding
sas1_name = 'import_highway_projects_2'

# -----------------------------------------------------------------------------
#  Set diagnostic output locations.
# -----------------------------------------------------------------------------
sas1_log = os.path.join(MHN.temp_dir, '{0}.log'.format(sas1_name))
sas1_lst = os.path.join(MHN.temp_dir, '{0}.lst'.format(sas1_name))
mhn_links_csv = os.path.join(MHN.temp_dir, 'mhn_links.csv')
projects_csv = os.path.join(MHN.temp_dir, 'projects.csv')

# -----------------------------------------------------------------------------
#  Clean up old temp files, if necessary.
# -----------------------------------------------------------------------------
MHN.delete_if_exists(sas1_log)