File: reference_measure.xml

package info (click to toggle)
postgis 3.5.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 69,528 kB
  • sloc: ansic: 162,229; sql: 93,970; xml: 53,139; cpp: 12,646; perl: 5,658; sh: 5,369; makefile: 3,435; python: 1,205; yacc: 447; lex: 151; pascal: 58
file content (2078 lines) | stat: -rw-r--r-- 81,371 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
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
<!-- Converted by db4-upgrade version 1.1 -->
<section xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Measurement_Functions">
    <title>Measurement Functions</title><info>
    <abstract>
    <para>These functions compute measurements of distance, area and angles.
		There are also functions to compute geometry values determined by measurements.</para>
    </abstract>
    </info>



	<refentry xml:id="ST_Area">
		<refnamediv>
		  <refname>ST_Area</refname>

		  <refpurpose>Returns the area of a polygonal geometry.
			</refpurpose>
		</refnamediv>
		<refsynopsisdiv>
		  <funcsynopsis>
			<funcprototype>
			  <funcdef>float <function>ST_Area</function></funcdef>
				<paramdef><type>geometry </type><parameter>g1</parameter></paramdef>
			</funcprototype>

			<funcprototype>
			  <funcdef>float <function>ST_Area</function></funcdef>
				<paramdef><type>geography </type><parameter>geog</parameter></paramdef>
				<paramdef choice="opt"><type>boolean </type><parameter>use_spheroid = true</parameter></paramdef>
			</funcprototype>
		  </funcsynopsis>
		</refsynopsisdiv>
		<refsection>
			<title>Description</title>

			<para>Returns the area of a polygonal geometry.
			For geometry types a 2D Cartesian (planar) area is computed, with units specified by the SRID.
			For geography types by default area is determined on a spheroid with units in square meters.
		  To compute the area using the faster but less accurate spherical model use <varname>ST_Area(geog,false)</varname>.
		  </para>
			<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 - support for 2D polyhedral surfaces was introduced.</para>
			<para role="enhanced" conformance="2.2.0">Enhanced: 2.2.0 - measurement on spheroid performed with GeographicLib for improved accuracy and robustness.  Requires PROJ &gt;= 4.9.0 to take advantage of the new feature.</para>
			<para role="changed" conformance="3.0.0">Changed: 3.0.0 - does not depend on SFCGAL anymore.</para>
			<para>&sfs_compliant;</para>
			<para>&sqlmm_compliant; SQL-MM 3: 8.1.2, 9.5.3</para>
			<para>&P_support;</para>
			<note><para>For polyhedral surfaces, only supports 2D polyhedral surfaces (not 2.5D).  For 2.5D, may give a non-zero answer, but only for the faces that
			sit completely in XY plane.</para></note>
		</refsection>

		  <refsection>
			<title>Examples</title>
			<para>Return area in square feet for a plot of Massachusetts land and multiply by conversion to get square meters.
				Note this is in square feet because EPSG:2249 is
				Massachusetts State Plane Feet </para>
			<programlisting>
select ST_Area(geom) sqft,
    ST_Area(geom) * 0.3048 ^ 2 sqm
from (
         select 'SRID=2249;POLYGON((743238 2967416,743238 2967450,
				 743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
     ) subquery;
┌─────────┬─────────────┐
│  sqft   │     sqm     │
├─────────┼─────────────┤
│ 928.625 │ 86.27208552 │
└─────────┴─────────────┘
</programlisting>
<para>Return area square feet and transform to Massachusetts state plane meters (EPSG:26986) to get square meters.
				Note this is in square feet because 2249 is
				Massachusetts State Plane Feet and transformed area is in square meters since EPSG:26986 is state plane Massachusetts meters </para>
<programlisting>select ST_Area(geom) sqft,
    ST_Area(ST_Transform(geom, 26986)) As sqm
from (
         select
             'SRID=2249;POLYGON((743238 2967416,743238 2967450,
             743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
     ) subquery;
┌─────────┬─────────────────┐
│  sqft   │       sqm       │
├─────────┼─────────────────┤
│ 928.625 │ 86.272430607008 │
└─────────┴─────────────────┘
</programlisting>

<para>Return area square feet and square meters using geography data type.  Note that we transform to our geometry to geography
	(before you can do that make sure your geometry is in WGS 84 long lat 4326).  Geography always measures in meters.
	This is just for demonstration to compare.  Normally your table will be stored in geography data type already.</para>
<programlisting>

select ST_Area(geog) / 0.3048 ^ 2 sqft_spheroid,
    ST_Area(geog, false) / 0.3048 ^ 2 sqft_sphere,
    ST_Area(geog) sqm_spheroid
from (
         select ST_Transform(
                    'SRID=2249;POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))'::geometry,
                    4326
             ) :: geography geog
     ) as subquery;
┌──────────────────┬──────────────────┬──────────────────┐
│  sqft_spheroid   │   sqft_sphere    │   sqm_spheroid   │
├──────────────────┼──────────────────┼──────────────────┤
│ 928.684405784452 │ 927.049336105925 │ 86.2776044979692 │
└──────────────────┴──────────────────┴──────────────────┘
</programlisting>

 <para>If your data is in geography already:</para>
 <programlisting>
select ST_Area(geog) / 0.3048 ^ 2 sqft,
    ST_Area(the_geog) sqm
from somegeogtable;</programlisting>
		  </refsection>
		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_3DArea"/>, <xref linkend="ST_GeomFromText"/>, <xref linkend="ST_GeographyFromText"/>, <xref linkend="ST_SetSRID"/>, <xref linkend="ST_Transform"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Azimuth">
		<refnamediv>
		  <refname>ST_Azimuth</refname>

		  <refpurpose>Returns the north-based azimuth of a line between two points.</refpurpose>
		</refnamediv>
		<refsynopsisdiv>
		  <funcsynopsis>
			<funcprototype>
			  <funcdef>float <function>ST_Azimuth</function></funcdef>
			  <paramdef><type>geometry </type><parameter>origin</parameter></paramdef>
			  <paramdef><type>geometry </type><parameter>target</parameter></paramdef>
			</funcprototype>
			<funcprototype>
			  <funcdef>float <function>ST_Azimuth</function></funcdef>
			  <paramdef><type>geography </type><parameter>origin</parameter></paramdef>
			  <paramdef><type>geography </type><parameter>target</parameter></paramdef>
			</funcprototype>
		  </funcsynopsis>
		</refsynopsisdiv>
		<refsection>
			<title>Description</title>

			<para>Returns the azimuth in radians of the target point from the origin point,
            or NULL if the two points are coincident.
            The azimuth angle is a positive clockwise angle
            referenced from the positive Y axis (geometry) or the North meridian (geography):
            North = 0; Northeast = &#x03C0;/4; East = &#x03C0;/2; Southeast = 3&#x03C0;/4;
            South = &#x03C0;; Southwest 5&#x03C0;/4; West = 3&#x03C0;/2; Northwest = 7&#x03C0;/4.</para>
			<para>For the geography type, the azimuth solution is known as the
                  <link xlink:href="https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid">inverse geodesic problem</link>.</para>
			<para>The azimuth is a mathematical concept defined as the angle between a reference vector and a point, with angular units in radians.
			The result value in radians can be converted to degrees using the PostgreSQL function <varname>degrees()</varname>.</para>

			<para>Azimuth can be used in conjunction with <xref linkend="ST_Translate"/> to shift an object along its perpendicular axis. See
				 the <varname>upgis_lineshift()</varname> function in the <link xlink:href="http://trac.osgeo.org/postgis/wiki/UsersWikiplpgsqlfunctions">PostGIS wiki</link> for an implementation of this.</para>

			<para role="availability" conformance="1.1.0">Availability: 1.1.0</para>
			<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for geography was introduced.</para>
			<para role="enhanced" conformance="2.2.0">Enhanced: 2.2.0 measurement on spheroid performed with GeographicLib for improved accuracy and robustness.  Requires PROJ &gt;= 4.9.0 to take advantage of the new feature.</para>
		</refsection>

		<refsection>
		<title>Examples</title>
		<para>Geometry Azimuth in degrees </para>
<programlisting>
SELECT degrees(ST_Azimuth( ST_Point(25, 45),  ST_Point(75, 100))) AS degA_B,
       degrees(ST_Azimuth( ST_Point(75, 100), ST_Point(25, 45) )) AS degB_A;

      dega_b       |     degb_a
