Mercurial > gemma
comparison pkg/imports/st.go @ 3566:4c585b5d4fe8
Introduce hectometer based order for ranges of ISRS location codes
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 31 May 2019 20:06:27 +0200 |
parents | 9538a0aeacde |
children | 6c5c15b2fb64 |
comparison
equal
deleted
inserted
replaced
3565:f6d67697f158 | 3566:4c585b5d4fe8 |
---|---|
74 SELECT key from import.track_imports | 74 SELECT key from import.track_imports |
75 WHERE import_id = $1 AND | 75 WHERE import_id = $1 AND |
76 relation = 'waterway.stretches'::regclass)` | 76 relation = 'waterway.stretches'::regclass)` |
77 | 77 |
78 stInsertSQL = ` | 78 stInsertSQL = ` |
79 WITH r AS ( | 79 WITH |
80 SELECT isrsrange( | 80 bounds (b) AS (VALUES ( |
81 least(($1::char(2), | 81 ($1::char(2), |
82 $2::char(3), | 82 $2::char(3), |
83 $3::char(5), | 83 $3::char(5), |
84 $4::char(5), | 84 $4::char(5), |
85 $5::int)::isrs, | 85 $5::int)::isrs |
86 ($6::char(2), | 86 ), ( |
87 $7::char(3), | 87 ($6::char(2), |
88 $8::char(5), | 88 $7::char(3), |
89 $9::char(5), | 89 $8::char(5), |
90 $10::int)::isrs), | 90 $9::char(5), |
91 greatest(($1::char(2), | 91 $10::int)::isrs)), |
92 $2::char(3), | 92 r AS (SELECT isrsrange( |
93 $3::char(5), | 93 (SELECT b FROM bounds ORDER BY b USING <~ FETCH FIRST ROW ONLY), |
94 $4::char(5), | 94 (SELECT b FROM bounds ORDER BY b USING >~ FETCH FIRST ROW ONLY)) AS r), |
95 $5::int)::isrs, | |
96 ($6::char(2), | |
97 $7::char(3), | |
98 $8::char(5), | |
99 $9::char(5), | |
100 $10::int)::isrs) | |
101 ) AS r), | |
102 axs AS ( | 95 axs AS ( |
103 SELECT ISRSrange_axis((SELECT r FROM r), $16::double precision) AS axs) | 96 SELECT ISRSrange_axis((SELECT r FROM r), $16::double precision) AS axs) |
104 INSERT INTO waterway.stretches ( | 97 INSERT INTO waterway.stretches ( |
105 name, | 98 name, |
106 stretch, | 99 stretch, |