Mercurial > gemma
view schema/isrs_tests.sql @ 4341:e58affd956c5
pdf-gen: adjust place of text for textbox element
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Fri, 06 Sep 2019 14:39:21 +0200 |
parents | 4c585b5d4fe8 |
children | 8fcabb6f971e |
line wrap: on
line source
-- This is Free Software under GNU Affero General Public License v >= 3.0 -- without warranty, see README.md and license for details. -- SPDX-License-Identifier: AGPL-3.0-or-later -- License-Filename: LICENSES/AGPL-3.0.txt -- Copyright (C) 2018, 2019 by via donau -- – Österreichische Wasserstraßen-Gesellschaft mbH -- Software engineering by Intevation GmbH -- Author(s): -- * Tom Gottfried <tom@intevation.de> -- -- pgTAP test script for ISRS location code types and functions -- -- -- Conversion from/to text -- SELECT results_eq($$ SELECT isrs_fromText('DEBON03901G007906548') $$, $$ SELECT CAST(('DE', 'BON', '03901', 'G0079', 6548) AS isrs) $$, 'Correct ISRS text input gives respective ISRS location code'); SELECT throws_ok($$ SELECT isrs_fromText('DEUXXX039000000005023') $$, 22023, NULL, 'ISRS text input needs to have correct length'); SELECT ok( 'DEBON03901G007906548' = isrs_asText(isrs_fromText('DEBON03901G007906548')) , 'isrs_asText() is the inverse of isrs_fromText()'); -- -- Comparison operators -- SELECT ok( isrs_fromText('DEBON03901G007906548') <> isrs_fromText('DEXXX039010000006548'), 'Different codes at equal hectometre do not equal by default'); SELECT ok( isrs_fromText('DEBON03901G007906548') ~= isrs_fromText('DEXXX039010000006548') AND isrs_fromText('DEBON03901G007906548') >~= isrs_fromText('DEXXX039010000006548') AND isrs_fromText('DEBON03901G007906548') <~= isrs_fromText('DEXXX039010000006548'), 'isrs_ops: Different codes at equal hectometre compare as equal'); SELECT ok( isrs_fromText('DEBON03901G007906549') >~ isrs_fromText('DEXXX039010000006548') AND isrs_fromText('DEBON03901G007906549') >~= isrs_fromText('DEXXX039010000006548') AND isrs_fromText('DEXXX039010000006547') <~= isrs_fromText('DEBON03901G007906548') AND isrs_fromText('DEXXX039010000006547') <~ isrs_fromText('DEBON03901G007906548'), 'isrs_ops: Ordering depends on hectometre'); SELECT ok( isrsrange(isrs_fromText('DEXXX039010000006540'), isrs_fromText('DEXXX039010000006560')) @> isrs_fromText('ATXXX000000000006550') AND isrs_fromText('DEXXX039010000006560') <@ isrsrange(isrs_fromText('ATXXX000000000006550'), isrs_fromText('ATXXX000000000006570')), 'isrsrange: ''Contains'' depends on hectometre'); SELECT ok( isrsrange(isrs_fromText('DEXXX039010000006540'), isrs_fromText('DEXXX039010000006560')) && isrsrange(isrs_fromText('ATXXX000000000006550'), isrs_fromText('ATXXX000000000006570')), 'isrsrange: Overlap depends on hectometre'); -- -- Geometry processing -- SELECT throws_ok($$ SELECT ISRSrange_points(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 99999)::isrs)) $$, 'P0002', NULL, 'ISRSrange_points fails if not both distance marks can be found'); SELECT throws_ok($$ SELECT ISRSrange_axis(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 2)::isrs), 0) $$, 'P0002', NULL, 'ISRSrange_axis fails if no contiguous axis can be constructed'); SELECT ok( ST_IsSimple(ISRSrange_axis(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 2)::isrs), 5)), 'ISRSrange_axis returns a valid simple feature'); SELECT throws_ok($$ SELECT ISRSrange_area('LINESTRING(0 0, 1 1)', NULL) $$, 'P0002', NULL, 'ISRSrange_area fails if no input area is given'); SELECT throws_ok($$ SELECT ISRSrange_area(ISRSrange_axis(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 1)::isrs), 5), ST_SetSRID('POLYGON((0 1, 0 2, 1 2, 1 1, 0 1))'::geometry, 4326)) $$, 'P0002', NULL, 'ISRSrange_area fails, if given area does not intersect with axis'); SELECT results_eq($$ SELECT every(ST_DWithin( ST_Boundary(ISRSrange_area( ISRSrange_axis(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 1)::isrs), 5), (SELECT ST_Collect(CAST(area AS geometry)) FROM waterway.waterway_area))), geom, 1)) FROM waterway.distance_marks_virtual WHERE location_code IN( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 1)::isrs) $$, $$ SELECT true $$, 'Resulting polygon almost ST_Touches points corresponding to stretch'); \set test_area 'POLYGON((-1 1, 2 1, 2 -1, -1 -1, -1 1))' SELECT ok( 2 = ST_NumGeometries( ISRSrange_area( ISRSrange_axis(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 1)::isrs), 5), ST_SetSRID(ST_Collect( ST_Translate(:'test_area', (ST_XMax(:'test_area'::geometry) - ST_XMin(:'test_area'::geometry))/2 + 0.1, 0), ST_Translate(:'test_area', -((ST_XMax(:'test_area'::geometry) - ST_XMin(:'test_area'::geometry))/2 + 0.1), 0)), 4326))), 'Two polygons intersecting the axis lead to two polygons in result'); SELECT ok( 1 = ST_NumGeometries( ISRSrange_area( ISRSrange_axis(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 1)::isrs), 5), ST_SetSRID(ST_Collect( ST_Translate(:'test_area', (ST_XMax(:'test_area'::geometry) - ST_XMin(:'test_area'::geometry))/3, 0), ST_Translate(:'test_area', -((ST_XMax(:'test_area'::geometry) - ST_XMin(:'test_area'::geometry))/3), 0)), 4326))), 'Self-intersecting multipolygon leads to one polygon in result'); SELECT results_eq($$ SELECT every(ST_DWithin( ST_Boundary(ISRSrange_area( ISRSrange_axis(isrsrange( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 2)::isrs), 5), (SELECT ST_Collect(CAST(area AS geometry)) FROM waterway.waterway_area))), geom, 1)) FROM waterway.distance_marks_virtual WHERE location_code IN( ('AT', 'XXX', '00001', '00000', 0)::isrs, ('AT', 'XXX', '00001', '00000', 2)::isrs) $$, $$ SELECT true $$, 'Area generated from non-matching distance mark and non-contiguous axis');