------------------+------------------
 42.2736890060937 | 222.273689006094
</programlisting>
		<informaltable>
		  <tgroup cols="2">
			<tbody>
				<row>
				<entry><para><informalfigure>
					<mediaobject>
					  <imageobject>
						<imagedata fileref="images/st_azimuth01.png"/>
					  </imageobject>
					  <caption><para>Blue: origin Point(25,45); Green: target Point(75, 100); Yellow: Y axis or North;
                      Red: azimuth angle.</para></caption>
					</mediaobject>
				  </informalfigure>
				</para></entry>
				<entry><para><informalfigure>
					<mediaobject>
					  <imageobject>
						<imagedata fileref="images/st_azimuth02.png"/>
					  </imageobject>
					  <caption><para>Blue: origin Point(75, 100); Green: target Point(25, 45); Yellow: Y axis or North;
                      Red: azimuth angle.</para></caption>
					</mediaobject>
				  </informalfigure>
				</para></entry>
				</row>
			</tbody>
			</tgroup>
		</informaltable>
		</refsection>
		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_Angle"/>, <xref linkend="ST_Point"/>, <xref linkend="ST_Translate"/>, <xref linkend="ST_Project"/>, <link xlink:href="http://www.postgresql.org/docs/current/interactive/functions-math.html">PostgreSQL Math Functions</link></para>
		</refsection>

  </refentry>

  	<refentry xml:id="ST_Angle">
		<refnamediv>
		  <refname>ST_Angle</refname>

		  <refpurpose>Returns the angle between two vectors defined by 3 or 4 points, or 2 lines.</refpurpose>
		</refnamediv>
		<refsynopsisdiv>
		  <funcsynopsis>
			<funcprototype>
			  <funcdef>float <function>ST_Angle</function></funcdef>
			  <paramdef><type>geometry </type><parameter>point1</parameter></paramdef>
			  <paramdef><type>geometry </type><parameter>point2</parameter></paramdef>
			  <paramdef><type>geometry </type><parameter>point3</parameter></paramdef>
			  <paramdef choice="opt"><type>geometry </type><parameter>point4</parameter></paramdef>
			</funcprototype>
			<funcprototype>
			  <funcdef>float <function>ST_Angle</function></funcdef>
			  <paramdef><type>geometry </type><parameter>line1</parameter></paramdef>
			  <paramdef><type>geometry </type><parameter>line2</parameter></paramdef>
			</funcprototype>
		  </funcsynopsis>
		</refsynopsisdiv>
		<refsection>
			<title>Description</title>

			<para> Computes the clockwise angle between two vectors.
			</para>

        <para><emphasis role="bold">Variant 1:</emphasis> computes the angle enclosed by the points P1-P2-P3. If a 4th point provided computes the angle points P1-P2 and P3-P4</para>
		<para><emphasis role="bold">Variant 2:</emphasis> computes the angle between two vectors S1-E1 and S2-E2,
        defined by the start and end points of the input lines
        </para>

			<para>The result is a positive angle between 0 and 2&#x03C0; radians.
            The radian result can be converted to degrees using the PostgreSQL function <varname>degrees()</varname>.
            </para>
			<para>Note that <varname>ST_Angle(P1,P2,P3) = ST_Angle(P2,P1,P2,P3)</varname>.</para>
			<para role="availability" conformance="2.5.0">Availability: 2.5.0</para>
		</refsection>

		<refsection>
		<title>Examples</title>

        <para>Angle between three points</para>
<programlisting>
SELECT degrees( ST_Angle('POINT(0 0)', 'POINT(10 10)', 'POINT(20 0)') );

 degrees
---------
     270
</programlisting>

        <para>Angle between vectors defined by four points</para>
<programlisting>
SELECT degrees( ST_Angle('POINT (10 10)', 'POINT (0 0)', 'POINT(90 90)', 'POINT (100 80)') );

      degrees
-------------------
 269.9999999999999
</programlisting>

        <para>Angle between vectors defined by the start and end points of lines</para>
<programlisting>
SELECT degrees( ST_Angle('LINESTRING(0 0, 0.3 0.7, 1 1)', 'LINESTRING(0 0, 0.2 0.5, 1 0)') );

      degrees
--------------
           45
</programlisting>

		</refsection>

	    <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Azimuth"/></para>
        </refsection>
  </refentry>

<refentry xml:id="ST_ClosestPoint">
	  <refnamediv>
		<refname>ST_ClosestPoint</refname>

		<refpurpose>Returns the 2D point on g1 that is closest to g2.  This is the first point of
			the shortest line from one geometry to the other.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>

		  <funcprototype>
			<funcdef>geometry <function>ST_ClosestPoint</function></funcdef>
			<paramdef><type>geometry </type>
			<parameter>geom1</parameter></paramdef>
			<paramdef><type>geometry </type>
			<parameter>geom2</parameter></paramdef>
		  </funcprototype>

          <funcprototype>
            <funcdef>geography <function>ST_ClosestPoint</function></funcdef>
            <paramdef><type>geography </type>
              <parameter>geom1</parameter></paramdef>
            <paramdef><type>geography </type>
              <parameter>geom2</parameter></paramdef>
            <paramdef choice="opt"><type>boolean </type>
              <parameter>use_spheroid = true</parameter></paramdef>
          </funcprototype>

		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 2-dimensional point on <varname>geom1</varname> that is closest to <varname>geom2</varname>.
        This is the first point of the shortest line between the geometries
        (as computed by <xref linkend="ST_ShortestLine"/>).
		</para>
		<note><para>If you have a 3D Geometry, you may prefer to use <xref linkend="ST_3DClosestPoint"/>.</para></note>
        <para role="enhanced" conformance="3.4.0">Enhanced: 3.4.0 -  Support for geography.</para>
		<para role="availability" conformance="1.5.0">Availability: 1.5.0</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

    <para><informalfigure>
        <mediaobject>
            <imageobject>
            <imagedata fileref="images/st_closestpoint01.png"/>
            </imageobject>
            <caption><para>The closest point for a Point and a LineString is the point itself.
            The closest point for a LineString and a Point is a point on the line.</para></caption>
        </mediaobject>
        </informalfigure>
<programlisting>
SELECT ST_AsText( ST_ClosestPoint(pt,line)) AS cp_pt_line,
       ST_AsText( ST_ClosestPoint(line,pt)) AS cp_line_pt
    FROM (SELECT 'POINT (160 40)'::geometry AS pt,
                 'LINESTRING (10 30, 50 50, 30 110, 70 90, 180 140, 130 190)'::geometry AS line ) AS t;

   cp_pt_line   |                cp_line_pt
----------------+------------------------------------------
 POINT(160 40)  | POINT(125.75342465753425 115.34246575342466)
</programlisting>
	</para>

    <para><informalfigure>
        <mediaobject>
            <imageobject>
            <imagedata fileref="images/st_closestpoint02.png"/>
            </imageobject>
            <caption><para>The closest point on polygon A to polygon B</para></caption>
        </mediaobject>
        </informalfigure>
<programlisting>
SELECT ST_AsText( ST_ClosestPoint(
		'POLYGON ((190 150, 20 10, 160 70, 190 150))',
		ST_Buffer('POINT(80 160)', 30)	)) As ptwkt;
------------------------------------------
 POINT(131.59149149528952 101.89887534906197)
</programlisting>
	</para>

	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_MaxDistance"/></para>
	  </refsection>
</refentry>

	<refentry xml:id="ST_3DClosestPoint">
		  <refnamediv>
			<refname>ST_3DClosestPoint</refname>

			<refpurpose>Returns the 3D point on g1 that is closest to g2.  This is the first point of
				the 3D shortest line.  </refpurpose>
		  </refnamediv>

		  <refsynopsisdiv>
			<funcsynopsis>
			  <funcprototype>
				<funcdef>geometry <function>ST_3DClosestPoint</function></funcdef>

				<paramdef><type>geometry </type>
				<parameter>g1</parameter></paramdef>

				<paramdef><type>geometry </type>
				<parameter>g2</parameter></paramdef>
			  </funcprototype>
			</funcsynopsis>
		  </refsynopsisdiv>

		  <refsection>
			<title>Description</title>

			<para>Returns the 3-dimensional point on g1 that is closest to g2.  This is the first point of
				the 3D shortest line. The 3D length of the 3D shortest line is the 3D distance.
			</para>
			<para>&Z_support;</para>
			<!-- Optionally mention supports Polyhedral Surface  -->
			<para>&P_support;</para>
			<para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
			<para role="changed" conformance="2.2.0">Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
		  </refsection>

		  <refsection>
			<title>Examples</title>
				<informaltable>
					  <tgroup cols="1">
						<tbody>
						  <row>
							<entry><para>linestring and point -- both 3d and 2d closest point
					<programlisting>
SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
		ST_AsEWKT(ST_ClosestPoint(line,pt)) As cp2d_line_pt
	FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
		) As foo;


 cp3d_line_pt						|               cp2d_line_pt
-----------------------------------------------------------+------------------------------------------
 POINT(54.6993798867619 128.935022917228 11.5475869506606) | POINT(73.0769230769231 115.384615384615)
					</programlisting>
							  </para></entry>
						    </row>
						    <row>
							<entry><para>linestring and multipoint -- both 3d and 2d closest point
					<programlisting>SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
		ST_AsEWKT(ST_ClosestPoint(line,pt)) As cp2d_line_pt
	FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
		) As foo;


                       cp3d_line_pt                        | cp2d_line_pt
-----------------------------------------------------------+--------------
 POINT(54.6993798867619 128.935022917228 11.5475869506606) | POINT(50 75)
					</programlisting>
							  </para></entry>
						  </row>
						  <row>
						  <entry><para>Multilinestring and polygon both 3d and 2d closest point
					<programlisting>SELECT ST_AsEWKT(ST_3DClosestPoint(poly, mline)) As cp3d,
    ST_AsEWKT(ST_ClosestPoint(poly, mline)) As cp2d
        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
                (1 10 2, 5 20 1))') As mline ) As foo;
                   cp3d                    |     cp2d
-------------------------------------------+--------------
 POINT(39.993580415989 54.1889925532825 5) | POINT(20 40)
             </programlisting>
							  </para></entry>
						  </row>
			</tbody>
		</tgroup>
	</informaltable>

		  </refsection>

		  <refsection>
			<title>See Also</title>

			<para><xref linkend="ST_AsEWKT"/>, <xref linkend="ST_ClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_3DShortestLine"/></para>
		  </refsection>
	</refentry>

	<refentry xml:id="ST_Distance">
	  <refnamediv>
		<refname>ST_Distance</refname>

		<refpurpose>Returns the distance between two geometry or geography values.</refpurpose>
	  </refnamediv>
	  <refsynopsisdiv>
		<funcsynopsis>

		  <funcprototype>
			<funcdef>float <function>ST_Distance</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>
		  </funcprototype>

		  <funcprototype>
			<funcdef>float <function>ST_Distance</function></funcdef>

			<paramdef><type>geography </type>
			<parameter>geog1</parameter></paramdef>

			<paramdef><type>geography </type>
			<parameter>geog2</parameter></paramdef>

			<paramdef choice="opt"><type>boolean </type>
			<parameter>use_spheroid = true</parameter></paramdef>
		  </funcprototype>

		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>For <xref linkend="geometry"/> types returns the minimum 2D Cartesian (planar) distance between two geometries, in
		projected units (spatial ref units).
		</para>
		<para>For <xref linkend="geography"/> types defaults to return the minimum geodesic distance between two geographies in meters,
		compute on the spheroid determined by the SRID.
		If <varname>use_spheroid</varname> is
		false, a faster spherical calculation is used.</para>

		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 5.1.23</para>
		<para>&curve_support;</para>

		<para role="availability" conformance="1.5.0">Availability: 1.5.0 geography support was introduced in 1.5.  Speed improvements for planar to better handle large or many vertex geometries</para>
		<para role="enhanced" conformance="2.1.0">Enhanced: 2.1.0 improved speed for geography. See <link xlink:href="http://boundlessgeo.com/2012/07/making-geography-faster/">Making Geography faster</link> for details.</para>
		<para role="enhanced" conformance="2.1.0">Enhanced: 2.1.0 - support for curved geometries was introduced.</para>
		<para role="enhanced" conformance="2.2.0">Enhanced: 2.2.0 - measurement on spheroid performed with GeographicLib for improved accuracy and robustness. Requires PROJ &gt;= 4.9.0 to take advantage of the new feature.</para>
		<para role="changed" conformance="3.0.0">Changed: 3.0.0 - does not depend on SFCGAL anymore.</para>
	  </refsection>

	  <refsection>
		<title>Geometry Examples</title>

		<para>Geometry example - units in planar degrees 4326 is WGS 84 long lat, units are degrees.</para>
		<programlisting>SELECT ST_Distance(
    'SRID=4326;POINT(-72.1235 42.3521)'::geometry,
    'SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry );
-----------------
0.00150567726382282</programlisting>

<para>Geometry example - units in meters (SRID: 3857, proportional to pixels on popular web maps).
Although the value is off, nearby ones can be compared correctly,
which makes it a good choice for algorithms like KNN or KMeans.</para>
<programlisting>SELECT ST_Distance(
    ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry, 3857),
    ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry, 3857) );
-----------------
167.441410065196</programlisting>

<para>Geometry example - units in meters (SRID: 3857 as above, but corrected by cos(lat) to account for distortion)</para>
<programlisting>SELECT ST_Distance(
    ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry, 3857),
    ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry, 3857)
		) * cosd(42.3521);
-----------------
123.742351254151</programlisting>

<para>Geometry example - units in meters (SRID: 26986 Massachusetts state plane meters) (most accurate for Massachusetts)</para>
<programlisting>SELECT ST_Distance(
    ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry, 26986),
    ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry, 26986) );
-----------------
123.797937878454</programlisting>

<para>Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (least accurate) </para>
<programlisting>SELECT ST_Distance(
    ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry, 2163),
    ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry, 2163) );
------------------
126.664256056812</programlisting>
	</refsection>
	  <refsection>
		<title>Geography Examples</title>
<para>Same as geometry example but note units in meters - use sphere for slightly faster and less accurate computation.</para>
<programlisting>SELECT ST_Distance(gg1, gg2) As spheroid_dist, ST_Distance(gg1, gg2, false) As sphere_dist
FROM (SELECT
    'SRID=4326;POINT(-72.1235 42.3521)'::geography as gg1,
    'SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geography as gg2
	) As foo  ;

  spheroid_dist   |   sphere_dist
------------------+------------------
 123.802076746848 | 123.475736916397</programlisting>
	</refsection>
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_3DDistance"/>, <xref linkend="ST_DWithin"/>, <xref linkend="ST_DistanceSphere"/>, <xref linkend="ST_Distance_Spheroid"/>,
		<xref linkend="ST_MaxDistance"/>, <xref linkend="ST_HausdorffDistance"/>,  <xref linkend="ST_FrechetDistance"/>, <xref linkend="ST_Transform"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_3DDistance">
	  <refnamediv>
		<refname>ST_3DDistance</refname>

		<refpurpose>Returns the 3D cartesian minimum distance (based on spatial ref) between two geometries in
		projected units. </refpurpose>
	  </refnamediv>
	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_3DDistance</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 3-dimensional minimum cartesian distance between two geometries in
		projected units (spatial ref units).</para>

		<para>&Z_support;</para>
		<!-- Optionally mention supports Polyhedral Surface  -->
		<para>&P_support;</para>
		<para>&sqlmm_compliant; SQL-MM ISO/IEC 13249-3</para>

		<para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 - In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
		<para role="changed" conformance="3.0.0">Changed: 3.0.0 - SFCGAL version removed</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>
-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
-- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
SELECT ST_3DDistance(
			ST_Transform('SRID=4326;POINT(-72.1235 42.3521 4)'::geometry,2163),
			ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'::geometry,2163)
		) As dist_3d,
		ST_Distance(
			ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry,2163),
			ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry,2163)
		) As dist_2d;

     dist_3d      |     dist_2d
------------------+-----------------
 127.295059324629 | 126.66425605671
</programlisting>
<programlisting>
-- Multilinestring and polygon both 3d and 2d distance
-- Same example as 3D closest point example
SELECT ST_3DDistance(poly, mline) As dist3d,
    ST_Distance(poly, mline) As dist2d
        FROM (SELECT  'POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))'::geometry as poly,
               'MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1), (1 10 2, 5 20 1))'::geometry as mline) as foo;
      dist3d       | dist2d
