Skip to content

Commit d69c9b5

Browse files
committed
chk saf gnx
1 parent ba1f20e commit d69c9b5

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
WITH address_points AS (
2+
SELECT * FROM {{ source("recipe_sources", "dcp_cscl_addresspoints") }}
3+
),
4+
street_names AS (
5+
SELECT * FROM {{ source("recipe_sources", "dcp_cscl_streetname") }}
6+
WHERE principal_flag = 'Y'
7+
)
8+
SELECT
9+
address_points.addresspointid,
10+
address_points.b7sc_actual,
11+
CASE
12+
WHEN street_name.snd_feature_type IN ('E', 'F')
13+
THEN
14+
-- Last character is A, B, etc -> converted to 1, 2, etc
15+
10000 * (COALESCE(ASCII(RIGHT(address_points.house_number_suffix)) - 64, 0))
16+
+ address_points.house_number::INT
17+
WHEN address_points.hyphen_type = 'R'
18+
THEN TRIM(SPLIT_PART(address_points.house_number, '-', 1))::INT
19+
ELSE address_points.house_number
20+
END AS house_number,
21+
address_points.house_number AS plain_house_number,
22+
street_namess.snd_feature_type
23+
FROM address_points
24+
INNER JOIN street_names
25+
ON address_points.b7sc_actual = street_names.b7sc AND street_names.principal_flag = 'Y'
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
WITH commonplace AS (
2+
SELECT * FROM {{ source("recipe_sources", "dcp_cscl_commonplace_gdb") }}
3+
),
4+
centerline AS (
5+
SELECT * FROM {{ ref('stg__centerline') }}
6+
),
7+
proto AS (
8+
SELECT * FROM {{ ref('stg__altsegmentdata_proto') }}
9+
),
10+
shoreline AS (
11+
SELECT * FROM {{ ref('stg__shoreline') }}
12+
),
13+
address_points AS (
14+
SELECT * FROM {{ ref('int__address_point_house_numbers') }}
15+
),
16+
feature_names AS (
17+
SELECT * FROM {{ ref('stg__facecode_and_featurename') }}
18+
)
19+
SELECT
20+
-- TODO "warning" issued if featurename instead of streetname
21+
-- TODO error when null
22+
-- TODO needs handling see 7.2 note 1.f
23+
feature_name.lookup_key AS place_name
24+
commonplace.boroughcode,
25+
'' AS face_code,
26+
'' AS segment_seqnum,
27+
CASE
28+
WHEN commonplace.sosindicator = '1' THEN 'L'
29+
WHEN commonplace.sosindicator = '2' THEN 'R'
30+
END AS sos_indicator,
31+
commonplace.b5sc,
32+
-- TODO there's a note about some text-processing when hyphen_type = 'R' and there's a hyphen in this field
33+
-- However, that does not match a single record. It seems like the docs are outdated and this is handled in cscl
34+
CASE WHEN commonplace.sosindicator = '1' THEN address_points.house_number END AS l_high_hn,
35+
CASE WHEN commonplace.sosindicator = '2' THEN address_points.house_number END AS r_high_hn,
36+
commonplace.saftype,
37+
RIGHT(commonplace.b7sc, 2) AS nap_lgc1,
38+
1 AS boe_lgc_pointer,
39+
CASE
40+
WHEN shoreline.segmentid IS NOT NULL THEN 'U'
41+
ELSE centerline.segment_type -- todo weirdness about roadbed vs generic
42+
END AS segment_type,
43+
saf.segmentid, -- todo note 8
44+
ROUND(ST_X(commonplace.geom))::INT AS x_coord,
45+
ROUND(ST_Y(commonplace.geom))::INT AS y_coord,
46+
-- TODO have no idea what's up with these
47+
NULL AS side_borough_code,
48+
NULL AS side_ct2010,
49+
NULL AS side_ap
50+
FROM commonplace
51+
LEFT JOIN segments ON saf.segmentid = segments.segmentid -- this is actually quite complicated
52+
LEFT JOIN address_points ON commonplace.primaryaddresspointid = address_points.addresspointid
53+
LEFT JOIN feature_names
54+
ON (saf.b5sc || saf.lgc1) = feature_names.b7sc
55+
WHERE saf.saftype IN ('A', 'B', 'C', 'E', 'P')

products/cscl/models/intermediate/segments/int__protosegments.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ SELECT
6161
feature_type_codes.source_feature_class AS feature_type,
6262
primary_segments.feature_type AS primary_feature_type,
6363
feature_type_codes.description AS feature_type_description,
64+
proto.alt_segdata_type,
6465
proto.source_table,
6566
proto.globalid
6667
FROM proto

0 commit comments

Comments
 (0)