File: measures.sql

package info (click to toggle)
postgis 3.5.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 70,052 kB
  • sloc: ansic: 162,204; sql: 93,950; xml: 53,121; cpp: 12,646; perl: 5,658; sh: 5,369; makefile: 3,434; python: 1,205; yacc: 447; lex: 151; pascal: 58
file content (329 lines) | stat: -rw-r--r-- 16,870 bytes parent folder | download | duplicates (2)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329

select '113', ST_area2d('MULTIPOLYGON( ((0 0, 10 0, 10 10, 0 10, 0 0)),( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5) ) ,( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7, 5 7, 5 5),(1 1,2 1, 2 2, 1 2, 1 1) ) )'::GEOMETRY) as value;

select '114', ST_perimeter2d('MULTIPOLYGON( ((0 0, 10 0, 10 10, 0 10, 0 0)),( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5) ) ,( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7, 5 7, 5 5),(1 1,2 1, 2 2, 1 2, 1 1) ) )'::GEOMETRY) as value;

select '115', ST_3DPerimeter('MULTIPOLYGON( ((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0)),( (0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0),(5 5 0, 7 5 0, 7 7  0, 5 7 0, 5 5 0) ) ,( (0 0 1, 10 0 1, 10 10 1, 0 10 1, 0 0 1),(5 5 1, 7 5 1, 7 7 1, 5 7 1, 5 5 1),(1 1 1,2 1 1, 2 2 1, 1 2 1, 1 1 1) ) )'::GEOMETRY) as value;

select '116', ST_length2d('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2) )'::GEOMETRY)::numeric(12,6) as value;
select '117', ST_3dlength('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2) )'::GEOMETRY)::numeric(12,6) as value;
select '118', ST_3dlength('MULTILINESTRING((0 0 0, 1 1 1),(0 0 0, 1 1 1, 2 2 2) )'::GEOMETRY)::numeric(12,6) as value;

select '134', ST_Distance('POINT(1 2)', 'POINT(1 2)');
select '135', ST_Distance('POINT(5 0)', 'POINT(10 12)');

select '136', ST_Distance('POINT(0 0)', ST_translate('POINT(0 0)', 5, 12, 0));

-- postgis-users/2006-May/012174.html
select 'dist', ST_Distance(a,b), ST_Distance(b,a) from (
	select 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry as a,
		'POLYGON((11 0, 11 10, 20 10, 20 0, 11 0),
			(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
	) as foo;

--#1502
SELECT '#1502', ST_Dwithin(a,b,0.0)  from
(SELECT 'LINESTRING(-97364 -97364, 9736.4 9736.4)'::geometry a, 'POINT(0 0)'::geometry b ) foo;

--st_shortestline

select 'st_shortestline_134', st_astext(st_shortestline('POINT(1 2)', 'POINT(1 2)'));
select 'st_shortestline_135', st_astext(st_shortestline('POINT(5 0)', 'POINT(10 12)'));

select 'st_shortestline_136', st_astext(st_shortestline('POINT(0 0)', ST_translate('POINT(0 0)', 5, 12, 0)));

-- postgis-users/2006-May/012174.html
select 'st_shortestline_dist', st_astext(st_shortestline(a,b)), st_astext(st_shortestline(b,a)) from (
	select 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry as a,
		'POLYGON((11 0, 12 10, 20 10, 20 0, 11 0),
			(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
	) as foo;

--st_maxdistance

select 'st_maxdistance_134', st_maxdistance('POINT(1 2)', 'POINT(1 2)');
select 'st_maxdistance_135', st_maxdistance('POINT(5 0)', 'POINT(10 12)');

select 'st_maxdistance_136', st_maxdistance('POINT(0 0)', ST_translate('POINT(0 0)', 5, 12, 0));

-- postgis-users/2006-May/012174.html
select 'st_maxdistance_dist', st_maxdistance(a,b)::numeric(12,6), st_maxdistance(b,a)::numeric(12,6) from (
	select 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry as a,
		'POLYGON((11 0, 11 10, 20 10, 20 0, 11 0),
			(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
	) as foo;

--st_longestline

select 'st_longestline_134', st_astext(st_longestline('POINT(1 2)', 'POINT(1 2)'));
select 'st_longestline_135', st_astext(st_longestline('POINT(5 0)', 'POINT(10 12)'));

select 'st_longestline_136', st_astext(st_longestline('POINT(0 0)', ST_translate('POINT(0 0)', 5, 12, 0)));

-- postgis-users/2006-May/012174.html
select 'st_longestline_dist', st_astext(st_longestline(a,b)), st_astext(st_longestline(b,a)) from (
	select 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry as a,
		'POLYGON((11 0, 11 10, 20 10, 20 0, 11 0),
			(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
	) as foo;

select 'distancetest1',
	ST_Distance(a, b),
	st_maxdistance(a, b),
	st_astext(st_shortestline(a,b)),
	st_astext(st_shortestline(b,a)),
	st_astext(st_longestline(a,b)),
	st_astext(st_longestline(b,a)) from (
select
	ST_GeomFromText('MULTILINESTRING((17 16, 16 17, 17 18, 17 17, 17 16), (28 35,29 39, 30 35))') as a,
	ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14)),((33 35,33 40, 35 40, 35 35, 33 35)))') as b
) as foo;

select  'distancetest2',
	ST_Distance(a, b),
	st_maxdistance(a, b),
	round(st_x(st_startpoint(st_shortestline(a,b)))::numeric, 10),
	round(st_y(st_startpoint(st_shortestline(a,b)))::numeric, 10),
	round(st_x(st_endpoint(st_shortestline(a,b)))::numeric, 10),
	round(st_y(st_endpoint(st_shortestline(a,b)))::numeric, 10),
	st_astext(st_longestline(a,b)),
	st_astext(st_longestline(b,a)) from (
select
	ST_GeomFromText('LINESTRING(-40 -20 , 4 2)') as a,
	ST_GeomFromText('LINESTRING(-10 20, 1 -2)') as b
) as foo;

select 'distancepoly1',
	ST_Distance(a, b),
	st_maxdistance(a, b),
	st_astext(st_shortestline(a,b)),
	st_astext(st_shortestline(b,a)),
	st_astext(st_longestline(a,b)),
	st_astext(st_longestline(b,a)) from (
select
	ST_GeomFromText('MULTIPOLYGON(((17 16, 16 17, 17 18, 17 17, 17 16)), ((28 35,29 39, 30 35, 28 35)))') as a,
	ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14)),((33 35,33 40, 35 40, 35 35, 33 35)))') as b
) as foo;

