-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadmin_boundary_functions.pg
75 lines (60 loc) · 3.85 KB
/
admin_boundary_functions.pg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
------------------------------------------------------------------------------
-- Provide unit testing for admin boundary functions using pgTAP
------------------------------------------------------------------------------
-- Turn off echo.
\set QUIET 1
-- Format the output nicely.
\pset format unaligned
\pset tuples_only true
\pset pager
-- Revert all changes on failure.
\set ON_ERROR_ROLLBACK 1
\set ON_ERROR_STOP true
BEGIN;
SELECT plan(8);
-- Tests
--Suburb--------------------------
SELECT results_eq(
$$SELECT buildings_reference.suburb_locality_intersect_polygon('01060000209108000001000000010300000001000000050000000000000028A83C41000000C0263155410000000028A83C410000000019315541000000008CA83C410000000019315541000000008CA83C41000000C0263155410000000028A83C41000000C026315541');$$,
$$VALUES (101)$$,
'suburb_locality_intersect_polygon not returning correct suburb_locality_id value when building intersects suburb polygon'
);
SELECT results_eq(
$$SELECT buildings_reference.suburb_locality_intersect_polygon('01030000209108000001000000050000008AA13A5BACA93C414227A7D5AF3155418AA13A5BACA93C416B9C8E5CAC315541CF072FE2C0A93C41E1C0D369AC315541F7751AADC0A93C412E7031F0AF3155418AA13A5BACA93C414227A7D5AF315541');$$,
$$VALUES (107)$$,
'suburb_locality_intersect_polygon not returning correct suburb_locality_id value when building intersects suburb polygon - island'
);
SELECT results_eq(
$$SELECT buildings_reference.suburb_locality_intersect_polygon('01030000209108000001000000050000002F02D344AFA93C4180AEA44DA8315541C1D7B600B0A93C41736D2300A5315541055058C897A93C41B17159EDA4315541F871083297A93C41A0B03F44A83155412F02D344AFA93C4180AEA44DA8315541');$$,
$$VALUES (107)$$,
'suburb_locality_intersect_polygon not returning correct suburb_locality_id value when building intersects suburb polygon - island'
);
SELECT results_eq(
$$SELECT buildings_reference.suburb_locality_intersect_polygon('01030000209108000001000000050000003460F2F8D9A93C417F87C576D7305541D6ECEDF2DAA93C41C1E8E623D0305541569A5626FCA93C4112AFE4A0D030554170F46338F9A93C412EC1C7F9D63055413460F2F8D9A93C417F87C576D7305541');$$,
$$VALUES (104)$$,
'suburb_locality_intersect_polygon not returning correct suburb_locality_id value when building is outside suburb polygon'
);
SELECT results_eq(
$$SELECT suburb_locality_id from buildings_bulk_load.bulk_load_outlines blo WHERE blo.supplied_dataset_id = 3;$$,
$$VALUES (101)$$,
'Check suburb_locality_id of bulk load outlines table after bulk_load_outlines_update_suburb function has run'
);
--Territorial Authority-------------------------
SELECT results_eq(
$$SELECT buildings_reference.territorial_authority_intersect_polygon('01060000209108000001000000010300000001000000050000000000000028A83C41000000C0263155410000000028A83C410000000019315541000000008CA83C410000000019315541000000008CA83C41000000C0263155410000000028A83C41000000C026315541');$$,
$$VALUES (10001)$$,
'nz_territorial_authority_intersect_polygon not returning correct territorial_authority value when building intersects territorial_authority polygon'
);
SELECT results_eq(
$$SELECT buildings_reference.territorial_authority_intersect_polygon('01030000209108000001000000050000003460F2F8D9A93C417F87C576D7305541D6ECEDF2DAA93C41C1E8E623D0305541569A5626FCA93C4112AFE4A0D030554170F46338F9A93C412EC1C7F9D63055413460F2F8D9A93C417F87C576D7305541');$$,
$$VALUES (10001)$$,
'territorial_authority_intersect_polygon not returning correct territorial_authority value when building is outside territorial_authority polygon'
);
SELECT results_eq(
$$SELECT territorial_authority_id from buildings_bulk_load.bulk_load_outlines blo WHERE blo.supplied_dataset_id = 3;$$,
$$VALUES (10001)$$,
'Check territorial_authority_id of bulk load outlines table after bulk_load_outlines_update_territorial_authority function has run'
);
-- Finish pgTAP testing
SELECT * FROM finish();
ROLLBACK;