|
49 | 49 | matched = 0 |
50 | 50 |
|
51 | 51 | BUFFER = 100.0 |
52 | | -# RESAMPLE = 100.0 |
53 | 52 |
|
54 | 53 | # SRS_BZIT = EPSG:25832 # ETRS89 / UTM zone 32N used by provinz.bz.it |
55 | 54 | # SRS_WGS = EPSG:4326 # WGS84 |
|
60 | 59 | transformer = Transformer.from_crs ("EPSG:4326", "EPSG:25832", always_xy = True) |
61 | 60 | itransformer = Transformer.from_crs ("EPSG:25832", "EPSG:4326", always_xy = True) |
62 | 61 |
|
63 | | -# def dist (a, b): |
64 | | -# """ Since we are using UTM we can use a simple euclidean distance. """ |
65 | | -# return math.sqrt ((b[0] - a[0]) ** 2 + (b[1] - a[1]) ** 2) |
66 | | - |
67 | | - |
68 | | -# def _distance (coords1, coords2): |
69 | | -# """ Return Hausdorff distance in m """ |
70 | | - |
71 | | -# hd1 = scipy.spatial.distance.directed_hausdorff (coords1, coords2) |
72 | | - |
73 | | -# # hd2 = scipy.spatial.distance.directed_hausdorff (coords2, coords1) |
74 | | -# # hd = max (hd1[0], hd2[0]) |
75 | | - |
76 | | -# a = coords1[hd1[1]] |
77 | | -# b = coords2[hd1[2]] |
78 | | -# return dist (a, b) |
79 | | - |
80 | | - |
81 | | -# def coords (geom): |
82 | | -# if geom.is_empty: |
83 | | -# return [] |
84 | | -# if geom.type in ('LineString', 'LinearRing'): |
85 | | -# return geom.coords |
86 | | -# if geom.type.startswith ('Multi') or geom.type == 'GeometryCollection': |
87 | | -# return [c for l in geom for c in l.coords ] |
88 | | -# return [] |
89 | | - |
90 | | - |
91 | | -# def resample (geom, threshold): |
92 | | -# """Resample the linestrings in geometry. |
93 | | - |
94 | | -# After resampling the distance between consecutive points in a linestring |
95 | | -# will be no longer than threshold. |
96 | | - |
97 | | -# """ |
98 | | - |
99 | | -# if geom.is_empty: |
100 | | -# return geom |
101 | | - |
102 | | -# if geom.type in ('LineString', 'LinearRing'): |
103 | | -# pts = [] |
104 | | -# last_pt = geom.coords[0] |
105 | | - |
106 | | -# for pt in geom.coords: |
107 | | -# d = dist (pt, last_pt) |
108 | | -# if d > threshold: |
109 | | -# # add some points in between |
110 | | -# long_line = LineString ([last_pt, pt]) |
111 | | -# i = threshold |
112 | | -# while i <= d: |
113 | | -# pts.append (long_line.interpolate (i)) |
114 | | -# i += threshold |
115 | | -# pts.append (pt) |
116 | | -# last_pt = pt |
117 | | - |
118 | | -# return type (geom) (pts) |
119 | | - |
120 | | -# elif geom.type.startswith ('Multi') or geom.type == 'GeometryCollection': |
121 | | -# return type (geom) ([ resample (part, threshold) for part in geom.geoms]) |
122 | | - |
123 | | -# return geom |
124 | | - |
125 | | - |
126 | 62 | gk_routes = dict () |
127 | 63 | osm_routes = dict () |
128 | 64 | gk_routes_by_id = dict () # needed for STRtree |
@@ -154,7 +90,7 @@ def match_route (rtags, gk_props): |
154 | 90 | return True |
155 | 91 |
|
156 | 92 | # special case for CAI Trentino Est |
157 | | - m = re.match (r'^E(\d\d\d)$', ref) |
| 93 | + m = re.match (r'^(?:E|O)([0-9]{3}[ABC]?)$', ref) |
158 | 94 | if m and gk_ref == m.group (1): |
159 | 95 | return True |
160 | 96 |
|
@@ -186,15 +122,13 @@ def get_relation (osm_relation): |
186 | 122 |
|
187 | 123 | geom = connect.osm_relation_as_multilinestring (rfull) |
188 | 124 | geom = shapely.ops.transform (transformer.transform, geom) |
189 | | - # geom = resample (geom, RESAMPLE) |
190 | 125 |
|
191 | 126 | res['geometry'] = geom |
192 | 127 | res['geometry'].id = rel_id |
193 | 128 |
|
194 | 129 | clipped = connect.osm_relation_as_multilinestring (rfull, True) |
195 | 130 | clipped = shapely.ops.transform (transformer.transform, clipped) |
196 | 131 |
|
197 | | - # clipped = resample (clipped, RESAMPLE) |
198 | 132 | clipped = clip_area (clipped) |
199 | 133 |
|
200 | 134 | if not clipped.is_empty: |
|
0 commit comments