select 'distancepoly2',
		ST_Distance(a, b),
		st_maxdistance(a, b)::numeric(12,6),
		st_astext(st_shortestline(a,b)),
		st_astext(st_shortestline(b,a)),
		st_astext(st_longestline(a,b)),
		st_astext(st_longestline(b,a)) from (
	select ST_GeomFromText('POLYGON((17 14, 16 17, 17 18, 17 17, 17 14))') as a,
			ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
	) as foo;

select 'distancepoly3',
		ST_Distance(a, b),
		st_maxdistance(a, b)::numeric(12,6),
		st_astext(st_shortestline(a,b)),
		st_astext(st_shortestline(b,a)),
		st_astext(st_longestline(a,b)),
		st_astext(st_longestline(b,a)) from (
	select ST_GeomFromText('POLYGON((17 16, 16 17, 17 19, 17 17, 17 16))') as a,
			ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
	) as foo;

select 'distancepoly4',
		ST_Distance(a, b),
			st_maxdistance(a, b)::numeric(12,6),
				st_astext(st_shortestline(a,b)),
					st_astext(st_shortestline(b,a)),
						st_astext(st_longestline(a,b)),
							st_astext(st_longestline(b,a)) from (
	select ST_GeomFromText('POLYGON((17 16, 16 17, 16 20, 18 20, 18 17, 17 16))') as a,
			ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
	) as foo;

select 'distancepoly5',
		ST_Distance(a, b),
			st_maxdistance(a, b)::numeric(12,6),
				st_astext(st_shortestline(a,b)),
					st_astext(st_shortestline(b,a)),
						st_astext(st_longestline(a,b)),
							st_astext(st_longestline(b,a)) from (
	select ST_GeomFromText('POLYGON((17 12, 16 17, 17 18, 17 17, 17 12))') as a,
			ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
	) as foo;

select 'distancepoly6',
		ST_Distance(a, b),
			st_maxdistance(a, b)::numeric(12,6),
				st_astext(st_shortestline(a,b)),
					st_astext(st_shortestline(b,a)),
						st_astext(st_longestline(a,b)),
							st_astext(st_longestline(b,a)) from (
	select ST_GeomFromText('POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))') as a,
			ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
	) as foo;

--3D Distance functions

