forked from pnorman/ogr2osm-translations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurreyroad.py
122 lines (99 loc) · 4.19 KB
/
surreyroad.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- coding: utf-8 -*-
"""
Translation rules for the Surrey Roads.
Copyright 2011 Paul Norman.
"""
import ogr2osm
class LangleyRoadTranslation(ogr2osm.TranslationBase):
def translateName(self, rawname):
suffixlookup = {}
suffixlookup.update({'Ave':'Avenue'})
suffixlookup.update({'Rd':'Road'})
suffixlookup.update({'St':'Street'})
suffixlookup.update({'Pl':'Place'})
suffixlookup.update({'Cr':'Crescent'})
suffixlookup.update({'Blvd':'Boulevard'})
suffixlookup.update({'Dr':'Drive'})
suffixlookup.update({'Lane':'Lane'})
suffixlookup.update({'Crt':'Court'})
suffixlookup.update({'Gr':'Grove'})
suffixlookup.update({'Cl':'Close'})
suffixlookup.update({'Rwy':'Railway'})
suffixlookup.update({'Div':'Diversion'})
suffixlookup.update({'Hwy':'Highway'})
suffixlookup.update({'Hwy':'Highway'})
suffixlookup.update({'E':'East'})
suffixlookup.update({'S':'South'})
suffixlookup.update({'N':'North'})
suffixlookup.update({'W':'West'})
newName = ''
for partName in rawname.split():
newName = newName + ' ' + suffixlookup.get(partName,partName)
return newName.strip()
def filter_tags(self, attrs):
if not attrs:
return
tags = {}
#Add the source
tags.update({'source':'City of Surrey 2012 GIS Data'})
#automagically convert names
if attrs['ROAD_NAME']:
tags.update({'name':self.translateName(attrs['ROAD_NAME'].strip(' '))})
if attrs['YR']:
tags.update({'start_date':attrs['YR'].strip(' ')})
if attrs['MATERIAL']:
tags.update({'surface':attrs['MATERIAL'].strip(' ').lower()})
if attrs['SPEED']:
tags.update({'maxspeed': attrs['SPEED'].strip(' ')})
if attrs['NO_LANE']:
tags.update({'lanes': attrs['NO_LANE'].strip(' ')})
if 'RC_TYPE2' in attrs:
if attrs['RC_TYPE2'] == "Road" or attrs['RC_TYPE2'] == "Frontage Road": #TYPE=0 or 1
#some form of road
if attrs['STATUS'] and attrs['STATUS'] == "Unconstructed":
tags.update({'highway':'proposed'})
else:
#a road that's been completed
if attrs['STATUS'] and attrs['STATUS'] == "Closed to Traffic":
tags.update({'access':'no'})
if attrs['RD_CLASS'] and attrs['RD_CLASS'] == "Provincial Highway":
tags.update({'highway':'primary'})
elif attrs['RD_CLASS'] and attrs['RD_CLASS'] == "Arterial":
tags.update({'highway':'secondary'})
elif attrs['RD_CLASS'] and attrs['RD_CLASS'] == "Major Collector":
tags.update({'highway':'tertiary'})
elif attrs['RD_CLASS'] and attrs['RD_CLASS'] == "Local":
tags.update({'highway':'residential'})
elif attrs['RD_CLASS'] and attrs['RD_CLASS'] == "Translink":
tags.update({'highway':'road'})
else:
tags.update({'highway':'road'})
elif attrs['RC_TYPE2'] == "Highway Interchange": #type=1
tags.update({'highway':'primary_link'})
elif attrs['RC_TYPE2'] == "Street Lane" or attrs['RC_TYPE2'] == "Access Lane": #TYPE=3 or 4
tags.update({'highway':'service'})
tags.update({'service':'alley'})
elif attrs['RC_TYPE2'] == "Railway": #type 5
tags.update({'railway':'rail'})
# Truck route information
if 'ROUTE' in attrs:
if attrs['ROUTE'] == "Dangerous Goods Routes":
tags.update({'hazmat':'designated'})
tags.update({'hgv':'designated'})
if attrs['ROUTE'] == "Truck Routes":
tags.update({'hgv':'designated'})
if attrs['ROUTE'] == "Truck Routes Restrictions":
tags.update({'hgv':'no'})
#Truck todo
# Does ROUTE0=Secondary -ROUTE=* imply a truck route?
#Gritting (snow clearing) information
if 'WTR_PRIOR' in attrs or 'WTR_VEHCL' in attrs:
tags.update({'maintenance':'gritting'})
tags.update({'gritting_operator':'City of Surrey'})
if attrs['WTR_PRIOR'] and ("First Priority" in attrs['WTR_VEHCL']):
tags.update({'gritting':'priority_1'})
if attrs['WTR_PRIOR'] and ("Second Priority" in attrs['WTR_VEHCL']):
tags.update({'gritting':'priority_2'})
if 'GEODB_OID' in attrs:
tags.update({'surrey:geodb_oid': attrs['GEODB_OID'].strip(' ')})
return tags