forked from azavea/pfb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
width_ft.sql
31 lines (28 loc) · 1.05 KB
/
width_ft.sql
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
----------------------------------------
-- INPUTS
-- location: neighborhood
----------------------------------------
UPDATE neighborhood_ways SET width_ft = NULL;
-- feet
UPDATE neighborhood_ways
SET width_ft = substring(osm.width from '\d+\.?\d?\d?')::FLOAT
FROM neighborhood_osm_full_line osm
WHERE neighborhood_ways.osm_id = osm.osm_id
AND osm.width IS NOT NULL
AND osm.width LIKE '% ft';
-- meters
UPDATE neighborhood_ways
SET width_ft = 3.28084 * substring(osm.width from '\d+\.?\d?\d?')::FLOAT
FROM neighborhood_osm_full_line osm
WHERE neighborhood_ways.osm_id = osm.osm_id
AND osm.width IS NOT NULL
AND osm.width LIKE '% m';
-- no units (default=meters)
-- N.B. we weed out anything more than 20, since that's likely either bogus
-- or not in meters
UPDATE neighborhood_ways
SET width_ft = 3.28084 * substring(osm.width from '\d+\.?\d?\d?')::FLOAT
FROM neighborhood_osm_full_line osm
WHERE neighborhood_ways.osm_id = osm.osm_id
AND osm.width IS NOT NULL
AND substring(osm.width from '\d+\.?\d?\d?')::FLOAT < 20;