SELECT '3dDistancetest1',
	ST_3DDistance(a,b)::numeric(12,6),
		ST_3DMaxDistance(a,b)::numeric(12,6),
			ST_3DDWithin(a,b,5),
				ST_3DDFullyWithin(a,b,5),
					ST_ASEWKT(ST_3DShortestline(a,b)),
						ST_ASEWKT(ST_3DClosestpoint(a,b)),
							ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
	SELECT 'POINT(1 1 1)'::geometry as a, 'POINT(3 2 7)'::geometry as b
	) as foo;

SELECT '3dDistancetest2',
	ST_3DDistance(a,b),
		ST_3DMaxDistance(a,b)::numeric(12,6),
			ST_3DDWithin(a,b,5),
				ST_3DDFullyWithin(a,b,5),
					ST_ASEWKT(ST_3DShortestline(a,b)),
						ST_ASEWKT(ST_3DClosestpoint(a,b)),
							ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
	SELECT 'POINT(1 1 1)'::geometry as a, 'LINESTRING(0 0 0, 2 2 2)'::geometry as b
	) as foo;

SELECT '3dDistancetest3',
	ST_3DDistance(a,b)::numeric(12,6),
		ST_3DMaxDistance(a,b)::numeric(12,6),
			ST_3DDWithin(a,b,5),
				ST_3DDFullyWithin(a,b,5),
					ST_ASEWKT(ST_SnapToGrid(ST_3DShortestline(a,b), 1e-14)),
						ST_ASEWKT(ST_3DClosestpoint(a,b)),
							ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
	SELECT 'POINT(1 1 1)'::geometry as a, 'LINESTRING(5 2 6, -3 -2 4)'::geometry as b
	) as foo;

SELECT '3dDistancetest4',
	ST_3DDistance(a,b),
		ST_3DMaxDistance(a,b)::numeric(12,6),
			ST_3DDWithin(a,b,5),
				ST_3DDFullyWithin(a,b,5),
					ST_ASEWKT(ST_3DShortestline(a,b)),
						ST_ASEWKT(ST_3DClosestpoint(a,b)),
							ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
	SELECT  'LINESTRING(1 1 3, 5 7 8)'::geometry  as a, 'POINT(1 1 1)'::geometry as b
	) as foo;

	SELECT '3dDistancetest5',
	ST_3DDistance(a,b),
		ST_3DMaxDistance(a,b),
			ST_3DDWithin(a,b,5),
				ST_3DDFullyWithin(a,b,5),
					ST_ASEWKT(ST_3DShortestline(a,b)),
						ST_ASEWKT(ST_3DClosestpoint(a,b)),
							ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
	SELECT  'LINESTRING(1 0 5, 11 0 5)'::geometry  as a, 'LINESTRING(5 2 0, 5 2 10, 5 0 13)'::geometry as b
	) as foo;

SELECT '3dDistancetest6',
	ST_3DDistance(a,b) FROM (
	SELECT 'LINESTRING(1 1 1 , 2 2 2)'::geometry as a, 'POLYGON((0 0 0, 2 2 2, 3 3 3, 0 0 0))'::geometry as b) as foo;

SELECT '3dDistancetest7',
	ST_3DDistance(a,b) FROM (
	SELECT 'LINESTRING(1 1 1 , 2 2 2)'::geometry as a, 'POLYGON((0 0 0, 2 2 2, 3 3 1, 0 0 0))'::geometry as b) as foo;

-- 3D mixed dimmentionality #2034
--closestpoint with 2d as first point and 3d as second
select st_astext(st_3dclosestpoint('linestring(0 0,1 1,2 0)'::geometry, 'linestring(0 2 3, 3 2 3)'::geometry));

--closestpoint with 3d as first point and 2d as second
select st_astext(st_3dclosestpoint('linestring(0 0 1,1 1 2,2 0 3)'::geometry, 'linestring(0 2, 3 2)'::geometry));

--shortestline with 2d as first point and 3d as second
select st_astext(st_3dshortestline('linestring(0 0,1 1,2 0)'::geometry, 'linestring(0 2 3, 3 2 3)'::geometry));

--shortestline with 3d as first point and 2d as second
select st_astext(st_3dshortestline('linestring(0 0 1,1 1 2,2 0 3)'::geometry, 'linestring(0 2, 3 2)'::geometry));

--distance with 2d as first point and 3d as second
select st_3ddistance('linestring(0 0,1 1,2 0)'::geometry, 'linestring(0 2 3, 3 2 3)'::geometry);