-------------------+--------
 0.716635696066337 |      0
</programlisting>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Distance"/>, <xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_3DMaxDistance"/>, <xref linkend="ST_3DShortestLine"/>, <xref linkend="ST_Transform"/></para>
	  </refsection>
	</refentry>

<refentry xml:id="ST_DistanceSphere">
	  <refnamediv>
		<refname>ST_DistanceSphere</refname>

		<refpurpose>Returns minimum distance in meters between two lon/lat
				geometries using a spherical earth model.
			</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_DistanceSphere</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomlonlatA</parameter></paramdef>
            <paramdef><type>geometry </type> <parameter>geomlonlatB</parameter></paramdef>
            <paramdef choice="opt"><type>float8 </type> <parameter>radius=6371008</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns minimum distance in meters between two lon/lat
				points. Uses a spherical earth and radius derived from the spheroid
        defined by the SRID.
				Faster than <xref linkend="ST_Distance_Spheroid"/>, but less
				accurate. PostGIS Versions prior to 1.5 only implemented for points.</para>

		<para role="availability" conformance="1.5">Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points.</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 In prior versions this used to be called ST_Distance_Sphere</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT round(CAST(ST_DistanceSphere(ST_Centroid(geom), ST_GeomFromText('POINT(-118 38)',4326)) As numeric),2) As dist_meters,
