Mercurial > gemma
diff pkg/imports/sec.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 | ec1aec03676d |
children | 6c5c15b2fb64 |
line wrap: on
line diff
--- a/pkg/imports/sec.go Fri May 31 17:43:39 2019 +0200 +++ b/pkg/imports/sec.go Fri May 31 20:06:27 2019 +0200 @@ -74,29 +74,22 @@ relation = 'waterway.sections'::regclass)` secInsertSQL = ` -WITH r AS ( - SELECT isrsrange( - least(($1::char(2), - $2::char(3), - $3::char(5), - $4::char(5), - $5::int)::isrs, - ($6::char(2), - $7::char(3), - $8::char(5), - $9::char(5), - $10::int)::isrs), - greatest(($1::char(2), - $2::char(3), - $3::char(5), - $4::char(5), - $5::int)::isrs, - ($6::char(2), - $7::char(3), - $8::char(5), - $9::char(5), - $10::int)::isrs) - ) AS r), +WITH +bounds (b) AS (VALUES ( + ($1::char(2), + $2::char(3), + $3::char(5), + $4::char(5), + $5::int)::isrs + ), ( + ($6::char(2), + $7::char(3), + $8::char(5), + $9::char(5), + $10::int)::isrs)), +r AS (SELECT isrsrange( + (SELECT b FROM bounds ORDER BY b USING <~ FETCH FIRST ROW ONLY), + (SELECT b FROM bounds ORDER BY b USING >~ FETCH FIRST ROW ONLY)) AS r), axs AS ( SELECT ISRSrange_axis((SELECT r FROM r), $16::double precision) AS axs) INSERT INTO waterway.sections (