forked from postgis/postgis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreference_constructor.xml
2464 lines (2019 loc) · 85.4 KB
/
reference_constructor.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<sect1 id="Geometry_Constructors">
<title>Geometry Constructors</title>
<refentry id="ST_BdPolyFromText">
<refnamediv>
<refname>ST_BdPolyFromText</refname>
<refpurpose>Construct a Polygon given an arbitrary collection of closed
linestrings as a MultiLineString Well-Known text representation.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_BdPolyFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Construct a Polygon given an arbitrary collection of closed
linestrings as a MultiLineString Well-Known text representation.</para>
<!-- optionally mention that this function uses indexes if appropriate -->
<note>
<para>Throws an error if WKT is not a MULTILINESTRING. Throws an
error if output is a MULTIPOLYGON; use ST_BdMPolyFromText in that case, or
see ST_BuildArea() for a
postgis-specific approach.</para>
</note>
<para>&sfs_compliant; s3.2.6.2</para>
<para>Availability: 1.1.0 - requires GEOS >= 2.1.0.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>Forthcoming</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_BuildArea" />, <xref linkend="ST_BdMPolyFromText" /></para>
</refsection>
</refentry>
<refentry id="ST_BdMPolyFromText">
<refnamediv>
<refname>ST_BdMPolyFromText</refname>
<refpurpose>Construct a MultiPolygon given an arbitrary collection of
closed linestrings as a MultiLineString text
representation Well-Known text representation.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_BdMPolyFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Construct a Polygon given an arbitrary collection of closed
linestrings, polygons, MultiLineStrings as Well-Known text representation.</para>
<!-- optionally mention that this function uses indexes if appropriate -->
<note>
<para>Throws an error if WKT is not a MULTILINESTRING. Forces
MULTIPOLYGON output even when result is really only composed by a
single POLYGON; use <link
linkend="ST_BdPolyFromText">ST_BdPolyFromText</link> if you're sure a
single POLYGON will result from operation, or see <link
linkend="ST_BuildArea">ST_BuildArea()</link> for a postgis-specific
approach.</para>
</note>
<para>&sfs_compliant; s3.2.6.2</para>
<para>Availability: 1.1.0 - requires GEOS >= 2.1.0.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>Forthcoming</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_BuildArea" />, <xref linkend="ST_BdPolyFromText" /></para>
</refsection>
</refentry>
<refentry id="ST_Box2dFromGeoHash">
<refnamediv>
<refname>ST_Box2dFromGeoHash</refname>
<refpurpose>Return a BOX2D from a GeoHash string.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>box2d <function>ST_Box2dFromGeoHash</function></funcdef>
<paramdef><type>text </type> <parameter>geohash</parameter></paramdef>
<paramdef choice="opt"><type>integer </type> <parameter>precision=full_precision_of_geohash</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return a BOX2D from a GeoHash string.</para>
<para>If no <varname>precision</varname> is specficified ST_Box2dFromGeoHash returns a BOX2D based on full precision of the input GeoHash string.</para>
<para>If <varname>precision</varname> is specified ST_Box2dFromGeoHash will use that many characters from the GeoHash to create the BOX2D. Lower precision values results in larger BOX2Ds and larger values increase the precision.</para>
<para>Availability: 2.1.0</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting><![CDATA[SELECT ST_Box2dFromGeoHash('9qqj7nmxncgyy4d0dbxqz0');
st_geomfromgeohash
--------------------------------------------------
BOX(-115.172816 36.114646,-115.172816 36.114646)
SELECT ST_Box2dFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 0);
st_box2dfromgeohash
----------------------
BOX(-180 -90,180 90)
SELECT ST_Box2dFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 10);
st_box2dfromgeohash
---------------------------------------------------------------------------
BOX(-115.17282128334 36.1146408319473,-115.172810554504 36.1146461963654)
]]>
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeoHash" />, <xref linkend="ST_GeomFromGeoHash" />, <xref linkend="ST_PointFromGeoHash" /></para>
</refsection>
</refentry>
<refentry id="ST_GeogFromText">
<refnamediv>
<refname>ST_GeogFromText</refname>
<refpurpose>Return a specified geography value from Well-Known Text representation or extended (WKT). </refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geography <function>ST_GeogFromText</function></funcdef>
<paramdef><type>text </type> <parameter>EWKT</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns a geography object from the well-known text or extended well-known representation. SRID 4326 is assumed if unspecified.
This is an alias for ST_GeographyFromText. Points are always expressed in long lat form.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
--- converting lon lat coords to geography
ALTER TABLE sometable ADD COLUMN geog geography(POINT,4326);
UPDATE sometable SET geog = ST_GeogFromText('SRID=4326;POINT(' || lon || ' ' || lat || ')');
--- specify a geography point using EPSG:4267, NAD27
SELECT ST_AsEWKT(ST_GeogFromText('SRID=4267;POINT(-77.0092 38.889588)'));
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsText" />, <xref linkend="ST_GeographyFromText" /></para>
</refsection>
</refentry>
<refentry id="ST_GeographyFromText">
<refnamediv>
<refname>ST_GeographyFromText</refname>
<refpurpose>Return a specified geography value from Well-Known Text representation or extended (WKT). </refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geography <function>ST_GeographyFromText</function></funcdef>
<paramdef><type>text </type> <parameter>EWKT</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns a geography object from the well-known text representation. SRID 4326 is assumed if unspecified.</para>
<!-- TODO: put in example -->
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeogFromText" />, <xref linkend="ST_AsText" /></para>
</refsection>
</refentry>
<refentry id="ST_GeogFromWKB">
<refnamediv>
<refname>ST_GeogFromWKB</refname>
<refpurpose>Creates a geography instance from a Well-Known Binary geometry
representation (WKB) or extended Well Known Binary (EWKB).</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geography <function>ST_GeogFromWKB</function></funcdef>
<paramdef><type>bytea </type> <parameter>wkb</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>The <varname>ST_GeogFromWKB</varname> function, takes a well-known
binary representation (WKB) of a geometry or PostGIS Extended WKB and creates an instance of the appropriate
geography type. This function plays the role of the Geometry Factory in
SQL. </para>
<para>If SRID is not specified, it defaults to 4326 (WGS 84 long lat).</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>--Although bytea rep contains single \, these need to be escaped when inserting into a table
SELECT ST_AsText(
ST_GeogFromWKB(E'\\001\\002\\000\\000\\000\\002\\000\\000\\000\\037\\205\\353Q\\270~\\\\\\300\\323Mb\\020X\\231C@\\020X9\\264\\310~\\\\\\300)\\\\\\217\\302\\365\\230C@')
);
st_astext
------------------------------------------------------
LINESTRING(-113.98 39.198,-113.981 39.195)
(1 row)
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeogFromText" />, <xref linkend="ST_AsBinary" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromTWKB">
<refnamediv>
<refname>ST_GeomFromTWKB</refname>
<refpurpose>Creates a geometry instance from a TWKB ("<ulink url="https://github.com/TWKB/Specification/blob/master/twkb.md">Tiny Well-Known Binary</ulink>") geometry
representation.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromTWKB</function></funcdef>
<paramdef><type>bytea </type> <parameter>twkb</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>The <varname>ST_GeomFromTWKB</varname> function, takes a a TWKB ("<ulink url="https://github.com/TWKB/Specification/blob/master/twkb.md">Tiny Well-Known Binary</ulink>") geometry representation (WKB) and creates an instance of the appropriate
geometry type.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
SELECT ST_AsText(ST_GeomFromTWKB(ST_AsTWKB('LINESTRING(126 34, 127 35)'::geometry)));
st_astext
-----------------------------
LINESTRING(126 34, 127 35)
(1 row)
SELECT ST_AsEWKT(
ST_GeomFromTWKB(E'\\x620002f7f40dbce4040105')
);
st_asewkt
------------------------------------------------------
LINESTRING(-113.98 39.198,-113.981 39.195)
(1 row)
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsTWKB" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomCollFromText">
<refnamediv>
<refname>ST_GeomCollFromText</refname>
<refpurpose>Makes a collection Geometry from collection WKT with the given SRID. If SRID is
not given, it defaults to 0.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomCollFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_GeomCollFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Makes a collection Geometry from the Well-Known-Text (WKT) representation with the given SRID. If SRID is
not given, it defaults to 0.</para>
<para>OGC SPEC 3.2.6.2 - option SRID is from the conformance suite</para>
<para>Returns null if the WKT is not a GEOMETRYCOLLECTION</para>
<note>
<para>If you are absolutely sure all your WKT geometries are collections, don't use this function.
It is slower than ST_GeomFromText since it adds an additional validation step.
</para>
</note>
<para>&sfs_compliant; s3.2.6.2</para>
<para>&sqlmm_compliant;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(1 2, 3 4))');
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeomFromText" />, <xref linkend="ST_SRID" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromEWKB">
<refnamediv>
<refname>ST_GeomFromEWKB</refname>
<refpurpose>Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromEWKB</function></funcdef>
<paramdef><type>bytea </type> <parameter>EWKB</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Constructs a PostGIS ST_Geometry object from the OGC Extended Well-Known binary (EWKT) representation.</para>
<note>
<para>The EWKB format is not an OGC standard, but a PostGIS specific format that includes the spatial reference system (SRID)
identifier</para>
</note>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces and TIN was introduced.</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<para>line string binary rep 0f
LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932) in NAD 83 long lat (4269).</para>
<note><para>NOTE: Even though byte arrays are delimited with \ and may have ', we need to escape both out with \ and '' if standard_conforming_strings is off. So it does not
look exactly like its AsEWKB representation.</para></note>
<programlisting>SELECT ST_GeomFromEWKB(E'\\001\\002\\000\\000 \\255\\020\\000\\000\\003\\000\\000\\000\\344J=
\\013B\\312Q\\300n\\303(\\010\\036!E@''\\277E''K
\\312Q\\300\\366{b\\235*!E@\\225|\\354.P\\312Q
\\300p\\231\\323e1!E@');</programlisting>
<note><para>In PostgreSQL 9.1+ - standard_conforming_strings is set to on by default, where as in past versions it was set to off. You can change defaults as needed
for a single query or at the database or server level. Below is how you would do it with standard_conforming_strings = on. In this case we escape the ' with standard ansi ',
but slashes are not escaped</para></note>
<programlisting>
set standard_conforming_strings = on;
SELECT ST_GeomFromEWKB('\001\002\000\000 \255\020\000\000\003\000\000\000\344J=\012\013B
\312Q\300n\303(\010\036!E@''\277E''K\012\312Q\300\366{b\235*!E@\225|\354.P\312Q\012\300p\231\323e1')</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsBinary" />, <xref linkend="ST_AsEWKB" />, <xref linkend="ST_GeomFromWKB" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromEWKT">
<refnamediv>
<refname>ST_GeomFromEWKT</refname>
<refpurpose>Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromEWKT</function></funcdef>
<paramdef><type>text </type> <parameter>EWKT</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Constructs a PostGIS ST_Geometry object from the OGC Extended Well-Known text (EWKT) representation.</para>
<note>
<para>The EWKT format is not an OGC standard, but an PostGIS specific format that includes the spatial reference system (SRID)
identifier</para>
</note>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces and TIN was introduced.</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_GeomFromEWKT('SRID=4269;LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)');
SELECT ST_GeomFromEWKT('SRID=4269;MULTILINESTRING((-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932))');
SELECT ST_GeomFromEWKT('SRID=4269;POINT(-71.064544 42.28787)');
SELECT ST_GeomFromEWKT('SRID=4269;POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239,
-71.1776063012595 42.3903825660754,-71.1775826583081 42.3903033653531,-71.1776585052917 42.3902909739571))');
SELECT ST_GeomFromEWKT('SRID=4269;MULTIPOLYGON(((-71.1031880899493 42.3152774590236,
-71.1031627617667 42.3152960829043,-71.102923838298 42.3149156848307,
-71.1023097974109 42.3151969047397,-71.1019285062273 42.3147384934248,
-71.102505233663 42.3144722937587,-71.10277487471 42.3141658254797,
-71.103113945163 42.3142739188902,-71.10324876416 42.31402489987,
-71.1033002961013 42.3140393340215,-71.1033488797549 42.3139495090772,
-71.103396240451 42.3138632439557,-71.1041521907712 42.3141153348029,
-71.1041411411543 42.3141545014533,-71.1041287795912 42.3142114839058,
-71.1041188134329 42.3142693656241,-71.1041112482575 42.3143272556118,
-71.1041072845732 42.3143851580048,-71.1041057218871 42.3144430686681,
-71.1041065602059 42.3145009876017,-71.1041097995362 42.3145589148055,
-71.1041166403905 42.3146168544148,-71.1041258822717 42.3146748022936,
-71.1041375307579 42.3147318674446,-71.1041492906949 42.3147711126569,
-71.1041598612795 42.314808571739,-71.1042515013869 42.3151287620809,
-71.1041173835118 42.3150739481917,-71.1040809891419 42.3151344119048,
-71.1040438678912 42.3151191367447,-71.1040194562988 42.3151832057859,
-71.1038734225584 42.3151140942995,-71.1038446938243 42.3151006300338,
-71.1038315271889 42.315094347535,-71.1037393329282 42.315054824985,
-71.1035447555574 42.3152608696313,-71.1033436658644 42.3151648370544,
-71.1032580383161 42.3152269126061,-71.103223066939 42.3152517403219,
-71.1031880899493 42.3152774590236)),
((-71.1043632495873 42.315113108546,-71.1043583974082 42.3151211109857,
-71.1043443253471 42.3150676015829,-71.1043850704575 42.3150793250568,-71.1043632495873 42.315113108546)))');
</programlisting>
<programlisting>
--3d circular string
SELECT ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)');
</programlisting>
<programlisting>
--Polyhedral Surface example
SELECT ST_GeomFromEWKT('POLYHEDRALSURFACE(
((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),
((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)),
((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1))
)');
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsEWKT" />, <xref linkend="ST_GeomFromText" />, <xref linkend="ST_GeomFromEWKT" /></para>
</refsection>
</refentry>
<refentry id="ST_GeometryFromText">
<refnamediv>
<refname>ST_GeometryFromText</refname>
<refpurpose>Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeometryFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_GeometryFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>&sfs_compliant;</para>
<para>&sqlmm_compliant; SQL-MM 3: 5.1.40</para>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeomFromText" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromGeoHash">
<refnamediv>
<refname>ST_GeomFromGeoHash</refname>
<refpurpose>Return a geometry from a GeoHash string.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromGeoHash</function></funcdef>
<paramdef><type>text </type> <parameter>geohash</parameter></paramdef>
<paramdef choice="opt"><type>integer </type> <parameter>precision=full_precision_of_geohash</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return a geometry from a GeoHash string. The geometry will be a polygon representing the GeoHash bounds.</para>
<para>If no <varname>precision</varname> is specified ST_GeomFromGeoHash returns a polygon based on full precision of the input GeoHash string.</para>
<para>If <varname>precision</varname> is specified ST_GeomFromGeoHash will use that many characters from the GeoHash to create the polygon.</para>
<para>Availability: 2.1.0</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting><![CDATA[SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0'));
st_astext
--------------------------------------------------------------------------------------------------------------------------
POLYGON((-115.172816 36.114646,-115.172816 36.114646,-115.172816 36.114646,-115.172816 36.114646,-115.172816 36.114646))
SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 4));
st_astext
------------------------------------------------------------------------------------------------------------------------------
POLYGON((-115.3125 36.03515625,-115.3125 36.2109375,-114.9609375 36.2109375,-114.9609375 36.03515625,-115.3125 36.03515625))
SELECT ST_AsText(ST_GeomFromGeoHash('9qqj7nmxncgyy4d0dbxqz0', 10));
st_astext
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
POLYGON((-115.17282128334 36.1146408319473,-115.17282128334 36.1146461963654,-115.172810554504 36.1146461963654,-115.172810554504 36.1146408319473,-115.17282128334 36.1146408319473))
]]>
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeoHash" />,<xref linkend="ST_Box2dFromGeoHash" />, <xref linkend="ST_PointFromGeoHash" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromGML">
<refnamediv>
<refname>ST_GeomFromGML</refname>
<refpurpose>Takes as input GML representation of geometry and outputs a PostGIS geometry object</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromGML</function></funcdef>
<paramdef><type>text </type> <parameter>geomgml</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromGML</function></funcdef>
<paramdef><type>text </type> <parameter>geomgml</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Constructs a PostGIS ST_Geometry object from the OGC GML representation.</para>
<para>ST_GeomFromGML works only for GML Geometry fragments. It throws an error if you try to use it on a whole GML document.</para>
<para>
OGC GML versions supported:
<itemizedlist>
<listitem>
<para>GML 3.2.1 Namespace</para>
</listitem>
<listitem>
<para>GML 3.1.1 Simple Features profile SF-2 (with GML 3.1.0 and 3.0.0 backward compatibility)</para>
</listitem>
<listitem>
<para>GML 2.1.2</para>
</listitem>
</itemizedlist>
OGC GML standards, cf: <ulink url="http://www.opengeospatial.org/standards/gml">http://www.opengeospatial.org/standards/gml</ulink>:
</para>
<para>Availability: 1.5, requires libxml2 1.6+</para>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces and TIN was introduced.</para>
<para>Enhanced: 2.0.0 default srid optional parameter added.</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
<para>GML allow mixed dimensions (2D and 3D inside the same MultiGeometry for instance). As PostGIS geometries don't, ST_GeomFromGML convert the whole geometry to 2D if a missing Z dimension is found once.</para>
<para>GML support mixed SRS inside the same MultiGeometry. As PostGIS geometries don't, ST_GeomFromGML, in this case, reproject all subgeometries to the SRS root node. If no srsName attribute available for the GML root node, the function throw an error.</para>
<para>ST_GeomFromGML function is not pedantic about an explicit GML namespace. You could avoid to mention it explicitly for common usages. But you need it if you want to use XLink feature inside GML.</para>
<note>
<para>ST_GeomFromGML function not support SQL/MM curves geometries.</para>
</note>
</refsection>
<refsection>
<title>Examples - A single geometry with srsName</title>
<programlisting>SELECT ST_GeomFromGML('<![CDATA[
<gml:LineString srsName="EPSG:4269">
<gml:coordinates>
-71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932
</gml:coordinates>
</gml:LineString>']]>);
</programlisting>
</refsection>
<refsection>
<title>Examples - XLink usage</title>
<programlisting>SELECT <![CDATA[ST_GeomFromGML('
<gml:LineString xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
srsName="urn:ogc:def:crs:EPSG::4269">
<gml:pointProperty>
<gml:Point gml:id="p1"><gml:pos>42.258729 -71.16028</gml:pos></gml:Point>
</gml:pointProperty>
<gml:pos>42.259112 -71.160837</gml:pos>
<gml:pointProperty>
<gml:Point xlink:type="simple" xlink:href="#p1"/>
</gml:pointProperty>
</gml:LineString>');]]>);
</programlisting>
</refsection>
<refsection>
<title>Examples - Polyhedral Surface</title>
<programlisting>SELECT ST_AsEWKT(<![CDATA[ST_GeomFromGML('
<gml:PolyhedralSurface>
<gml:polygonPatches>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing><gml:posList srsDimension="3">0 0 0 0 0 1 0 1 1 0 1 0 0 0 0</gml:posList></gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing><gml:posList srsDimension="3">0 0 0 0 1 0 1 1 0 1 0 0 0 0 0</gml:posList></gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing><gml:posList srsDimension="3">0 0 0 1 0 0 1 0 1 0 0 1 0 0 0</gml:posList></gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing><gml:posList srsDimension="3">1 1 0 1 1 1 1 0 1 1 0 0 1 1 0</gml:posList></gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing><gml:posList srsDimension="3">0 1 0 0 1 1 1 1 1 1 1 0 0 1 0</gml:posList></gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing><gml:posList srsDimension="3">0 0 1 1 0 1 1 1 1 0 1 1 0 0 1</gml:posList></gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
</gml:polygonPatches>
</gml:PolyhedralSurface>']]>));
-- result --
POLYHEDRALSURFACE(((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),
((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),
((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)))
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="installation_configuration" />, <xref linkend="ST_AsGML" />, <xref linkend="ST_GMLToSQL" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromGeoJSON">
<refnamediv>
<refname>ST_GeomFromGeoJSON</refname>
<refpurpose>Takes as input a geojson representation of a geometry and outputs a PostGIS geometry object</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromGeoJSON</function></funcdef>
<paramdef><type>text </type> <parameter>geomjson</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Constructs a PostGIS geometry object from the GeoJSON representation.</para>
<para>ST_GeomFromGeoJSON works only for JSON Geometry fragments. It throws an error if you try to use it on a whole JSON document.</para>
<para>Availability: 2.0.0 requires - JSON-C >= 0.9</para>
<note><para>If you do not have JSON-C enabled, support you will get an error notice instead of seeing an output.
To enable JSON-C, run configure --with-jsondir=/path/to/json-c. See <xref linkend="installation_configuration" /> for details.</para></note>
<para>&Z_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Point","coordinates":[-48.23456,20.12345]}')) As wkt;
wkt
------
POINT(-48.23456 20.12345)
</programlisting>
<programlisting>-- a 3D linestring
SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"LineString","coordinates":[[1,2,3],[4,5,6],[7,8,9]]}')) As wkt;
wkt
-------------------
LINESTRING(1 2,4 5,7 8)
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsText" />, <xref linkend="ST_AsGeoJSON" />, <xref linkend="installation_configuration" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromKML">
<refnamediv>
<refname>ST_GeomFromKML</refname>
<refpurpose>Takes as input KML representation of geometry and outputs a PostGIS geometry object</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromKML</function></funcdef>
<paramdef><type>text </type> <parameter>geomkml</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Constructs a PostGIS ST_Geometry object from the OGC KML representation.</para>
<para>ST_GeomFromKML works only for KML Geometry fragments. It throws an error if you try to use it on a whole KML document.</para>
<para>
OGC KML versions supported:
<itemizedlist>
<listitem>
<para>KML 2.2.0 Namespace</para>
</listitem>
</itemizedlist>
OGC KML standards, cf: <ulink url="http://www.opengeospatial.org/standards/kml">http://www.opengeospatial.org/standards/kml</ulink>:
</para>
<para>Availability: 1.5,libxml2 2.6+</para>
<para>&Z_support;</para>
<note>
<para>ST_GeomFromKML function not support SQL/MM curves geometries.</para>
</note>
</refsection>
<refsection>
<title>Examples - A single geometry with srsName</title>
<programlisting>SELECT ST_GeomFromKML('<![CDATA[
<LineString>
<coordinates>-71.1663,42.2614
-71.1667,42.2616</coordinates>
</LineString>']]>);
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="installation_configuration" />, <xref linkend="ST_AsKML" /></para>
</refsection>
</refentry>
<refentry id="ST_GMLToSQL">
<refnamediv>
<refname>ST_GMLToSQL</refname>
<refpurpose>Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GMLToSQL</function></funcdef>
<paramdef><type>text </type> <parameter>geomgml</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_GMLToSQL</function></funcdef>
<paramdef><type>text </type> <parameter>geomgml</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>&sqlmm_compliant; SQL-MM 3: 5.1.50 (except for curves support).</para>
<para>Availability: 1.5, requires libxml2 1.6+</para>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces and TIN was introduced.</para>
<para>Enhanced: 2.0.0 default srid optional parameter added.</para>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="installation_configuration" />, <xref linkend="ST_GeomFromGML" />, <xref linkend="ST_AsGML" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromText">
<refnamediv>
<refname>ST_GeomFromText</refname>
<refpurpose>Return a specified ST_Geometry value from Well-Known Text representation (WKT).</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromText</function></funcdef>
<paramdef><type>text </type> <parameter>WKT</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Constructs a PostGIS ST_Geometry object from the OGC Well-Known text representation.</para>
<!-- optionally mention that this function uses indexes if appropriate -->
<note>
<para>There are two variants of ST_GeomFromText function. The first takes no SRID and returns a geometry
with no defined spatial reference system (SRID=0). The second takes a SRID as the second argument
and returns a geometry that includes this SRID as part of its metadata.
</para>
</note>
<para>&sfs_compliant; s3.2.6.2 - option SRID is from the conformance suite.</para>
<para>&sqlmm_compliant; SQL-MM 3: 5.1.40</para>
<para>&curve_support;</para>
<warning><para>Changed: 2.0.0 In prior versions of PostGIS ST_GeomFromText('GEOMETRYCOLLECTION(EMPTY)') was allowed. This is now illegal in PostGIS 2.0.0 to better conform with SQL/MM standards. This should now be
written as ST_GeomFromText('GEOMETRYCOLLECTION EMPTY')</para></warning>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_GeomFromText('LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)');
SELECT ST_GeomFromText('LINESTRING(-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932)',4269);
SELECT ST_GeomFromText('MULTILINESTRING((-71.160281 42.258729,-71.160837 42.259113,-71.161144 42.25932))');
SELECT ST_GeomFromText('POINT(-71.064544 42.28787)');
SELECT ST_GeomFromText('POLYGON((-71.1776585052917 42.3902909739571,-71.1776820268866 42.3903701743239,
-71.1776063012595 42.3903825660754,-71.1775826583081 42.3903033653531,-71.1776585052917 42.3902909739571))');
SELECT ST_GeomFromText('MULTIPOLYGON(((-71.1031880899493 42.3152774590236,
-71.1031627617667 42.3152960829043,-71.102923838298 42.3149156848307,
-71.1023097974109 42.3151969047397,-71.1019285062273 42.3147384934248,
-71.102505233663 42.3144722937587,-71.10277487471 42.3141658254797,
-71.103113945163 42.3142739188902,-71.10324876416 42.31402489987,
-71.1033002961013 42.3140393340215,-71.1033488797549 42.3139495090772,
-71.103396240451 42.3138632439557,-71.1041521907712 42.3141153348029,
-71.1041411411543 42.3141545014533,-71.1041287795912 42.3142114839058,
-71.1041188134329 42.3142693656241,-71.1041112482575 42.3143272556118,
-71.1041072845732 42.3143851580048,-71.1041057218871 42.3144430686681,
-71.1041065602059 42.3145009876017,-71.1041097995362 42.3145589148055,
-71.1041166403905 42.3146168544148,-71.1041258822717 42.3146748022936,
-71.1041375307579 42.3147318674446,-71.1041492906949 42.3147711126569,
-71.1041598612795 42.314808571739,-71.1042515013869 42.3151287620809,
-71.1041173835118 42.3150739481917,-71.1040809891419 42.3151344119048,
-71.1040438678912 42.3151191367447,-71.1040194562988 42.3151832057859,
-71.1038734225584 42.3151140942995,-71.1038446938243 42.3151006300338,
-71.1038315271889 42.315094347535,-71.1037393329282 42.315054824985,
-71.1035447555574 42.3152608696313,-71.1033436658644 42.3151648370544,
-71.1032580383161 42.3152269126061,-71.103223066939 42.3152517403219,
-71.1031880899493 42.3152774590236)),
((-71.1043632495873 42.315113108546,-71.1043583974082 42.3151211109857,
-71.1043443253471 42.3150676015829,-71.1043850704575 42.3150793250568,-71.1043632495873 42.315113108546)))',4326);
SELECT ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)');
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeomFromEWKT" />, <xref linkend="ST_GeomFromWKB" />, <xref linkend="ST_SRID" /></para>
</refsection>
</refentry>
<refentry id="ST_GeomFromWKB">
<refnamediv>
<refname>ST_GeomFromWKB</refname>
<refpurpose>Creates a geometry instance from a Well-Known Binary geometry
representation (WKB) and optional SRID.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromWKB</function></funcdef>
<paramdef><type>bytea </type> <parameter>geom</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_GeomFromWKB</function></funcdef>
<paramdef><type>bytea </type> <parameter>geom</parameter></paramdef>
<paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>The <varname>ST_GeomFromWKB</varname> function, takes a well-known
binary representation of a geometry and a Spatial Reference System ID
(<varname>SRID</varname>) and creates an instance of the appropriate
geometry type. This function plays the role of the Geometry Factory in
SQL. This is an alternate name for ST_WKBToSQL.</para>
<para>If SRID is not specified, it defaults to 0 (Unknown).</para>