round(CAST(ST_Distance(ST_Transform(ST_Centroid(geom),32611),
		ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As dist_utm11_meters,
round(CAST(ST_Distance(ST_Centroid(geom), ST_GeomFromText('POINT(-118 38)', 4326)) As numeric),5) As dist_degrees,
round(CAST(ST_Distance(ST_Transform(geom,32611),
		ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As min_dist_line_point_meters
FROM
	(SELECT ST_GeomFromText('LINESTRING(-118.584 38.374,-118.583 38.5)', 4326) As geom) as foo;
	 dist_meters | dist_utm11_meters | dist_degrees | min_dist_line_point_meters
	-------------+-------------------+--------------+----------------------------
		70424.47 |          70438.00 |      0.72900 |                   65871.18

	</programlisting>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Distance"/>, <xref linkend="ST_Distance_Spheroid"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Distance_Spheroid">
	  <refnamediv>
		<refname>ST_DistanceSpheroid</refname>

		<refpurpose>Returns the minimum distance between two lon/lat geometries
		using a spheroidal earth model.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_DistanceSpheroid</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomlonlatA</parameter></paramdef>
			<paramdef><type>geometry </type> <parameter>geomlonlatB</parameter></paramdef>
			<paramdef choice="opt"><type>spheroid </type><parameter>measurement_spheroid=WGS84</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns minimum distance in meters between two lon/lat
				geometries given a particular spheroid. See the explanation of spheroids given for
			<xref linkend="ST_Length_Spheroid"/>.</para>
		<note>
			<para>This function does not look at the SRID of the geometry.
			It assumes the geometry coordinates are based on the provided spheroid.
			</para>
		</note>

		<para role="availability" conformance="1.5">Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points.</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 In prior versions this was called ST_Distance_Spheroid</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT round(CAST(
		ST_DistanceSpheroid(ST_Centroid(geom), ST_GeomFromText('POINT(-118 38)',4326), 'SPHEROID["WGS 84",6378137,298.257223563]')
			As numeric),2) As dist_meters_spheroid,
		round(CAST(ST_DistanceSphere(ST_Centroid(geom), ST_GeomFromText('POINT(-118 38)',4326)) As numeric),2) As dist_meters_sphere,
round(CAST(ST_Distance(ST_Transform(ST_Centroid(geom),32611),
		ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As dist_utm11_meters
FROM
	(SELECT ST_GeomFromText('LINESTRING(-118.584 38.374,-118.583 38.5)', 4326) As geom) as foo;
 dist_meters_spheroid | dist_meters_sphere | dist_utm11_meters
----------------------+--------------------+-------------------
			 70454.92 |           70424.47 |          70438.00

	</programlisting>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Distance"/>, <xref linkend="ST_DistanceSphere"/></para>
	  </refsection>
	</refentry>


	<refentry xml:id="ST_FrechetDistance">
	  <refnamediv>
		<refname>ST_FrechetDistance</refname>

		<refpurpose>Returns the Fréchet distance between two geometries.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_FrechetDistance</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>

			<paramdef><type>float</type>
			<parameter>densifyFrac = -1</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Implements algorithm for computing the Fréchet distance restricted to discrete points for both geometries, based on <link xlink:href="http://www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf">Computing Discrete Fréchet Distance</link>.
		The Fréchet distance is a measure of similarity between curves that takes into account the location and ordering of the points along the curves. Therefore it is often better than the Hausdorff distance. </para>
		<para>
When the optional densifyFrac is specified, this function performs a segment densification before computing the discrete Fréchet distance. The densifyFrac parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.
		</para>
		<para>Units are in the units of the spatial reference system of the geometries.
		</para>

		<note>
			<para>
The current implementation supports only vertices as the discrete locations. This could be extended to allow an arbitrary density of points to be used.
			</para>
		</note>
		<note>
			<para>
The smaller densifyFrac we specify, the more accurate Fréchet distance we get. But, the computation time and the memory usage increase with the square of the number of subsegments.
			</para>
		</note>
		<para>Performed by the GEOS module.</para>
		<para role="availability" conformance="2.4.0">Availability: 2.4.0 - requires GEOS &gt;= 3.7.0</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>
			<programlisting>postgres=# SELECT st_frechetdistance('LINESTRING (0 0, 100 0)'::geometry, 'LINESTRING (0 0, 50 50, 100 0)'::geometry);
 st_frechetdistance
--------------------
   70.7106781186548
(1 row)
			</programlisting>
			<programlisting>SELECT st_frechetdistance('LINESTRING (0 0, 100 0)'::geometry, 'LINESTRING (0 0, 50 50, 100 0)'::geometry, 0.5);
 st_frechetdistance
--------------------
                 50
(1 row)
			</programlisting>

	  </refsection>
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_HausdorffDistance"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_HausdorffDistance">
	  <refnamediv>
		<refname>ST_HausdorffDistance</refname>

		<refpurpose>Returns the Hausdorff distance between two geometries. </refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_HausdorffDistance</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>
		  </funcprototype>
		  <funcprototype>
			<funcdef>float <function>ST_HausdorffDistance</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>

			<paramdef><type>float</type>
			<parameter>densifyFrac</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the
        <link xlink:href="http://en.wikipedia.org/wiki/Hausdorff_distance">Hausdorff distance</link>
        between two geometries.
        The Hausdorff distance is a measure of how similar or dissimilar 2 geometries are.
		</para>
		<para>The function actually computes the "Discrete Hausdorff Distance".
        This is the Hausdorff distance computed at discrete points on the geometries.
        The <parameter>densifyFrac</parameter> parameter can be specified,
        to provide a more accurate answer by densifying
        segments before computing the discrete Hausdorff distance.
        Each segment is split into a number of equal-length subsegments
        whose fraction of the segment length is closest to the given fraction.
		</para>
		<para>Units are in the units of the spatial reference system of the geometries.
		</para>

		<note>
			<para>
			This algorithm is NOT equivalent to the standard Hausdorff distance.
            However, it computes an approximation that is correct for a large subset of useful cases.
			One important case is Linestrings that are roughly parallel to each other,
            and roughly equal in length.  This is a useful metric for line matching.
			</para>
		</note>
		<para role="availability" conformance="1.5.0">Availability: 1.5.0</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>

        <informalfigure>
            <mediaobject>
            <imageobject>
                <imagedata fileref="images/st_hausdorffdistance01.png"/>
            </imageobject>
            <caption><para>Hausdorff distance (red) and distance (yellow)
            between two lines </para></caption>
            </mediaobject>
        </informalfigure>

<programlisting>
SELECT ST_HausdorffDistance(geomA, geomB),
       ST_Distance(geomA, geomB)
    FROM (SELECT 'LINESTRING (20 70, 70 60, 110 70, 170 70)'::geometry AS geomA,
                 'LINESTRING (20 90, 130 90, 60 100, 190 100)'::geometry AS geomB) AS t;
 st_hausdorffdistance | st_distance
----------------------+-------------
    37.26206567625497 |          20
</programlisting>

<para><emphasis role="bold">Example:</emphasis> Hausdorff distance with densification.</para>
<programlisting>
SELECT ST_HausdorffDistance(
            'LINESTRING (130 0, 0 0, 0 150)'::geometry,
            'LINESTRING (10 10, 10 150, 130 10)'::geometry,
            0.5);
 ----------------------
          70
</programlisting>

		    <para><emphasis role="bold">Example:</emphasis>
            For each building, find the parcel that best represents it.
            First we require that the parcel intersect with the building geometry.
            <code>DISTINCT ON</code> guarantees we get each building listed only once.
            <code>ORDER BY .. ST_HausdorffDistance</code> selects the parcel that is most similar to the building.</para>

<programlisting>
SELECT DISTINCT ON (buildings.gid) buildings.gid, parcels.parcel_id
   FROM buildings
       INNER JOIN parcels
       ON ST_Intersects(buildings.geom, parcels.geom)
   ORDER BY buildings.gid, ST_HausdorffDistance(buildings.geom, parcels.geom);
</programlisting>

	  </refsection>
          <refsection>
                <title>See Also</title>

                <para><xref linkend="ST_FrechetDistance"/></para>
          </refsection>
	</refentry>

	<refentry xml:id="ST_Length">
		<refnamediv>
		  <refname>ST_Length</refname>

		  <refpurpose>Returns the 2D length of a linear geometry.</refpurpose>
		</refnamediv>
		<refsynopsisdiv>
		  <funcsynopsis>
			<funcprototype>
			  <funcdef>float <function>ST_Length</function></funcdef>
				<paramdef><type>geometry </type><parameter>a_2dlinestring</parameter></paramdef>
			</funcprototype>
			<funcprototype>
			  <funcdef>float <function>ST_Length</function></funcdef>
				<paramdef><type>geography </type><parameter>geog</parameter></paramdef>
				<paramdef choice="opt"><type>boolean </type><parameter>use_spheroid = true</parameter></paramdef>
			</funcprototype>
		  </funcsynopsis>
		</refsynopsisdiv>
		<refsection>
			<title>Description</title>

			<para>For geometry types: returns the 2D Cartesian length of the geometry if it is a LineString, MultiLineString, ST_Curve, ST_MultiCurve.
				For areal geometries 0 is returned; use <xref linkend="ST_Perimeter"/> instead.
				The units of length is determined by the
				spatial reference system of the geometry.</para>
			<para>For geography types: computation is performed using the inverse geodesic calculation. Units of length are in meters.
				If PostGIS is compiled with PROJ version 4.8.0 or later, the spheroid is specified by the SRID, otherwise it is exclusive to WGS84.
				If <varname>use_spheroid = false</varname>, then the calculation is based on a sphere instead of a spheroid.
				</para>

			<para>Currently for geometry this is an alias for ST_Length2D, but this may change to support higher dimensions.</para>

			<warning><para role="changed" conformance="2.0.0">Changed: 2.0.0 Breaking change -- in prior versions applying this to a MULTI/POLYGON of type geography would give you the perimeter of the POLYGON/MULTIPOLYGON.  In 2.0.0
			this was changed to return 0 to be in line with geometry behavior.  Please use ST_Perimeter if you want the perimeter of a polygon</para></warning>

			<note><para>For geography the calculation defaults to using a spheroidal model.  To use the faster but less accurate spherical calculation use ST_Length(gg,false);</para></note>
			<para>&sfs_compliant; s2.1.5.1</para>
			<para>&sqlmm_compliant; SQL-MM 3: 7.1.2, 9.3.4</para>
			<para role="availability" conformance="1.5.0">Availability: 1.5.0 geography support was introduced in 1.5.</para>
		</refsection>

		  <refsection>
			<title>Geometry Examples</title>
			<para>Return length in feet for line string. Note this is in feet because EPSG:2249 is
				Massachusetts State Plane Feet</para>
			<programlisting>
SELECT ST_Length(ST_GeomFromText('LINESTRING(743238 2967416,743238 2967450,743265 2967450,
743265.625 2967416,743238 2967416)',2249));

st_length
---------
 122.630744000095


--Transforming WGS 84 LineString to Massachusetts state plane meters
SELECT ST_Length(
	ST_Transform(
		ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)'),
		26986
	)
);

st_length
---------
34309.4563576191
			</programlisting>
		  </refsection>
		  <refsection>
			<title>Geography Examples</title>
			<para>Return length of WGS 84 geography line</para>
			<programlisting>
-- the default calculation uses a spheroid
SELECT ST_Length(the_geog) As length_spheroid,  ST_Length(the_geog,false) As length_sphere
FROM (SELECT ST_GeographyFromText(
'SRID=4326;LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)') As the_geog)
 As foo;

 length_spheroid  |  length_sphere
------------------+------------------
 34310.5703627288 | 34346.2060960742
			</programlisting>
		  </refsection>
		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_GeographyFromText"/>, <xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_Length_Spheroid"/>, <xref linkend="ST_Perimeter"/>, <xref linkend="ST_Transform"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Length2D">
	  <refnamediv>
		<refname>ST_Length2D</refname>

		<refpurpose>Returns the 2D length of a linear geometry. Alias for <varname>ST_Length</varname></refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_Length2D</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_2dlinestring</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 2D length of the geometry if it is a
				linestring or multi-linestring. This is an alias for <varname>ST_Length</varname></para>

	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Length"/>, <xref linkend="ST_3DLength"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_3DLength">
	  <refnamediv>
		<refname>ST_3DLength</refname>

		<refpurpose>Returns the 3D length of a linear geometry.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_3DLength</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_3dlinestring</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 3-dimensional or 2-dimensional length of the geometry if it is a
			LineString or MultiLineString. For 2-d lines it will just return the 2-d length (same as ST_Length and ST_Length2D)</para>
		<para>&Z_support;</para>
        <para>&sqlmm_compliant; SQL-MM IEC 13249-3: 7.1, 10.3</para>
		<para role="changed" conformance="2.0.0">Changed: 2.0.0 In prior versions this used to be called ST_Length3D</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>

		<para>Return length in feet for a 3D cable. Note this is in feet because EPSG:2249 is
				Massachusetts State Plane Feet</para>
		<programlisting>
SELECT ST_3DLength(ST_GeomFromText('LINESTRING(743238 2967416 1,743238 2967450 1,743265 2967450 3,
743265.625 2967416 3,743238 2967416 3)',2249));
ST_3DLength
-----------
122.704716741457
		</programlisting>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Length"/>, <xref linkend="ST_Length2D"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Length_Spheroid">
	  <refnamediv>
		<refname>ST_LengthSpheroid</refname>

        <refpurpose>Returns the 2D or 3D length/perimeter of a lon/lat geometry on a spheroid.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_LengthSpheroid</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_geometry</parameter></paramdef>
			<paramdef><type>spheroid </type> <parameter>a_spheroid</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

      <para>Calculates the length or perimeter of a geometry on an ellipsoid. This
			is useful if the coordinates of the geometry are in
			longitude/latitude and a length is desired without reprojection.
			The spheroid is specified by a text value	as follows:</para>

		<literallayout><![CDATA[
SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>]
]]> </literallayout>
		<para>For example:</para>
		<literallayout>SPHEROID["GRS_1980",6378137,298.257222101]</literallayout>

		<para role="availability" conformance="1.2.2">Availability: 1.2.2</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 In prior versions this was called ST_Length_Spheroid and had the alias ST_3DLength_Spheroid</para>
		<para>&Z_support;</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_LengthSpheroid( geometry_column,
			  'SPHEROID["GRS_1980",6378137,298.257222101]' )
			  FROM geometry_table;

SELECT ST_LengthSpheroid( geom, sph_m ) As tot_len,
ST_LengthSpheroid(ST_GeometryN(geom,1), sph_m) As len_line1,
ST_LengthSpheroid(ST_GeometryN(geom,2), sph_m) As len_line2
			  FROM (SELECT ST_GeomFromText('MULTILINESTRING((-118.584 38.374,-118.583 38.5),
	(-71.05957 42.3589 , -71.061 43))') As geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo;
	tot_len      |    len_line1     |    len_line2
------------------+------------------+------------------
 85204.5207562955 | 13986.8725229309 | 71217.6482333646

 --3D
SELECT ST_LengthSpheroid( geom, sph_m ) As tot_len,
ST_LengthSpheroid(ST_GeometryN(geom,1), sph_m) As len_line1,
ST_LengthSpheroid(ST_GeometryN(geom,2), sph_m) As len_line2
			  FROM (SELECT ST_GeomFromEWKT('MULTILINESTRING((-118.584 38.374 20,-118.583 38.5 30),
	(-71.05957 42.3589 75, -71.061 43 90))') As geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo;

	 tot_len      |    len_line1    |    len_line2
------------------+-----------------+------------------
 85204.5259107402 | 13986.876097711 | 71217.6498130292

</programlisting>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_GeometryN"/>, <xref linkend="ST_Length"/></para>
	  </refsection>
	</refentry>


<refentry xml:id="ST_LongestLine">
	  <refnamediv>
		<refname>ST_LongestLine</refname>

		<refpurpose>Returns the 2D longest line between two geometries.
		</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_LongestLine</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 2-dimensional longest line between the points of two geometries.
        The line returned starts on <varname>g1</varname> and ends on <varname>g2</varname>.
		</para>
		<para>The longest line always occurs between two vertices.
        The function returns the first longest line if more than one is found.
		The length of the line is equal to the distance returned by <xref linkend="ST_MaxDistance"/>.
		</para>
        <para>
        If g1 and g2 are the same geometry, returns the line between the two vertices farthest apart in the geometry.
        The endpoints of the line lie on the circle computed by <xref linkend="ST_MinimumBoundingCircle"/>.
        </para>
		<para role="availability" conformance="1.5.0">Availability: 1.5.0</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>
        <para><informalfigure>
            <mediaobject>
                <imageobject>
                <imagedata fileref="images/st_longestline01.png"/>
                </imageobject>
                <caption><para>Longest line between a point and a line</para></caption>
            </mediaobject>
            </informalfigure>
<programlisting>
SELECT ST_AsText( ST_LongestLine(
        'POINT (160 40)',
        'LINESTRING (10 30, 50 50, 30 110, 70 90, 180 140, 130 190)' )
	) AS lline;
-----------------
LINESTRING(160 40,130 190)
</programlisting>
	</para>

    <para>
        <informalfigure>
        <mediaobject>
            <imageobject>
            <imagedata fileref="images/st_longestline02.png"/>
            </imageobject>
            <caption><para>Longest line between two polygons</para></caption>
        </mediaobject>
        </informalfigure>
<programlisting>
SELECT ST_AsText( ST_LongestLine(
        'POLYGON ((190 150, 20 10, 160 70, 190 150))',
        ST_Buffer('POINT(80 160)', 30)
            ) ) AS llinewkt;
-----------------
LINESTRING(20 10,105.3073372946034 186.95518130045156)
</programlisting>
	</para>

    <para><informalfigure>
        <mediaobject>
            <imageobject>
            <imagedata fileref="images/st_longestline03.png"/>
            </imageobject>
            <caption><para>Longest line across a single geometry.
            The length of the line is equal to the Maximum Distance.
            The endpoints of the line lie on the Minimum Bounding Circle.</para></caption>
        </mediaobject>
        </informalfigure>
<programlisting>
SELECT ST_AsText( ST_LongestLine( geom, geom)) AS llinewkt,
                  ST_MaxDistance( geom, geom) AS max_dist,
                  ST_Length( ST_LongestLine(geom, geom)) AS lenll
FROM (SELECT 'POLYGON ((40 180, 110 160, 180 180, 180 120, 140 90, 160 40, 80 10, 70 40, 20 50, 40 180),
              (60 140, 99 77.5, 90 140, 60 140))'::geometry AS geom) AS t;

         llinewkt          |      max_dist      |       lenll
---------------------------+--------------------+--------------------
 LINESTRING(20 50,180 180) | 206.15528128088303 | 206.15528128088303
</programlisting>
	</para>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_MaxDistance"/>, <xref linkend="ST_ShortestLine"/>,
        <xref linkend="ST_3DLongestLine"/>, <xref linkend="ST_MinimumBoundingCircle"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_3DLongestLine">
	  <refnamediv>
		<refname>ST_3DLongestLine</refname>

		<refpurpose>Returns the 3D longest line between two geometries</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_3DLongestLine</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 3-dimensional longest line between two geometries.
        The function returns the first longest line if more than one.
		The line returned starts in g1 and ends in g2.
		The 3D length of the line is equal to the distance returned by <xref linkend="ST_3DMaxDistance"/>.
		</para>

		<para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
		<para>&Z_support;</para>
		<!-- Optionally mention supports Polyhedral Surface  -->
		<para>&P_support;</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>
				<informaltable>
					  <tgroup cols="1">
						<tbody>
						  <row>
							<entry><para>linestring and point -- both 3d and 2d longest line
					<programlisting>
SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
		ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
	FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
		) As foo;


           lol3d_line_pt           |       lol2d_line_pt
-----------------------------------+----------------------------
 LINESTRING(50 75 1000,100 100 30) | LINESTRING(98 190,100 100)
					</programlisting>
							  </para></entry>
						    </row>
						    <row>
							<entry><para>linestring and multipoint -- both 3d and 2d longest line
					<programlisting>SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
		ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
	FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
		) As foo;


          lol3d_line_pt          |      lol2d_line_pt
---------------------------------+--------------------------
 LINESTRING(98 190 1,50 74 1000) | LINESTRING(98 190,50 74)
					</programlisting>
							  </para></entry>
						  </row>
						  <row>
						  <entry><para>MultiLineString and Polygon both 3d and 2d longest line
					<programlisting>SELECT ST_AsEWKT(ST_3DLongestLine(poly, mline)) As lol3d,
    ST_AsEWKT(ST_LongestLine(poly, mline)) As lol2d
        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
                (1 10 2, 5 20 1))') As mline ) As foo;
            lol3d             |          lol2d
------------------------------+--------------------------
 LINESTRING(175 150 5,1 10 2) | LINESTRING(175 150,1 10)
             </programlisting>
							  </para></entry>
						  </row>
			</tbody>
		</tgroup>
	</informaltable>

	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_3DShortestLine"/>, <xref linkend="ST_3DMaxDistance"/></para>
	  </refsection>
	</refentry>

<refentry xml:id="ST_MaxDistance">
  <refnamediv>
    <refname>ST_MaxDistance</refname>

    <refpurpose>Returns the 2D largest distance between two geometries in
		projected units.</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcprototype>
        <funcdef>float <function>ST_MaxDistance</function></funcdef>
        <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
        <paramdef><type>geometry </type> <parameter>g2</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>

  <refsection>
    <title>Description</title>

    <!-- optionally mention that this function uses indexes if appropriate -->
    <para>Returns the 2-dimensional maximum distance between two geometries, in  projected units.
    The maximum distance always occurs between two vertices.
    This is the length of the line returned by <xref linkend="ST_LongestLine"/>.
    </para>
    <para>If g1 and g2 are the same geometry, returns the distance between
    the two vertices farthest apart in that geometry.
    </para>

	<para role="availability" conformance="1.5.0">Availability: 1.5.0</para>
  </refsection>
  <refsection>
    <title>Examples</title>

     <para>Maximum distance between a point and lines.</para>
		<programlisting>SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
-----------------
 2

SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 2, 2 2 )'::geometry);
------------------
 2.82842712474619
</programlisting>

     <para>Maximum distance between vertices of a single geometry.</para>
<programlisting>
SELECT ST_MaxDistance('POLYGON ((10 10, 10 0, 0 0, 10 10))'::geometry,
                      'POLYGON ((10 10, 10 0, 0 0, 10 10))'::geometry);
------------------
 14.142135623730951
</programlisting>
  </refsection>

  <!-- Optionally add a "See Also" section -->
  <refsection>
    <title>See Also</title>
<para><xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_DFullyWithin"/></para>
  </refsection>
</refentry>

	<refentry xml:id="ST_3DMaxDistance">
	  <refnamediv>
		<refname>ST_3DMaxDistance</refname>

		<refpurpose>Returns the 3D cartesian maximum distance (based on spatial ref) between two geometries in
		projected units.  </refpurpose>
	  </refnamediv>
	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_3DMaxDistance</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 3-dimensional maximum cartesian distance between two geometries in
		projected units (spatial ref units). </para>

        <para>&Z_support;</para>
        <!-- Optionally mention supports Polyhedral Surface  -->
        <para>&P_support;</para>

		<para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 - In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>
-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
-- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
SELECT ST_3DMaxDistance(
			ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
			ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
		) As dist_3d,
		ST_MaxDistance(
			ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
			ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
		) As dist_2d;

     dist_3d      |     dist_2d
------------------+------------------
 24383.7467488441 | 22247.8472107251
</programlisting>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Distance"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_3DMaxDistance"/>, <xref linkend="ST_Transform"/></para>
	  </refsection>
	</refentry>

<refentry xml:id="ST_MinimumClearance">
		<refnamediv>
			<refname>ST_MinimumClearance</refname>
			<refpurpose>Returns the minimum clearance of a geometry, a measure of a geometry's robustness.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>float <function>ST_MinimumClearance</function></funcdef>
					<paramdef><type>geometry </type><parameter>g</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>
		It is possible for a geometry to meet the criteria for validity according to <xref linkend="ST_IsValid"/> (polygons)
		or <xref linkend="ST_IsSimple"/> (lines),
        but to become invalid if one of its vertices is moved by a small distance.
        This can happen due to loss of precision during conversion to text formats (such as WKT, KML, GML, GeoJSON),
        or binary formats that do not use double-precision floating point coordinates (e.g. MapInfo TAB).
		</para>

		<para>
		The minimum clearance is a quantitative measure of a geometry's robustness to change in coordinate precision.
        It is the largest distance by which vertices of the geometry can be moved without creating an invalid geometry.
        Larger values of minimum clearance indicate greater robustness.
		</para>

		<para>
        If a geometry has a minimum clearance of <varname>e</varname>, then:
        <itemizedlist>
            <listitem>
                <para>
                    No two distinct vertices in the geometry are closer than the distance <varname>e</varname>.
                </para>
            </listitem>
            <listitem>
                <para>
                    No vertex is closer than <varname>e</varname> to a line segment of which it is not an endpoint.
                </para>
            </listitem>
        </itemizedlist>
		</para>

		<para>
		If no minimum clearance exists for a geometry (e.g. a single point, or a MultiPoint whose points are identical),
        the return value is <varname>Infinity</varname>.
		</para>

		<para>
        To avoid validity issues caused by precision loss,
		<xref linkend="ST_ReducePrecision"/> can reduce coordinate precision
        while ensuring that polygonal geometry remains valid.
		</para>

		<para role="availability" conformance="2.3.0">Availability: 2.3.0</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>
		<programlisting>
SELECT ST_MinimumClearance('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))');
 st_minimumclearance
---------------------
             0.00032
     </programlisting>

	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para>
			<xref linkend="ST_MinimumClearanceLine"/>,
            <xref linkend="ST_IsSimple"/>,
            <xref linkend="ST_IsValid"/>,
            <xref linkend="ST_ReducePrecision"/>
		</para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_MinimumClearanceLine">
		<refnamediv>
			<refname>ST_MinimumClearanceLine</refname>
			<refpurpose>Returns the two-point LineString spanning a geometry's minimum clearance.</refpurpose>
		</refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>Geometry <function>ST_MinimumClearanceLine</function></funcdef>
			    <paramdef><type>geometry </type>
			    <parameter>g</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>
		Returns the two-point LineString spanning a geometry's minimum clearance.
        If the geometry does not have a minimum
		clearance, <varname>LINESTRING EMPTY</varname> is returned.
		</para>
		<para>Performed by the GEOS module.</para>
		<para role="availability" conformance="2.3.0">Availability: 2.3.0 - requires GEOS &gt;= 3.6.0</para>
	  </refsection>

	  <refsection>
		  <title>Examples</title>
		  <programlisting>
SELECT ST_AsText(ST_MinimumClearanceLine('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))'));
-------------------------------
LINESTRING(0.5 0.00032,0.5 0)
		  </programlisting>
	  </refsection>

	  <refsection>
		<title>See Also</title>
		<para><xref linkend="ST_MinimumClearance"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Perimeter">
		<refnamediv>
		  <refname>ST_Perimeter</refname>

		  <refpurpose>Returns the length of the boundary of a polygonal geometry or geography.</refpurpose>
		</refnamediv>
		<refsynopsisdiv>
		  <funcsynopsis>
			<funcprototype>
			  <funcdef>float <function>ST_Perimeter</function></funcdef>
				<paramdef><type>geometry </type><parameter>g1</parameter></paramdef>
			</funcprototype>

			<funcprototype>
			  <funcdef>float <function>ST_Perimeter</function></funcdef>
				<paramdef><type>geography </type><parameter>geog</parameter></paramdef>
				<paramdef choice="opt"><type>boolean </type><parameter>use_spheroid = true</parameter></paramdef>
			</funcprototype>
		  </funcsynopsis>
		</refsynopsisdiv>
		<refsection>
			<title>Description</title>

			<para>Returns the 2D perimeter of the geometry/geography if it is a ST_Surface, ST_MultiSurface (Polygon, MultiPolygon).  0 is returned for
				non-areal geometries.  For linear geometries use <xref linkend="ST_Length"/>.  For geometry types, units for perimeter measures are specified by the
				spatial reference system of the geometry.</para>
			<para>For geography types, the calculations are performed using the inverse geodesic problem, where perimeter units are in meters.
				If PostGIS is compiled with PROJ version 4.8.0 or later, the spheroid is specified by the SRID, otherwise it is exclusive to WGS84.
				If <varname>use_spheroid = false</varname>, then calculations will approximate a sphere instead of a spheroid.</para>

			<para>Currently this is an alias for ST_Perimeter2D, but this may change to support higher dimensions.</para>

			<para>&sfs_compliant; s2.1.5.1</para>
			<para>&sqlmm_compliant; SQL-MM 3: 8.1.3, 9.5.4</para>
			<para role="availability" conformance="2.0.0">Availability 2.0.0: Support for geography was introduced</para>
		</refsection>

		<refsection>
			<title>Examples: Geometry</title>
			<para>Return perimeter in feet for Polygon and MultiPolygon. Note this is in feet because EPSG:2249 is
				Massachusetts State Plane Feet</para>
			<programlisting>
SELECT ST_Perimeter(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,743265 2967450,
743265.625 2967416,743238 2967416))', 2249));
st_perimeter
---------
 122.630744000095
(1 row)

SELECT ST_Perimeter(ST_GeomFromText('MULTIPOLYGON(((763104.471273676 2949418.44119003,
763104.477769673 2949418.42538203,
763104.189609677 2949418.22343004,763104.471273676 2949418.44119003)),
((763104.471273676 2949418.44119003,763095.804579742 2949436.33850239,
763086.132105649 2949451.46730207,763078.452329651 2949462.11549407,
763075.354136904 2949466.17407812,763064.362142565 2949477.64291974,
763059.953961626 2949481.28983009,762994.637609571 2949532.04103014,
762990.568508415 2949535.06640477,762986.710889563 2949539.61421415,
763117.237897679 2949709.50493431,763235.236617789 2949617.95619822,
763287.718121842 2949562.20592617,763111.553321674 2949423.91664605,
763104.471273676 2949418.44119003)))', 2249));
st_perimeter
---------
 845.227713366825
(1 row)
			</programlisting>
		  </refsection>
		  <refsection>
			<title>Examples: Geography</title>
			<para>Return perimeter in meters and feet for Polygon and MultiPolygon. Note this is geography (WGS 84 long lat)</para>
			<programlisting>
SELECT  ST_Perimeter(geog) As per_meters, ST_Perimeter(geog)/0.3048 As per_ft
FROM ST_GeogFromText('POLYGON((-71.1776848522251 42.3902896512902,-71.1776843766326 42.3903829478009,
-71.1775844305465 42.3903826677917,-71.1775825927231 42.3902893647987,-71.1776848522251 42.3902896512902))') As geog;

   per_meters    |      per_ft
-----------------+------------------
37.3790462565251 | 122.634666195949


-- MultiPolygon example --
SELECT  ST_Perimeter(geog) As per_meters, ST_Perimeter(geog,false) As per_sphere_meters,  ST_Perimeter(geog)/0.3048 As per_ft
FROM ST_GeogFromText('MULTIPOLYGON(((-71.1044543107478 42.340674480411,-71.1044542869917 42.3406744369506,
-71.1044553562977 42.340673886454,-71.1044543107478 42.340674480411)),
((-71.1044543107478 42.340674480411,-71.1044860600303 42.3407237015564,-71.1045215770124 42.3407653385914,
-71.1045498002983 42.3407946553165,-71.1045611902745 42.3408058316308,-71.1046016507427 42.340837442371,
-71.104617893173 42.3408475056957,-71.1048586153981 42.3409875993595,-71.1048736143677 42.3409959528211,
-71.1048878050242 42.3410084812078,-71.1044020965803 42.3414730072048,
-71.1039672113619 42.3412202916693,-71.1037740497748 42.3410666421308,
-71.1044280218456 42.3406894151355,-71.1044543107478 42.340674480411)))') As geog;

    per_meters    | per_sphere_meters |      per_ft
------------------+-------------------+------------------
 257.634283683311 |  257.412311446337 | 845.256836231335
			</programlisting>
		  </refsection>
		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_GeogFromText"/>, <xref linkend="ST_GeomFromText"/>, <xref linkend="ST_Length"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Perimeter2D">
	  <refnamediv>
		<refname>ST_Perimeter2D</refname>

		<refpurpose>Returns the 2D perimeter of a polygonal geometry.
		Alias for <varname>ST_Perimeter</varname>.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_Perimeter2D</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 2-dimensional perimeter of a polygonal geometry. </para>

		<!-- optionally mention that this function uses indexes if appropriate -->
		<note>
		  <para> This is currently an alias for ST_Perimeter. In future versions ST_Perimeter may return the highest dimension perimeter for a geometry.  This is still under consideration</para>
		</note>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Perimeter"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_3DPerimeter">
	  <refnamediv>
		<refname>ST_3DPerimeter</refname>

		<refpurpose>Returns the 3D perimeter of a polygonal geometry.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_3DPerimeter</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 3-dimensional perimeter of the geometry, if it
			is a polygon or multi-polygon. If the geometry is 2-dimensional, then the 2-dimensional perimeter is returned.  </para>
		<para>&Z_support;</para>
        <para>&sqlmm_compliant; SQL-MM ISO/IEC 13249-3: 8.1, 10.5</para>
		<para role="changed" conformance="2.0.0">Changed: 2.0.0 In prior versions this used to be called ST_Perimeter3D</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>
		<para>Perimeter of a slightly elevated polygon in the air in Massachusetts state plane feet</para>
		<programlisting>SELECT ST_3DPerimeter(geom), ST_Perimeter2d(geom), ST_Perimeter(geom) FROM
			(SELECT ST_GeomFromEWKT('SRID=2249;POLYGON((743238 2967416 2,743238 2967450 1,
743265.625 2967416 1,743238 2967416 2))') As geom) As foo;

  ST_3DPerimeter  |  st_perimeter2d  |   st_perimeter
------------------+------------------+------------------
 105.465793597674 | 105.432997272188 | 105.432997272188

</programlisting>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_Perimeter"/>, <xref linkend="ST_Perimeter2D"/></para>
	  </refsection>
	</refentry>

<refentry xml:id="ST_ShortestLine">
	  <refnamediv>
		<refname>ST_ShortestLine</refname>

		<refpurpose>Returns the 2D shortest line between two geometries</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_ShortestLine</function></funcdef>
			<paramdef><type>geometry </type>
			<parameter>geom1</parameter></paramdef>
			<paramdef><type>geometry </type>
			<parameter>geom2</parameter></paramdef>
		  </funcprototype>

          <funcprototype>
            <funcdef>geography <function>ST_ShortestLine</function></funcdef>
            <paramdef><type>geography </type>
            <parameter>geom1</parameter></paramdef>
            <paramdef><type>geography </type>
            <parameter>geom2</parameter></paramdef>
            <paramdef choice="opt"><type>boolean </type><parameter>use_spheroid = true</parameter></paramdef>
          </funcprototype>

		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 2-dimensional shortest line between two geometries.
		The line returned starts in <varname>geom1</varname> and ends in <varname>geom2</varname>.
		If <varname>geom1</varname> and <varname>geom2</varname> intersect
        the result is a line with start and end at an intersection point.
		The length of the line is the same as <xref linkend="ST_Distance"/> returns for g1 and g2.
		</para>

        <para role="enhanced" conformance="3.4.0">Enhanced: 3.4.0 - support for geography.</para>
		<para role="availability" conformance="1.5.0">Availability: 1.5.0</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>
        <para><informalfigure>
            <mediaobject>
                <imageobject>
                <imagedata fileref="images/st_shortestline01.png"/>
                </imageobject>
                <caption><para>Shortest line between Point and LineString</para></caption>
            </mediaobject>
            </informalfigure>
<programlisting>
SELECT ST_AsText(  ST_ShortestLine(
        'POINT (160 40)',
        'LINESTRING (10 30, 50 50, 30 110, 70 90, 180 140, 130 190)')
	) As sline;
---------------------------------------------------------
 LINESTRING(160 40,125.75342465753425 115.34246575342466)
</programlisting>
		</para>

        <para><informalfigure>
            <mediaobject>
                <imageobject>
                <imagedata fileref="images/st_shortestline02.png"/>
                </imageobject>
                <caption><para>Shortest line between Polygons</para></caption>
            </mediaobject>
            </informalfigure>
<programlisting>
SELECT ST_AsText( ST_ShortestLine(
         'POLYGON ((190 150, 20 10, 160 70, 190 150))',
         ST_Buffer('POINT(80 160)', 30)
              ) ) AS llinewkt;
-----------------
LINESTRING(131.59149149528952 101.89887534906197,101.21320343559644 138.78679656440357)
</programlisting>
		</para>

	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_ClosestPoint"/>, <xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_MaxDistance"/></para>
	  </refsection>
	</refentry>
	<refentry xml:id="ST_3DShortestLine">
	  <refnamediv>
		<refname>ST_3DShortestLine</refname>

		<refpurpose>Returns the 3D shortest line between two geometries</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_3DShortestLine</function></funcdef>

			<paramdef><type>geometry </type>
			<parameter>g1</parameter></paramdef>

			<paramdef><type>geometry </type>
			<parameter>g2</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 3-dimensional shortest line between two geometries. The function will
		only return the first shortest line if more than one, that the function finds.
		If g1 and g2 intersects in just one point the function will return a line with both start
		and end in that intersection-point.
		If g1 and g2 are intersecting with more than one point the function will return a line with start
		and end in the same point but it can be any of the intersecting points.
		The line returned will always start in g1 and end in g2.
		The 3D length of the line this function returns will always be the same as <xref linkend="ST_3DDistance"/> returns for g1 and g2.
		</para>

		<para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
		<para>&Z_support;</para>
		<!-- Optionally mention supports Polyhedral Surface  -->
		<para>&P_support;</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>
				<informaltable>
					  <tgroup cols="1">
						<tbody>
						  <row>
							<entry><para>linestring and point -- both 3d and 2d shortest line
					<programlisting>
SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
		ST_AsEWKT(ST_ShortestLine(line,pt)) As shl2d_line_pt
	FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
		) As foo;


 shl3d_line_pt						                 |               shl2d_line_pt
----------------------------------------------------------------------------+------------------------------------------------------
 LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30)  | LINESTRING(73.0769230769231 115.384615384615,100 100)
					</programlisting>
							  </para></entry>
						    </row>
						    <row>
							<entry><para>linestring and multipoint -- both 3d and 2d shortest line
					<programlisting>SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
		ST_AsEWKT(ST_ShortestLine(line,pt)) As shl2d_line_pt
	FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
		) As foo;


                       shl3d_line_pt                                       | shl2d_line_pt
---------------------------------------------------------------------------+------------------------
 LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30) | LINESTRING(50 75,50 74)
					</programlisting>
							  </para></entry>
						  </row>
						  <row>
						  <entry><para>MultiLineString and polygon both 3d and 2d shortest line
					<programlisting>SELECT ST_AsEWKT(ST_3DShortestLine(poly, mline)) As shl3d,
    ST_AsEWKT(ST_ShortestLine(poly, mline)) As shl2d
        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
                (1 10 2, 5 20 1))') As mline ) As foo;
                   shl3d                                                                           |     shl2d
---------------------------------------------------------------------------------------------------+------------------------
 LINESTRING(39.993580415989 54.1889925532825 5,40.4078575708294 53.6052383805529 5.03423778139177) | LINESTRING(20 40,20 40)
             </programlisting>
							  </para></entry>
						  </row>
			</tbody>
		</tgroup>
	</informaltable>

	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_3DMaxDistance"/></para>
	  </refsection>
	</refentry>



</section>