--distance with 3d as first point and 2d as second
select st_3ddistance('linestring(0 0 1,1 1 2,2 0 3)'::geometry, 'linestring(0 2, 3 2)'::geometry);

select ST_AsText(ST_3DClosestPoint('POINT(0 0 0)', 'POINT(0 0)'));
select ST_AsText(ST_3DShortestLine('LINESTRING(2 1, 3 0)', 'LINESTRING(0 0 2, 3 3 -4)'));

-- Area of an empty polygon
select 'emptyPolyArea', st_area('POLYGON EMPTY');

-- Area of an empty linestring
select 'emptyLineArea', st_area('LINESTRING EMPTY');

-- Area of an empty point
select 'emptyPointArea', st_area('POINT EMPTY');

-- Area of an empty multipolygon
select 'emptyMultiPolyArea', st_area('MULTIPOLYGON EMPTY');

-- Area of an empty multilinestring
select 'emptyMultiLineArea', st_area('MULTILINESTRING EMPTY');

-- Area of an empty multilipoint
select 'emptyMultiPointArea', st_area('MULTIPOINT EMPTY');

-- Area of an empty collection
select 'emptyCollectionArea', st_area('GEOMETRYCOLLECTION EMPTY');

--
select 'spheroidLength1_deprecated', round(ST_LengthSpheroid('MULTILINESTRING((-118.584 38.374,-118.583 38.5),(-71.05957 42.3589 , -71.061 43))'::geometry,'SPHEROID["GRS_1980",6378137,298.257222101]'::spheroid)::numeric,5);
select 'spheroidLength1', round(ST_LengthSpheroid('MULTILINESTRING((-118.584 38.374,-118.583 38.5),(-71.05957 42.3589 , -71.061 43))'::geometry,'SPHEROID["GRS_1980",6378137,298.257222101]'::spheroid)::numeric,5);

select 'length2d_spheroid', ST_Length2DSpheroid('LINESTRING(0 0 0, 0 0 100)'::geometry, 'SPHEROID["GRS_1980",6378137,298.257222101]');
select 'length_spheroid', ST_LengthSpheroid('LINESTRING(0 0 0, 0 0 100)'::geometry, 'SPHEROID["GRS_1980",6378137,298.257222101]');


-- Solid intersects solid when contains it
select '#4278.1', ST_3DIntersects('BOX3D(0 0 0, 1 1 1)'::box3d::geometry, 'BOX3D(-1 -1 -1, 2 2 2)'::box3d::geometry);
select '#4278.2', ST_3DDistance('BOX3D(0 0 0, 1 1 1)'::box3d::geometry, 'BOX3D(-1 -1 -1, 2 2 2)'::box3d::geometry);
-- cast to text and back as a way of getting rid of solid flag
select '#4278.3', ST_3DIntersects('BOX3D(0 0 0, 1 1 1)'::box3d::geometry::text::geometry, 'BOX3D(-1 -1 -1, 2 2 2)'::box3d::geometry::text::geometry);
select '#4278.4', ST_3DDistance('BOX3D(0 0 0, 1 1 1)'::box3d::geometry::text::geometry, 'BOX3D(-1 -1 -1, 2 2 2)'::box3d::geometry::text::geometry);


SELECT '#4328.1', ST_Intersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'POINT(.1 .1)'::geometry), ST_3DIntersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'POINT(.1 .1)'::geometry);
SELECT '#4328.2', ST_Intersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'LINESTRING(.1 .1, .2 .2)'::geometry), ST_3DIntersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'LINESTRING(.1 .1, .2 .2)'::geometry);
SELECT '#4328.3', ST_Intersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'TRIANGLE((.1 .1, .2 .2, .2 .1, .1 .1))'::geometry), ST_3DIntersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'TRIANGLE((.1 .1, .2 .2, .2 .1, .1 .1))'::geometry);
SELECT '#4328.4', ST_Intersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'POLYGON((.1 .1, .2 .2, .2 .1, .1 .1))'::geometry), ST_3DIntersects('TIN(((0 0,1 0,0 1,0 0)))'::geometry, 'POLYGON((.1 .1, .2 .2, .2 .1, .1 .1))'::geometry);
SELECT '#4328.5', ST_Intersects('TIN(((0 0,3 0,0 3,0 0)))'::geometry, 'CIRCULARSTRING(1.1 1.1, 1.2 1.2, 1.2 1.1)'::geometry), ST_3DIntersects('TIN(((0 0,3 0,0 3,0 0)))'::geometry, 'CIRCULARSTRING(1.1 1.1, 1.2 1.2, 1.2 1.1)'::geometry);
SELECT '#4328.6', ST_Intersects('TIN(((0 0,3 0,0 3,0 0)))'::geometry, 'CURVEPOLYGON(CIRCULARSTRING(1.1 1.1, 1.2 1.2, 1.2 1.1, 1.2 1.2, 1.1 1.1))'::geometry), ST_3DIntersects('TIN(((0 0,3 0,0 3,0 0)))'::geometry, 'CURVEPOLYGON(CIRCULARSTRING(1.1 1.1, 1.2 1.2, 1.2 1.1, 1.2 1.2, 1.1 1.1))'::geometry);

