This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.py
executable file
·99 lines (74 loc) · 4.37 KB
/
convert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
import arcpy
class ProcessTables():
def __init__(self, toolbox_path, staging_path, flex_path, field_map_path):
arcpy.ImportToolbox(toolbox_path)
self.staging = staging_path
self.flex = flex_path
self.field_maps = field_map_path
def create_spillman_tables(self):
# helper method runs class ProcessTables
self.create_street()
self.create_block()
self.create_address()
self.create_commonplace()
self.create_pointofinterest()
def create_street(self):
# process StreetCenterline feature class
input_street = self.staging + 'StreetCenterline'
output_street = self.flex + 'StreetCenterline_RG'
output_streetalt = self.flex + 'StreetCenterline_Alt'
with open(self.field_maps + 'street_fields.txt', 'r') as sf:
#reads text file of field mapping in for easier readability when altering field mapping
street_fields = ''.join(line.rstrip() for line in sf)
arcpy.StreetFeatureClassExporter_SpillmanToolbox(input_street, street_fields, '', 'true', self.flex, output_street)
print(arcpy.GetMessages())
with open(self.field_maps + 'streetalt_fields.txt', 'r') as saf:
streetalt_fields = ''.join(line.rstrip() for line in saf)
arcpy.AltNamesStreet_SpillmanToolbox(input_street, streetalt_fields, '', output_streetalt)
print(arcpy.GetMessages())
def create_block(self):
# process Block feature class
input_street = self.flex + 'StreetCenterline_RG'
output_block = self.flex + 'Block'
arcpy.BlockFeatureClassTool_SpillmanToolbox(input_street, 'BLK', '10', output_block)
print(arcpy.GetMessages())
def create_address(self):
# process AddressPoint feature class
input_address = self.staging + 'AddressPoint'
output_address = self.flex + 'AddressPoint_RG'
output_addressalt = self.flex + 'AddressPoint_Alt'
with open(self.field_maps + 'address_fields.txt', 'r') as af:
address_fields = ''.join(line.rstrip() for line in af)
arcpy.AddressPointFeatureClassExporter_SpillmanToolbox(input_address, address_fields, '', 'true', '', output_address)
print(arcpy.GetMessages())
with open(self.field_maps + 'addressalt_fields.txt', 'r') as aaf:
addressalt_fields = ''.join(line.rstrip() for line in aaf)
arcpy.AltNamesStreet_SpillmanToolbox(input_address, addressalt_fields, '', output_addressalt)
print(arcpy.GetMessages())
def create_commonplace(self):
# process CommonPlace feature class
input_commonplace = self.staging + 'CommonPlace'
output_commonplace = self.flex + 'CommonPlace_RG'
output_commonplacealt = self.flex + 'CommonPlace_Alt'
with open(self.field_maps + 'commonplace_fields.txt', 'r') as cpf:
commonplace_fields = ''.join(line.rstrip() for line in cpf)
arcpy.AddressPointFeatureClassExporter_SpillmanToolbox(input_commonplace, commonplace_fields, '', 'true', '', output_commonplace)
print(arcpy.GetMessages())
with open(self.field_maps + 'commonplacealt_fields.txt', 'r') as cpaf:
commonplacealt_fields = ''.join(line.rstrip() for line in cpaf)
arcpy.AltNamesPOI_SpillmanToolbox(input_commonplace, commonplacealt_fields, '', output_commonplacealt)
print(arcpy.GetMessages())
def create_pointofinterest(self):
# process PointOfInterest feature class
input_poi = self.staging + 'PointOfInterest'
output_poi = self.flex + 'PointOfInterest_RG'
output_poialt = self.flex + 'PointOfInterest_Alt'
with open(self.field_maps + 'pointofinterest_fields.txt', 'r') as poif:
poi_fields = ''.join(line.rstrip() for line in poif)
arcpy.AddressPointFeatureClassExporter_SpillmanToolbox(input_poi, poi_fields, '', 'true', '', output_poi)
print(arcpy.GetMessages())
with open(self.field_maps + 'pointofinterestalt_fields.txt', 'r') as poiaf:
poialt_fields = ''.join(line.rstrip() for line in poiaf)
arcpy.AltNamesPOI_SpillmanToolbox(input_poi, poialt_fields, '', output_poialt)
print(arcpy.GetMessages())