Mercurial > gemma
diff schema/gemma_tests.sql @ 5095:e21cbb9768a2
Prevent duplicate fairway areas
In principal, there can be only one or no fairway area at each point
on the map. Since polygons from real data will often be topologically
inexact, just disallow equal geometries. This will also help to
avoid importing duplicates with concurrent imports, once the history
of fairway dimensions will be preserved.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 25 Mar 2020 18:10:02 +0100 |
parents | cf25b23e3eec |
children | 722b7c305319 |
line wrap: on
line diff
--- a/schema/gemma_tests.sql Wed Mar 25 09:37:04 2020 +0100 +++ b/schema/gemma_tests.sql Wed Mar 25 18:10:02 2020 +0100 @@ -52,3 +52,38 @@ $$, 23505, NULL, 'No duplicate geometries can be inserted into waterway_area'); + +SELECT throws_ok($$ + INSERT INTO waterway.fairway_dimensions ( + area, level_of_service, + min_width, max_width, min_depth, source_organization + ) VALUES ( + ST_GeogFromText('MULTIPOLYGON(((0 0, 1 1, 1 0, 0 0)))'), 3, + 100, 200, 2, 'test' + ), ( + ST_GeogFromText('MULTIPOLYGON(((0 0, 1 1, 1 0, 0 0)))'), 3, + 100, 200, 2, 'test' + ) + $$, + 23505, NULL, + 'No duplicate geometries can be inserted into fairway_dimensions'); + +SELECT lives_ok($$ + INSERT INTO waterway.fairway_dimensions ( + area, level_of_service, + min_width, max_width, min_depth, source_organization, staging_done + ) VALUES ( + ST_GeogFromText('MULTIPOLYGON(((0 0, 1 1, 1 0, 0 0)))'), 3, + 100, 200, 2, 'test', false + ), ( + ST_GeogFromText('MULTIPOLYGON(((0 0, 1 1, 1 0, 0 0)))'), 3, + 100, 200, 2, 'test', true + ) + $$, + 'Duplicate fairway area can be inserted if stage_done differs'); + +SELECT throws_ok($$ + UPDATE waterway.fairway_dimensions SET staging_done = true + $$, + 23505, NULL, + 'No duplicate fairway area can be released from staging area');