Skip to content

Commit

Permalink
tighten up matching precision and discard duplicates when generating …
Browse files Browse the repository at this point in the history
…habitat endpoints
  • Loading branch information
smnorris committed Aug 15, 2023
1 parent d2c065c commit edaed73
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions model/01_access/sql/user_habitat_classification_endpoints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ INSERT INTO bcfishpass.user_habitat_classification_endpoints
)

SELECT
h.blue_line_key,
h.downstream_route_measure,
s.linear_feature_id,
s.watershed_group_code
h.blue_line_key
,h.downstream_route_measure
,s.linear_feature_id
,s.watershed_group_code
FROM bcfishpass.user_habitat_classification h
INNER JOIN whse_basemapping.fwa_stream_networks_sp s
ON h.blue_line_key = s.blue_line_key
AND ROUND(s.downstream_route_measure::numeric) <= ROUND(h.downstream_route_measure::numeric)
AND ROUND(s.upstream_route_measure::numeric) > ROUND(h.downstream_route_measure::numeric)
AND ROUND(s.downstream_route_measure::numeric, 4) <= ROUND(h.downstream_route_measure::numeric, 4)
AND ROUND(s.upstream_route_measure::numeric, 4) > ROUND(h.downstream_route_measure::numeric, 4)
UNION
SELECT
h.blue_line_key,
Expand All @@ -36,5 +36,6 @@ SELECT
FROM bcfishpass.user_habitat_classification h
INNER JOIN whse_basemapping.fwa_stream_networks_sp s
ON h.blue_line_key = s.blue_line_key
AND ROUND(s.downstream_route_measure::numeric) <= ROUND(h.upstream_route_measure::numeric)
AND ROUND(s.upstream_route_measure::numeric) > ROUND(h.upstream_route_measure::numeric);
AND ROUND(s.downstream_route_measure::numeric, 4) <= ROUND(h.upstream_route_measure::numeric, 4)
AND ROUND(s.upstream_route_measure::numeric, 4) > ROUND(h.upstream_route_measure::numeric, 4)
on conflict do nothing; -- the same blkey/measure may exist for different species, discard duplicates

0 comments on commit edaed73

Please sign in to comment.