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
|
<?xml version="1.0" encoding="UTF-8"?>
<sect1 id="Geometry_Outputs">
<title>Geometry Outputs</title>
<refentry id="ST_AsBinary">
<refnamediv>
<refname>ST_AsBinary</refname>
<refpurpose>Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>bytea <function>ST_AsBinary</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>text </type><parameter>NDR_or_XDR</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the Well-Known Binary representation of the geometry. There are 2 variants of the function. The first
variant takes no endian encoding paramater and defaults to little endian. The second variant takes a second argument
denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.</para>
<para>This is useful in binary cursors to pull data out of the
database without converting it to a string representation.</para>
<note>
<para>The WKB spec does not include the SRID. To get the OGC WKB with SRID format use ST_AsEWKB</para>
</note>
<note>
<para>ST_AsBinary is the reverse of <xref linkend="ST_GeomFromWKB" /> for geometry. Use <xref linkend="ST_GeomFromWKB" /> to convert to a postgis geometry from ST_AsBinary representation.</para>
</note>
<para>Availability: 1.5.0 geography support was introduced.</para>
<para>&sfs_compliant; s2.1.1.1</para>
<para>&sqlmm_compliant; SQL-MM 3: 5.1.37</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_asbinary
--------------------------------
\001\003\000\000\000\001\000\000\000\005
\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000
\000\000\000\360?\000\000\000\000\000\000
\360?\000\000\000\000\000\000\360?\000\000
\000\000\000\000\360?\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000
(1 row)</programlisting>
<programlisting>SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR');
st_asbinary
--------------------------------
\000\000\000\000\003\000\000\000\001\000\000\000\005\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\000?\360\000\000\000\000\000\000?\360\000\000\000\000\000\000?\360\000\000
\000\000\000\000?\360\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
(1 row)</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsEWKB" />, <xref linkend="ST_AsEWKT" />, <xref linkend="ST_AsText" />, <xref linkend="ST_GeomFromEWKB" /></para>
</refsection>
</refentry>
<refentry id="ST_AsEWKB">
<refnamediv>
<refname>ST_AsEWKB</refname>
<refpurpose>Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>bytea <function>ST_AsEWKB</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>bytea <function>ST_AsEWKB</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>text </type><parameter>NDR_or_XDR</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the Well-Known Binary representation of the geometry with SRID metadata. There are 2 variants of the function. The first
variant takes no endian encoding paramater and defaults to little endian. The second variant takes a second argument
denoting the encoding - using little-endian ('NDR') or big-endian ('XDR') encoding.</para>
<para>This is useful in binary cursors to pull data out of the
database without converting it to a string representation.</para>
<note>
<para>The WKB spec does not include the SRID. To get the OGC WKB format use ST_AsBinary</para>
</note>
<note>
<para>ST_AsEWKB is the reverse of ST_GeomFromEWKB. Use ST_GeomFromEWKB to convert to a postgis geometry from ST_AsEWKB representation.</para>
</note>
<para>&Z_support;</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_asewkb
--------------------------------
\001\003\000\000 \346\020\000\000\001\000
\000\000\005\000\000\000\000
\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000
\000\000\360?\000\000\000\000\000\000\360?
\000\000\000\000\000\000\360?\000\000\000\000\000
\000\360?\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000
(1 row)</programlisting>
<programlisting>
SELECT ST_AsEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326), 'XDR');
st_asewkb
--------------------------------
\000 \000\000\003\000\000\020\346\000\000\000\001\000\000\000\005\000\000\000\000\
000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000?
\360\000\000\000\000\000\000?\360\000\000\000\000\000\000?\360\000\000\000\000
\000\000?\360\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\000\000\000\000\000\000\000\000\000
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsBinary" />, <xref linkend="ST_AsEWKT" />, <xref linkend="ST_AsText" />, <xref linkend="ST_GeomFromEWKT" />, <xref linkend="ST_SRID" /></para>
</refsection>
</refentry>
<refentry id="ST_AsEWKT">
<refnamediv>
<refname>ST_AsEWKT</refname>
<refpurpose>Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_AsEWKT</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the Well-Known Text representation of the geometry prefixed with the SRID.</para>
<note>
<para>The WKT spec does not include the SRID. To get the OGC WKT format use ST_AsText</para>
</note>
<para><inlinegraphic fileref="images/warning.png" />
WKT format does not maintain precision so to prevent floating truncation, use ST_AsBinary or ST_AsEWKB format for transport.
</para>
<note>
<para>ST_AsEWKT is the reverse of <xref linkend="ST_GeomFromEWKT" />. Use <xref linkend="ST_GeomFromEWKT" /> to convert to a postgis geometry from ST_AsEWKT representation.</para>
</note>
<para>&Z_support;</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsEWKT('0103000020E61000000100000005000000000000
000000000000000000000000000000000000000000000000000000
F03F000000000000F03F000000000000F03F000000000000F03
F000000000000000000000000000000000000000000000000'::geometry);
st_asewkt
--------------------------------
SRID=4326;POLYGON((0 0,0 1,1 1,1 0,0 0))
(1 row)
SELECT ST_AsEWKT('0108000080030000000000000060E30A4100000000785C0241000000000000F03F0000000018
E20A4100000000485F024100000000000000400000000018
E20A4100000000305C02410000000000000840')
--st_asewkt---
CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsBinary" /><xref linkend="ST_AsEWKB" /><xref linkend="ST_AsText" />, <xref linkend="ST_GeomFromEWKT" /></para>
</refsection>
</refentry>
<refentry id="ST_AsGeoJSON">
<refnamediv>
<refname>ST_AsGeoJSON</refname>
<refpurpose>Return the geometry as a GeoJSON element.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
<paramdef><type>integer </type> <parameter>options</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
<paramdef><type>integer </type> <parameter>options</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
<paramdef><type>integer </type> <parameter>options</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGeoJSON</function></funcdef>
<paramdef><type>integer </type> <parameter>gj_version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>max_decimal_digits</parameter></paramdef>
<paramdef><type>integer </type> <parameter>options</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return the geometry as a Geometry Javascript Object Notation (GeoJSON) element. (Cf <ulink
url="http://geojson.org/geojson-spec.html">GeoJSON
specifications 1.0</ulink>). 2D and 3D Geometries are both
supported. GeoJSON only support SFS 1.1 geometry type (no curve
support for example).</para>
<para>The gj_version parameter is the major version of the GeoJSON spec. If specified, must be 1.</para>
<para>The third argument may be used to reduce the maximum number
of decimal places used in output (defaults to 15).</para>
<para>The last 'options' argument could be used to add Bbox or Crs
in GeoJSON output:
<itemizedlist>
<listitem>
<para>0: means no option (default value)</para>
</listitem>
<listitem>
<para>1: GeoJSON Bbox</para>
</listitem>
<listitem>
<para>2: GeoJSON Short CRS (e.g EPSG:4326)</para>
</listitem>
<listitem>
<para>4: GeoJSON Long CRS (e.g urn:ogc:def:crs:EPSG::4326)</para>
</listitem>
</itemizedlist>
</para>
<para>Version 1: ST_AsGeoJSON(geom) / precision=15 version=1 options=0</para>
<para>Version 2: ST_AsGeoJSON(geom, precision) / version=1 options=0</para>
<para>Version 3: ST_AsGeoJSON(geom, precision, options) / version=1</para>
<para>Version 4: ST_AsGeoJSON(version, geom) / precision=15 options=0</para>
<para>Version 5: ST_AsGeoJSON(version, geom, precision) /options=0</para>
<para>Version 6: ST_AsGeoJSON(version, geom, precision,options)</para>
<para>Availability: 1.3.4</para>
<para>Availability: 1.5.0 geography support was introduced.</para>
<para>&Z_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<para>GeoJSON format is generally more efficient than other formats for use in ajax mapping.
One popular javascript client that supports this is Open Layers.
Example of its use is <ulink
url="http://openlayers.org/dev/examples/vector-formats.html">OpenLayers GeoJSON Example</ulink>
</para>
<programlisting>SELECT ST_AsGeoJSON(the_geom) from fe_edges limit 1;
st_asgeojson
-----------------------------------------------------------------------------------------------------------
{"type":"MultiLineString","coordinates":[[[-89.734634999999997,31.492072000000000],
[-89.734955999999997,31.492237999999997]]]}
(1 row)
--3d point
SELECT ST_AsGeoJSON('LINESTRING(1 2 3, 4 5 6)');
st_asgeojson
-----------------------------------------------------------------------------------------
{"type":"LineString","coordinates":[[1,2,3],[4,5,6]]}
</programlisting>
</refsection>
</refentry>
<refentry id="ST_AsGML">
<refnamediv>
<refname>ST_AsGML</refname>
<refpurpose>Return the geometry as a GML version 2 or 3 element.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
<paramdef><type>integer </type> <parameter>options</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsGML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
<paramdef><type>integer </type> <parameter>options</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return the geometry as a Geography Markup Language (GML) element. The version parameter,
if specified, may be either 2 or 3. If no version parameter is
specified then the default is assumed to be 2. The third argument
may be used to reduce the maximum number of decimal places
used in output (defaults to 15).</para>
<para>GML 2 refer to 2.1.2 version, GML 3 to 3.1.1 version</para>
<para>The last 'options' argument is a bitfield. It could be used to define CRS output type
in GML output, and to declare data as lat/lon:
<itemizedlist>
<listitem>
<para>0: GML Short CRS (e.g EPSG:4326), default value</para>
</listitem>
<listitem>
<para>1: GML Long CRS (e.g urn:ogc:def:crs:EPSG::4326)</para>
</listitem>
<listitem>
<para>16: Declare that datas are lat/lon (e.g srid=4326). Default is to assume that data are planars. This option is usefull for GML 3.1.1 output only, related to axis order.</para>
</listitem>
</itemizedlist>
</para>
<!-- TODO: Itemize defaults for each function -->
<note>
<para>Availability: 1.3.2</para>
<para>Availability: 1.5.0 geography support was introduced.</para>
</note>
<para>&Z_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting><![CDATA[SELECT ST_AsGML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_asgml
--------
<gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,0 0,1 1,1 1,0 0,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>]]>
</programlisting>
<programlisting><![CDATA[SELECT ST_AsGML(3, ST_GeomFromText('POINT(5.234234233242 6.34534534534)',4326), 5, 17);
st_asgml
--------
<gml:Point srsName="urn:ogc:def:crs:EPSG::4326"><gml:pos>6.34535 5.23423</gml:pos></gml:Point>]]>
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_GeomFromGML" /></para>
</refsection>
</refentry>
<refentry id="ST_AsHEXEWKB">
<refnamediv>
<refname>ST_AsHEXEWKB</refname>
<refpurpose>Returns a Geometry in HEXEWKB format (as text) using either
little-endian (NDR) or big-endian (XDR) encoding.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_AsHEXEWKB</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>text </type> <parameter>NDRorXDR</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsHEXEWKB</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns a Geometry in HEXEWKB format (as text) using either
little-endian (NDR) or big-endian (XDR) encoding. If no encoding is specified, then NDR is used.</para>
<note>
<para>Availability: 1.2.2</para>
</note>
<para>&Z_support;</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsHEXEWKB(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
which gives same answer as
SELECT ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326)::text;
st_ashexewkb
--------
0103000020E6100000010000000500
00000000000000000000000000000000
00000000000000000000000000000000F03F
000000000000F03F000000000000F03F000000000000F03
F000000000000000000000000000000000000000000000000</programlisting>
</refsection>
</refentry>
<refentry id="ST_AsKML">
<refnamediv>
<refname>ST_AsKML</refname>
<refpurpose>Return the geometry as a KML element. Several variants. Default version=2, default precision=15</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>geom1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>geom1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geometry </type> <parameter>geom1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsKML</function></funcdef>
<paramdef><type>integer </type> <parameter>version</parameter></paramdef>
<paramdef><type>geography </type> <parameter>geom1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return the geometry as a Keyhole Markup Language (KML) element. There are several variants of this function.
maximum number of decimal places used in
output (defaults to 15) and version default to 2.</para>
<para>Version 1: ST_AsKML(geom) / version=2 precision=15</para>
<para>Version 2: ST_AsKML(geom, max_sig_digits) / version=2 </para>
<para>Version 3: ST_AsKML(version, geom) / precision=15 </para>
<para>Version 4: ST_AsKML(version, geom, precision) </para>
<note>
<para>Requires PostGIS be compiled with Proj support. Use <xref linkend="PostGIS_Full_Version" /> to confirm you have proj support compiled in.</para>
</note>
<note>
<para>Availability: 1.2.2 - later variants that include version param came in 1.3.2</para>
</note>
<note>
<para>AsKML output will not work with geometries that do not have an SRID</para>
</note>
<para>&Z_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting><![CDATA[SELECT ST_AsKML(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_askml
--------
<Polygon><outerBoundaryIs><LinearRing><coordinates>0,0 0,1 1,1 1,0 0,0</coordinates></LinearRing></outerBoundaryIs></Polygon>
--3d linestring
SELECT ST_AsKML('SRID=4326;LINESTRING(1 2 3, 4 5 6)');
<LineString><coordinates>1,2,3 4,5,6</coordinates></LineString>
]]>
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsSVG" />, <xref linkend="ST_AsGML" /></para>
</refsection>
</refentry>
<refentry id="ST_AsSVG">
<refnamediv>
<refname>ST_AsSVG</refname>
<refpurpose>Returns a Geometry in SVG path data given a geometry or geography object.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_AsSVG</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsSVG</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsSVG</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>rel</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsSVG</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>rel</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsSVG</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>rel</parameter></paramdef>
<paramdef><type>integer </type> <parameter>maxdecimaldigits</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsSVG</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>rel</parameter></paramdef>
<paramdef><type>integer </type> <parameter>maxdecimaldigits</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return the geometry as Scalar Vector Graphics (SVG) path data. Use 1 as second
argument to have the path data implemented in terms of relative
moves, the default (or 0) uses absolute moves. Third argument may
be used to reduce the maximum number of decimal digits used in
output (defaults to 15). Point geometries will be rendered as
cx/cy when 'rel' arg is 0, x/y when 'rel' is 1. Multipoint
geometries are delimited by commas (","), GeometryCollection
geometries are delimited by semicolons (";").</para>
<note>
<para>Availability: 1.2.2 . Availability: 1.4.0 Changed in PostGIS 1.4.0 to include L command in absolute path to conform to <ulink
url="http://www.w3.org/TR/SVG/paths.html#PathDataBNF">http://www.w3.org/TR/SVG/paths.html#PathDataBNF</ulink></para>
</note>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsSVG(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))',4326));
st_assvg
--------
M 0 0 L 0 -1 1 -1 1 0 Z</programlisting>
</refsection>
</refentry>
<refentry id="ST_GeoHash">
<refnamediv>
<refname>ST_GeoHash</refname>
<refpurpose>Return a GeoHash representation (geohash.org) of the geometry.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_GeoHash</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_GeoHash</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>integer </type> <parameter>precision</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return a GeoHash representation (geohash.org) of the geometry. A GeoHash encodes a point into a text form that is sortable and searchable based on prefixing. A shorter GeoHash is a less precise representation of a point. It can also be thought of as a box, that contains the actual point.</para>
<para>The one-parameter variant of ST_GeoHash returns a GeoHash based on the input geometry type. Points return a GeoHash with 20 characters of precision (about enough to hold the full double precision of the input). Other types return a GeoHash with a variable amount of precision, based on the size of the feature. Larger features are represented with less precision, smaller features with more precision. The idea is that the box implied by the GeoHash will always contain the input feature.</para>
<para>The two-parameter variant of ST_GeoHash returns a GeoHash with a requested precision. For non-points, the starting point of the calculation is the center of the bounding box of the geometry.</para>
<para>Availability: 1.4.0</para>
<note>
<para>ST_GeoHash will not work with geometries that are not in geographic (lon/lat) coordinates.</para>
</note>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting><![CDATA[SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326));
st_geohash
----------------------
c0w3hf1s70w3hf1s70w3
SELECT ST_GeoHash(ST_SetSRID(ST_MakePoint(-126,48),4326),5);
st_geohash
------------
c0w3h
]]>
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para></para>
</refsection>
</refentry>
<refentry id="ST_AsText">
<refnamediv>
<refname>ST_AsText</refname>
<refpurpose>Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>ST_AsText</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>text <function>ST_AsText</function></funcdef>
<paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the Well-Known Text representation of the geometry/geography.</para>
<note>
<para>The WKT spec does not include the SRID. To get the SRID as part of the data, use the non-standard
PostGIS <xref linkend="ST_AsEWKT" /></para>
</note>
<para><inlinegraphic fileref="images/warning.png" />
WKT format does not maintain precision so to prevent floating truncation, use ST_AsBinary or ST_AsEWKB format for transport.
</para>
<note>
<para>ST_AsText is the reverse of <xref linkend="ST_GeomFromText" />. Use <xref linkend="ST_GeomFromText" /> to convert to a postgis geometry from ST_AsText representation.</para>
</note>
<para>Availability: 1.5 - support for geography was introduced.</para>
<para>&sfs_compliant; s2.1.1.1</para>
<para>&sqlmm_compliant; SQL-MM 3: 5.1.25</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsText('01030000000100000005000000000000000000
000000000000000000000000000000000000000000000000
F03F000000000000F03F000000000000F03F000000000000F03
F000000000000000000000000000000000000000000000000');
st_astext
--------------------------------
POLYGON((0 0,0 1,1 1,1 0,0 0))
(1 row)</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsBinary" />, <xref linkend="ST_AsEWKB" />, <xref linkend="ST_AsEWKT" />, <xref linkend="ST_GeomFromText" /></para>
</refsection>
</refentry>
</sect1>
|