SELECT 'st_project.01', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 1, 0), 0.1), 2);
SELECT 'st_project.02', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 1, pi()), 0.1), 2);
SELECT 'st_project.03', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 1, pi()/2), 0.1), 2);
SELECT 'st_project.04', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 1, 3*pi()/2), 0.1), 2);
SELECT 'st_project.05', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 1, pi()/4), 0.001), 3);
SELECT 'st_project.06', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 1, pi()+pi()/4), 0.001), 3);
SELECT 'st_project.07', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 0, 0), 0.001), 3);
SELECT 'st_project.08', ST_AsText(ST_SnapToGrid(ST_Project('POINT(10 10)'::geometry, 1, pi()+pi()/4), 0.001), 3);

SELECT 'st_project.11', ST_AsText(ST_SnapToGrid(ST_Project('POINT(1 0)'::geometry, 'POINT(0 0)'::geometry, 1), 0.1), 2);
SELECT 'st_project.12', ST_AsText(ST_SnapToGrid(ST_Project('POINT(-1 0)'::geometry, 'POINT(0 0)'::geometry, 1), 0.1), 2);
SELECT 'st_project.13', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 1)'::geometry, 'POINT(0 0)'::geometry, 1), 0.1), 2);
SELECT 'st_project.14', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 -1)'::geometry, 'POINT(0 0)'::geometry, 1), 0.1), 2);
SELECT 'st_project.15', ST_AsText(ST_SnapToGrid(ST_Project('POINT(1 1)'::geometry, 'POINT(0 0)'::geometry, 1), 0.001), 3);
SELECT 'st_project.16', ST_AsText(ST_SnapToGrid(ST_Project('POINT(-1 -1)'::geometry, 'POINT(0 0)'::geometry, 1), 0.001), 3);
SELECT 'st_project.17', ST_AsText(ST_SnapToGrid(ST_Project('POINT(0 0)'::geometry, 'POINT(0 0)'::geometry, 1), 0.001), 3);
SELECT 'st_project.18', ST_AsText(ST_SnapToGrid(ST_Project('POINT(10 10)'::geometry, 'POINT(8 8)'::geometry, 1), 0.001), 3);

SELECT 'st_lineextend.1', ST_AsText(ST_SnapToGrid(ST_LineExtend('LINESTRING(0 0,1 1)'::geometry, 1, 1), 0.001), 3);
SELECT 'st_lineextend.2', ST_AsText(ST_SnapToGrid(ST_LineExtend('LINESTRING(0 0,1 1)'::geometry, 0, 1), 0.001), 3);
SELECT 'st_lineextend.3', ST_AsText(ST_SnapToGrid(ST_LineExtend('LINESTRING(0 0,1 1)'::geometry, 1), 0.001), 3);
SELECT 'st_lineextend.4', ST_AsText(ST_SnapToGrid(ST_LineExtend('LINESTRING(0 0,1 1,1 1,1 1)'::geometry, 1), 0.001), 3);
SELECT 'st_lineextend.5', ST_AsText(ST_SnapToGrid(ST_LineExtend('LINESTRING EMPTY'::geometry, 1), 0.001), 3);
SELECT 'st_lineextend.6', ST_AsText(ST_SnapToGrid(ST_LineExtend('POINT EMPTY'::geometry, 1), 0.001), 3);

-- #5782
WITH inp AS (
	SELECT
	'LINESTRING(18.00678831099686 69.0404811833497,18.006784630996860 69.04045431334970,18.00677727099686 69.0404005833497)'::geometry a,
	'LINESTRING(18.00677727099686 69.0404005833497,18.006780950996863 69.04042744334969,18.00678831099686 69.0404811833497)'::geometry b,
	'POINT(18.006691126034692 69.04048768506776)'::geometry q
)
SELECT
	'#5782',
	ST_Distance(a,q) < ST_Distance(b,q)
FROM inp;