Skip to content

Created some tests for contains and overlap operations to check DE-9IM compliance #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ DATA_built = $(RELEASE_SQL) \

DOCS = README.pg_sphere COPYRIGHT.pg_sphere
REGRESS = init tables points euler circle line ellipse poly path box index \
contains_ops contains_ops_compat bounding_box_gist gnomo epochprop
contains_ops contains_ops_compat bounding_box_gist gnomo epochprop \
contains overlaps

ifneq ($(USE_HEALPIX),0)
REGRESS += healpix moc mocautocast
Expand All @@ -41,7 +42,7 @@ REGRESS_9_5 = index_9.5 # experimental for spoint3

TESTS = init_test tables points euler circle line ellipse poly path box \
index contains_ops contains_ops_compat bounding_box_gist gnomo \
epochprop
epochprop contains overlaps

ifneq ($(USE_HEALPIX),0)
TESTS += healpix moc mocautocast
Expand Down
233 changes: 233 additions & 0 deletions expected/contains.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
/*
This set of tests is designed to verify the compliance of the contain operation with the DE-9IM model
*/
-- sline vs spoint
-- the point lies far beyond the line
select 'sline ~ spoint', 'f' as expected, sline(spoint'(270d,10d)', spoint'(270d,30d)') ~ spoint'(0d, 50d)' as actual;
?column? | expected | actual
----------------+----------+--------
sline ~ spoint | f | f
(1 row)

-- the point lies in the boundary of line
select 'sline ~ spoint', 'f' as expected, sline(spoint'(270d,10d)', spoint'(270d,30d)') ~ spoint'(270d, 10d)' as actual;
?column? | expected | actual
----------------+----------+--------
sline ~ spoint | f | t
(1 row)

-- the point lies in the interior of line
select 'sline ~ spoint', 't' as expected, sline(spoint'(270d,10d)', spoint'(270d,30d)') ~ spoint'(270d, 20d)' as actual;
?column? | expected | actual
----------------+----------+--------
sline ~ spoint | t | t
(1 row)

-- the point and line that degenerated into the point coincide
select 'sline ~ spoint', 't' as expected, sline(spoint'(270d,10d)', spoint'(270d,10d)') ~ spoint'(270d, 10d)' as actual;
?column? | expected | actual
----------------+----------+--------
sline ~ spoint | t | t
(1 row)

-- the point and line that degenerated into the point do not coincide
select 'sline ~ spoint', 'f' as expected, sline(spoint'(270d,10d)', spoint'(270d,10d)') ~ spoint'(270d, 20d)' as actual;
?column? | expected | actual
----------------+----------+--------
sline ~ spoint | f | f
(1 row)

-- spoint vs scircle
-- the point lies far beyond the circle
select 'spoint @ scircle', 'f' as expected, spoint'(0d,0d)' @ scircle'<(0d,90d),50d>' as actual;
?column? | expected | actual
------------------+----------+--------
spoint @ scircle | f | f
(1 row)

-- the point lies in the boundary of circle
select 'spoint @ scircle', 'f' as expected, spoint'(0d,80d)' @ scircle'<(0d,90d),10d>' as actual;
?column? | expected | actual
------------------+----------+--------
spoint @ scircle | f | t
(1 row)

-- the point lies in the interior of circle
select 'spoint @ scircle', 't' as expected, spoint'(0d,80d)' @ scircle'<(0d,90d),50d>' as actual;
?column? | expected | actual
------------------+----------+--------
spoint @ scircle | t | t
(1 row)

-- the point and circle that degenerated into the point coincide
select 'spoint @ scircle', 't' as expected, spoint'(0d,90d)' @ scircle'<(0d,90d),0d>' as actual;
?column? | expected | actual
------------------+----------+--------
spoint @ scircle | t | t
(1 row)

-- the point and circle that degenerated into the point do not coincide
select 'spoint @ scircle', 'f' as expected, spoint'(0d,50d)' @ scircle'<(0d,90d),0d>' as actual;
?column? | expected | actual
------------------+----------+--------
spoint @ scircle | f | f
(1 row)

-- sellipse vs spoint
-- the point lies far beyond the ellipse
select 'sellipse ~ spoint', 'f' as expected, sellipse'<{ 30d , 20d }, (0d , 90d) , 0d>' ~ spoint'(0d, 0d)' as actual;
?column? | expected | actual
-------------------+----------+--------
sellipse ~ spoint | f | f
(1 row)

-- the point lies in the boundary of ellipse
select 'sellipse ~ spoint', 'f' as expected, sellipse'<{ 30d , 20d }, (0d , 90d) , 0d>' ~ spoint'(0d, 70d)' as actual;
?column? | expected | actual
-------------------+----------+--------
sellipse ~ spoint | f | t
(1 row)

-- the point lies in the interior of ellipse
select 'sellipse ~ spoint', 't' as expected, sellipse'<{ 30d , 20d }, (0d , 90d) , 0d>' ~ spoint'(90d, 65d)' as actual;
?column? | expected | actual
-------------------+----------+--------
sellipse ~ spoint | t | t
(1 row)

-- the point lies in the boundary of ellipse that degenerated into the line
select 'sellipse ~ spoint', 't' as expected, sellipse'<{ 10d , 0d }, (0d , 0d) , 0d>' ~ spoint'(10d, 0d)' as actual;
?column? | expected | actual
-------------------+----------+--------
sellipse ~ spoint | t | t
(1 row)

-- the point lies in the interior of ellipse that degenerated into the line
select 'sellipse ~ spoint', 't' as expected, sellipse'<{ 10d , 0d }, (0d , 0d) , 0d>' ~ spoint'(0d, 0d)' as actual;
?column? | expected | actual
-------------------+----------+--------
sellipse ~ spoint | t | t
(1 row)

