File: hausdorff.sql

package info (click to toggle)
postgis 2.3.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 58,660 kB
  • ctags: 10,181
  • sloc: ansic: 132,858; sql: 131,148; xml: 46,460; sh: 4,832; perl: 4,476; makefile: 2,749; python: 1,198; yacc: 442; lex: 131
file content (37 lines) | stat: -rw-r--r-- 1,143 bytes parent folder | download | duplicates (3)
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
-- tests for Hausdorff distances

-- polygon and polygon
SELECT 'hausdorff_poly_poly', st_hausdorffdistance(
	'POLYGON((0 0, 0 2, 1 2, 2 2, 2 0, 0 0))'::geometry,
	'POLYGON((0.5 0.5, 0.5 2.5, 1.5 2.5, 2.5 2.5, 2.5 0.5, 0.5 0.5))'::geometry);
-- 0.707106781186548

-- linestring and linestring
SELECT 'hausdorff_ls_ls', st_hausdorffdistance(
	'LINESTRING (0 0, 2 1)'::geometry
	, 'LINESTRING (0 0, 2 0)'::geometry);
-- 1.0

-- other linestrings
SELECT 'hausdorff_ls_ls_2', st_hausdorffdistance(
	'LINESTRING (0 0, 2 0)'::geometry,
	'LINESTRING (0 1, 1 2, 2 1)'::geometry);
-- 2.0

-- linestring and multipoint
SELECT 'hausdorff_ls_mp', st_hausdorffdistance(
	'LINESTRING (0 0, 2 0)'::geometry,
	'MULTIPOINT (0 1, 1 0, 2 1)'::geometry);
-- 1.0

-- another linestring and linestring
SELECT 'hausdorff_ls_ls_3', st_hausdorffdistance(
	'LINESTRING (130 0, 0 0, 0 150)'::geometry,
	'LINESTRING (10 10, 10 150, 130 10)'::geometry);
-- 14.142135623730951

-- hausdorf with densification
SELECT 'hausdorffdensify_ls_ls', st_hausdorffdistance(
	'LINESTRING (130 0, 0 0, 0 150)'::geometry
	, 'LINESTRING (10 10, 10 150, 130 10)'::geometry, 0.5);
-- 70.0