-- the point and ellipse that degenerated into the point coincide
select 'sellipse ~ spoint', 't' as expected, sellipse'<{ 0d , 0d }, (0d , 90d) , 0d>' ~ spoint'(0d, 90d)' as actual;
?column? | expected | actual
-------------------+----------+--------
sellipse ~ spoint | t | t
(1 row)

-- the point and ellipse that degenerated into the point do not coincide
select 'sellipse ~ spoint', 'f' as expected, sellipse'<{ 0d , 0d }, (0d , 90d) , 0d>' ~ spoint'(0d, 91d)' as actual;
?column? | expected | actual
-------------------+----------+--------
sellipse ~ spoint | f | f
(1 row)

-- spath vs spoint
-- the point lies far beyond the opened path
select 'spath ~ spoint', 'f' as expected, spath'{ (-10d, 0d),(10d,0d),(45d,15d),(80d,30d) }' ~ spoint'(0d, 90d)' as actual;
?column? | expected | actual
----------------+----------+--------
spath ~ spoint | f | f
(1 row)

-- the point lies in the boundary of opened path
select 'spath ~ spoint', 'f' as expected, spath'{ (-10d, 0d),(10d,0d),(45d,15d),(80d,30d) }' ~ spoint'(-10d, 0d)' as actual;
?column? | expected | actual
----------------+----------+--------
spath ~ spoint | f | t
(1 row)

-- the point lies in the boundary of unsimple opened path
select 'spath ~ spoint', 'f' as expected, spath'{ (-10d, 0d),(10d,0d),(45d,15d),(80d,30d),(-5d, 0d) }' ~ spoint'(-5d, 0d)' as actual;
?column? | expected | actual
----------------+----------+--------
spath ~ spoint | f | t
(1 row)

-- the point lies in the interior of opened path
select 'spath ~ spoint', 't' as expected, spath'{ (-10d, 0d),(10d,0d),(45d,15d),(80d,30d) }' ~ spoint'(9d, 0d)' as actual;
?column? | expected | actual
----------------+----------+--------
spath ~ spoint | t | t
(1 row)

-- the point lies in the interior of closed path
select 'spath ~ spoint', 't' as expected, spath'{ (-10d, 0d),(10d,0d),(45d,15d),(80d,30d),(-10d, 0d) }' ~ spoint'(-10d, 0d)' as actual;
?column? | expected | actual
----------------+----------+--------
spath ~ spoint | t | t
(1 row)

-- spoly vs spoint
-- the point lies far beyond the polygon
select 'spoly ~ spoint', 'f' as expected, spoly'{ (0d,0d), (10d,0d), (20d,20d) }' ~ spoint'(0d, 90d)' as actual;
?column? | expected | actual
----------------+----------+--------
spoly ~ spoint | f | f
(1 row)

-- the point lies in the boundary of polygon
select 'spoly ~ spoint', 'f' as expected, spoly'{ (0d,0d), (10d,0d), (20d,20d) }' ~ spoint'(5d, 0d)' as actual;
?column? | expected | actual
----------------+----------+--------
spoly ~ spoint | f | t
(1 row)

-- the point lies in the boundary of polygon
select 'spoly ~ spoint', 'f' as expected, spoly'{ (0d,0d), (10d,0d), (20d,20d) }' ~ spoint'(20d, 20d)' as actual;
?column? | expected | actual
----------------+----------+--------
spoly ~ spoint | f | t
(1 row)

-- the point lies in the interior of polygon
select 'spoly ~ spoint', 't' as expected, spoly'{ (0d,0d), (10d,0d), (20d,20d) }' ~ spoint'(5d, 5d)' as actual;
?column? | expected | actual
----------------+----------+--------
spoly ~ spoint | t | t
(1 row)

-- sbox vs spoint
-- the point lies far beyond the box
select 'sbox ~ spoint', 'f' as expected, sbox'( (0d,0d), (20d,10d) )' ~ spoint'(0d, 90d)' as actual;
?column? | expected | actual
---------------+----------+--------
sbox ~ spoint | f | f
(1 row)

-- the point lies in the boundary of box
select 'sbox ~ spoint', 'f' as expected, sbox'( (0d,0d), (20d,10d) )' ~ spoint'(0d, 5d)' as actual;
?column? | expected | actual
---------------+----------+--------
sbox ~ spoint | f | t
(1 row)

-- the point lies in the boundary of box
select 'sbox ~ spoint', 'f' as expected, sbox'( (0d,0d), (20d,10d) )' ~ spoint'(0d, 0d)' as actual;
?column? | expected | actual
---------------+----------+--------
sbox ~ spoint | f | t
(1 row)

-- the point lies in the interior of box
select 'sbox ~ spoint', 't' as expected, sbox'( (0d,0d), (20d,10d) )' ~ spoint'(5d, 5d)' as actual;
?column? | expected | actual
---------------+----------+--------
sbox ~ spoint | t | t
(1 row)

-- the point and box that degenerated into the point coincide
select 'sbox ~ spoint', 't' as expected, sbox'( (0d,0d), (0d,0d) )' ~ spoint'(0d, 0d)' as actual;
?column? | expected | actual
---------------+----------+--------
sbox ~ spoint | t | t
(1 row)

-- the point and box that degenerated into the point do not coincide
select 'sbox ~ spoint', 'f' as expected, sbox'( (0d,0d), (0d,0d) )' ~ spoint'(0d, 1d)' as actual;
?column? | expected | actual
---------------+----------+--------
sbox ~ spoint | f | f
(1 row)

Loading