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
|
<?xml version="1.0" encoding="UTF-8"?>
<sect1 id="reference_sfcgal">
<sect1info>
<abstract>
<para>
SFCGAL is a C++ wrapper library around CGAL that provides advanced 2D and 3D functions.
For robustness, geometry coordinates have an exact rational number representation.
</para>
<para>
Installation instructions of the library can be found on SFCGAL home page <ulink url="http://www.sfcgal.org">http://www.sfcgal.org</ulink>.
To load the functions create extension postgis_sfcgal.
</para>
<para>
Some SFCGAL functions replace standard ones (ST_Intersects, ST_Intersection, ST_Difference, ST_Union, ST_Area and ST_Distance), to switch between standard functions and SFCGAL function use:
<programlisting>SET postgis.backend = sfcgal;</programlisting>
and
<programlisting>SET postgis.backend = geos;</programlisting>
</para>
</abstract>
</sect1info>
<title>SFCGAL Functions</title>
<refentry id="postgis_sfcgal_version">
<refnamediv>
<refname>postgis_sfcgal_version</refname>
<refpurpose>Returns the version of SFCGAL in use</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>text <function>postgis_sfcgal_version</function></funcdef>
<void/>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
</refentry>
<refentry id="ST_Extrude">
<refnamediv>
<refname>ST_Extrude</refname>
<refpurpose>Extrude a surface to a related volume</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_Extrude</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
<paramdef><type>float</type> <parameter>x</parameter></paramdef>
<paramdef><type>float</type> <parameter>y</parameter></paramdef>
<paramdef><type>float</type> <parameter>z</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection><title>Examples</title>
<para>3D images were generated using PostGIS <xref linkend="ST_AsX3D" /> and rendering in HTML using <ulink url="http://www.x3dom.org">X3Dom HTML Javascript rendering library</ulink>.</para>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><para>
<programlisting>SELECT ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30);</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_extrude01.png" />
</imageobject>
<caption><para>Original octagon formed from buffering point</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para>
<programlisting>ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30);</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_extrude02.png" />
</imageobject>
<caption><para>Hexagon extruded 30 units along Z produces a PolyhedralSurfaceZ</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
<row>
<entry><para>
<programlisting>SELECT ST_GeomFromText('LINESTRING(50 50, 100 90, 95 150)')</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_extrude03.png" />
</imageobject>
<caption><para>Original linestring</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para>
<programlisting>SELECT ST_Extrude(
ST_GeomFromText('LINESTRING(50 50, 100 90, 95 150)'),0,0,10));</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_extrude04.png" />
</imageobject>
<caption><para>LineString Extruded along Z produces a PolyhedralSurfaceZ</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsX3D" /></para>
</refsection>
</refentry>
<refentry id="ST_StraightSkeleton">
<refnamediv>
<refname>ST_StraightSkeleton</refname>
<refpurpose>Compute a straight skeleton from a geometry</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_StraightSkeleton</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection><title>Examples</title>
<programlisting>SELECT ST_StraightSkeleton(ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))'));</programlisting>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><para><informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_straightskeleton01.png" />
</imageobject>
<caption><para>Original polygon</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para><informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_straightskeleton02.png" />
</imageobject>
<caption><para>Straight Skeleton of polygon</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
</refentry>
<refentry id="ST_ApproximateMedialAxis">
<refnamediv>
<refname>ST_ApproximateMedialAxis</refname>
<refpurpose>Compute the approximate medial axis of an areal geometry.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_ApproximateMedialAxis</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>
Return an approximate medial axis for the areal input based on
its straight skeleton. Uses an SFCGAL specific API when built against
a capable version (1.2.0+). Otherwise the function is just a wrapper
around ST_StraightSkeleton (slower case).
</para>
<para>Availability: 2.2.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection><title>Examples</title>
<programlisting>SELECT ST_ApproximateMedialAxis(ST_GeomFromText('POLYGON (( 190 190, 10 190, 10 10, 190 10, 190 20, 160 30, 60 30, 60 130, 190 140, 190 190 ))'));</programlisting>
<informaltable>
<tgroup cols="1">
<tbody>
<row>
<entry><para><informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_approximatemedialaxis01.png" />
</imageobject>
<caption><para>A polygon and its approximate medial axis</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_StraightSkeleton" /></para>
</refsection>
</refentry>
<refentry id="ST_IsPlanar">
<refnamediv>
<refname>ST_IsPlanar</refname>
<refpurpose>Check if a surface is or not planar</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>ST_IsPlanar</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.2.0: This was documented in 2.1.0 but got accidentally left out in 2.1 release.</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
</refentry>
<refentry id="ST_Orientation">
<refnamediv>
<refname>ST_Orientation</refname>
<refpurpose>Determine surface orientation</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>integer <function>ST_Orientation</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>The function only applies to polygons. It returns -1 if the polygon is counterclockwise oriented and 1 if the polygon is clockwise oriented.</para>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
</refsection>
</refentry>
<refentry id="ST_ForceLHR">
<refnamediv>
<refname>ST_ForceLHR</refname>
<refpurpose>Force LHR orientation</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_ForceLHR</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
</refentry>
<refentry id="ST_MinkowskiSum">
<refnamediv>
<refname>ST_MinkowskiSum</refname>
<refpurpose>Performs Minkowski sum</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_MinkowskiSum</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>geom2</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>This function performs a 2D minkowski sum of a point, line or polygon with a polygon.</para>
<para>A minkowski sum of two geometries A and B is the set of all points that are the sum of any point in A and B. Minkowski sums are often used in motion planning and computer-aided design. More details on <ulink url="https://en.wikipedia.org/wiki/Minkowski_addition">Wikipedia Minkowski addition</ulink>.</para>
<para>The first parameter can be any 2D geometry (point, linestring, polygon). If a 3D geometry is passed, it will be converted to 2D by forcing Z to 0, leading to possible cases of invalidity. The second parameter must be a 2D polygon.</para>
<para>Implementation utilizes <ulink url="http://doc.cgal.org/latest/Minkowski_sum_2/">CGAL 2D Minkowskisum</ulink>.</para>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
</refsection>
<refsection><title>Examples</title>
<para>Minkowski Sum of Linestring and circle polygon where Linestring cuts thru the circle</para>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry>
<para>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_minkowskisum01.png" />
</imageobject>
<caption><para>Before Summing</para></caption>
</mediaobject>
</informalfigure>
</para>
</entry>
<entry>
<para>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_minkowskisum02.png" />
</imageobject>
<caption><para>After summing</para></caption>
</mediaobject>
</informalfigure>
</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<programlisting>
SELECT ST_MinkowskiSum(line, circle))
FROM (SELECT
ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(100, 100)) As line,
ST_Buffer(ST_GeomFromText('POINT(50 50)'), 30) As circle) As foo;
-- wkt --
MULTIPOLYGON(((30 59.9999999999999,30.5764415879031 54.1472903395161,32.2836140246614 48.5194970290472,35.0559116309237 43.3328930094119,38.7867965644036 38.7867965644035,43.332893009412 35.0559116309236,48.5194970290474 32.2836140246614,54.1472903395162 30.5764415879031,60.0000000000001 30,65.8527096604839 30.5764415879031,71.4805029709527 32.2836140246614,76.6671069905881 35.0559116309237,81.2132034355964 38.7867965644036,171.213203435596 128.786796564404,174.944088369076 133.332893009412,177.716385975339 138.519497029047,179.423558412097 144.147290339516,180 150,179.423558412097 155.852709660484,177.716385975339 161.480502970953,174.944088369076 166.667106990588,171.213203435596 171.213203435596,166.667106990588 174.944088369076,
161.480502970953 177.716385975339,155.852709660484 179.423558412097,150 180,144.147290339516 179.423558412097,138.519497029047 177.716385975339,133.332893009412 174.944088369076,128.786796564403 171.213203435596,38.7867965644035 81.2132034355963,35.0559116309236 76.667106990588,32.2836140246614 71.4805029709526,30.5764415879031 65.8527096604838,30 59.9999999999999)))
</programlisting>
<para>Minkowski Sum of a polygon and multipoint</para>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry>
<para>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_minkowskisum03.png" />
</imageobject>
<caption><para>Before Summing</para></caption>
</mediaobject>
</informalfigure>
</para>
</entry>
<entry>
<para>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_minkowskisum04.png" />
</imageobject>
<caption><para>After summing: polygon is duplicated and translated to position of points</para></caption>
</mediaobject>
</informalfigure>
</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<programlisting>SELECT ST_MinkowskiSum(mp, poly)
FROM (SELECT 'MULTIPOINT(25 50,70 25)'::geometry As mp,
'POLYGON((130 150, 20 40, 50 60, 125 100, 130 150))'::geometry As poly
) As foo
-- wkt --
MULTIPOLYGON(
((70 115,100 135,175 175,225 225,70 115)),
((120 65,150 85,225 125,275 175,120 65))
)
</programlisting>
</refsection>
</refentry>
<refentry id="ST_3DIntersection">
<refnamediv>
<refname>ST_3DIntersection</refname>
<refpurpose>Perform 3D intersection</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_3DIntersection</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>geom2</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return a geometry that is the shared portion between geom1 and geom2.</para>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<para>3D images were generated using PostGIS <xref linkend="ST_AsX3D" /> and rendering in HTML using <ulink url="http://www.x3dom.org">X3Dom HTML Javascript rendering library</ulink>.</para>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><para>
<programlisting>SELECT ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30) AS geom1,
ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(80 80)'),
50, 'quad_segs=1'),0,0,30) AS geom2;
</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_3ddifference01.png" />
</imageobject>
<caption><para>Original 3D geometries overlaid. geom2 is shown semi-transparent</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para>
<programlisting>SELECT ST_3DIntersection(geom1,geom2)
FROM ( SELECT ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30) AS geom1,
ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(80 80)'),
50, 'quad_segs=1'),0,0,30) AS geom2 ) As t;</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_3dintersection01.png" />
</imageobject>
<caption><para>Intersection of geom1 and geom2</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>3D linestrings and polygons</para>
<programlisting> SELECT ST_AsText(ST_3DIntersection(linestring, polygon)) As wkt
FROM ST_GeomFromText('LINESTRING Z (2 2 6,1.5 1.5 7,1 1 8,0.5 0.5 8,0 0 10)') AS linestring
CROSS JOIN ST_GeomFromText('POLYGON((0 0 8, 0 1 8, 1 1 8, 1 0 8, 0 0 8))') AS polygon;
wkt
--------------------------------
LINESTRING Z (1 1 8,0.5 0.5 8)
</programlisting>
<para>Cube (closed Polyhedral Surface) and Polygon Z</para>
<programlisting>SELECT ST_AsText(ST_3DIntersection(
ST_GeomFromText('POLYHEDRALSURFACE Z( ((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)) )'),
'POLYGON Z ((0 0 0, 0 0 0.5, 0 0.5 0.5, 0 0.5 0, 0 0 0))'::geometry))</programlisting>
<screen>TIN Z (((0 0 0,0 0 0.5,0 0.5 0.5,0 0 0)),((0 0.5 0,0 0 0,0 0.5 0.5,0 0.5 0)))</screen>
<para>Intersection of 2 solids that result in volumetric intersection is also a solid (ST_Dimension returns 3)</para>
<programlisting>SELECT ST_AsText(ST_3DIntersection( ST_Extrude(ST_Buffer('POINT(10 20)'::geometry,10,1),0,0,30),
ST_Extrude(ST_Buffer('POINT(10 20)'::geometry,10,1),2,0,10) ));</programlisting>
<screen>POLYHEDRALSURFACE Z (((13.3333333333333 13.3333333333333 10,20 20 0,20 20 10,13.3333333333333 13.3333333333333 10)),
((20 20 10,16.6666666666667 23.3333333333333 10,13.3333333333333 13.3333333333333 10,20 20 10)),
((20 20 0,16.6666666666667 23.3333333333333 10,20 20 10,20 20 0)),
((13.3333333333333 13.3333333333333 10,10 10 0,20 20 0,13.3333333333333 13.3333333333333 10)),
((16.6666666666667 23.3333333333333 10,12 28 10,13.3333333333333 13.3333333333333 10,16.6666666666667 23.3333333333333 10)),
((20 20 0,9.99999999999995 30 0,16.6666666666667 23.3333333333333 10,20 20 0)),
((10 10 0,9.99999999999995 30 0,20 20 0,10 10 0)),((13.3333333333333 13.3333333333333 10,12 12 10,10 10 0,13.3333333333333 13.3333333333333 10)),
((12 28 10,12 12 10,13.3333333333333 13.3333333333333 10,12 28 10)),
((16.6666666666667 23.3333333333333 10,9.99999999999995 30 0,12 28 10,16.6666666666667 23.3333333333333 10)),
((10 10 0,0 20 0,9.99999999999995 30 0,10 10 0)),
((12 12 10,11 11 10,10 10 0,12 12 10)),((12 28 10,11 11 10,12 12 10,12 28 10)),
((9.99999999999995 30 0,11 29 10,12 28 10,9.99999999999995 30 0)),((0 20 0,2 20 10,9.99999999999995 30 0,0 20 0)),
((10 10 0,2 20 10,0 20 0,10 10 0)),((11 11 10,2 20 10,10 10 0,11 11 10)),((12 28 10,11 29 10,11 11 10,12 28 10)),
((9.99999999999995 30 0,2 20 10,11 29 10,9.99999999999995 30 0)),((11 11 10,11 29 10,2 20 10,11 11 10)))</screen>
</refsection>
</refentry>
<refentry id="ST_3DDifference">
<refnamediv>
<refname>ST_3DDifference</refname>
<refpurpose>Perform 3D difference</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_3DDifference</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>geom2</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns that part of geom1 that is not part of geom2.</para>
<para>Availability: 2.2.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<para>3D images were generated using PostGIS <xref linkend="ST_AsX3D" /> and rendering in HTML using <ulink url="http://www.x3dom.org">X3Dom HTML Javascript rendering library</ulink>.</para>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><para>
<programlisting>SELECT ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30) AS geom1,
ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(80 80)'),
50, 'quad_segs=1'),0,0,30) AS geom2;
</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_3ddifference01.png" />
</imageobject>
<caption><para>Original 3D geometries overlaid. geom2 is the part that will be removed.</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para>
<programlisting>SELECT ST_3DDifference(geom1,geom2)
FROM ( SELECT ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30) AS geom1,
ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(80 80)'),
50, 'quad_segs=1'),0,0,30) AS geom2 ) As t;</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_3ddifference02.png" />
</imageobject>
<caption><para>What's left after removing geom2</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
<refsection>
<title>See Also</title>
<para>
<xref linkend="ST_Extrude" />,
<xref linkend="ST_AsX3D" />, <xref linkend="ST_3DIntersection" />
<xref linkend="ST_3DUnion" />
</para>
</refsection>
</refentry>
<refentry id="ST_3DUnion">
<refnamediv>
<refname>ST_3DUnion</refname>
<refpurpose>Perform 3D union</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_3DUnion</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>geom2</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.2.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<para>3D images were generated using PostGIS <xref linkend="ST_AsX3D" /> and rendering in HTML using <ulink url="http://www.x3dom.org">X3Dom HTML Javascript rendering library</ulink>.</para>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><para>
<programlisting>SELECT ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30) AS geom1,
ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(80 80)'),
50, 'quad_segs=1'),0,0,30) AS geom2;
</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_3ddifference01.png" />
</imageobject>
<caption><para>Original 3D geometries overlaid. geom2 is the one with transparency.</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para>
<programlisting>SELECT ST_3DUnion(geom1,geom2)
FROM ( SELECT ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(100 90)'),
50, 'quad_segs=2'),0,0,30) AS geom1,
ST_Extrude(ST_Buffer(ST_GeomFromText('POINT(80 80)'),
50, 'quad_segs=1'),0,0,30) AS geom2 ) As t;</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_3dunion01.png" />
</imageobject>
<caption><para>Union of geom1 and geom2</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
<refsection>
<title>See Also</title>
<para>
<xref linkend="ST_Extrude" />,
<xref linkend="ST_AsX3D" />, <xref linkend="ST_3DIntersection" />
<xref linkend="ST_3DDifference" />
</para>
</refsection>
</refentry>
<refentry id="ST_3DArea">
<refnamediv>
<refname>ST_3DArea</refname>
<refpurpose>Computes area of 3D surface geometries. Will return 0 for solids.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>float<function>ST_3DArea</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection><title>Examples</title>
<para>Note: By default a PolyhedralSurface built from WKT is a surface geometry, not solid. It therefore has surface area. Once converted to a solid, no area.</para>
<programlisting>SELECT ST_3DArea(geom) As cube_surface_area,
ST_3DArea(ST_MakeSolid(geom)) As solid_surface_area
FROM (SELECT '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)) )'::geometry) As f(geom);
cube_surface_area | solid_surface_area
-------------------+--------------------
6 | 0 </programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Area" />, <xref linkend="ST_MakeSolid" />, <xref linkend="ST_IsSolid" />, <xref linkend="ST_Area" /></para>
</refsection>
</refentry>
<refentry id="ST_Tesselate">
<refnamediv>
<refname>ST_Tesselate</refname>
<refpurpose>Perform surface Tesselation of a polygon or polyhedralsurface and returns as a TIN or collection of TINS</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_Tesselate</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Takes as input a surface such a MULTI(POLYGON) or POLYHEDRALSURFACE and returns a TIN representation via the process of tesselation using triangles.</para>
<para>Availability: 2.1.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection><title>Examples</title>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><para>
<programlisting>SELECT ST_GeomFromText('POLYHEDRALSURFACE Z( ((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>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_tesselate01.png" />
</imageobject>
<caption><para>Original Cube</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para>
<programlisting>SELECT ST_Tesselate(ST_GeomFromText('POLYHEDRALSURFACE Z( ((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></para>
<para>ST_AsText output:</para>
<screen>TIN Z (((0 0 0,0 0 1,0 1 1,0 0 0)),((0 1 0,0 0 0,0 1 1,0 1 0)),
((0 0 0,0 1 0,1 1 0,0 0 0)),
((1 0 0,0 0 0,1 1 0,1 0 0)),((0 0 1,1 0 0,1 0 1,0 0 1)),
((0 0 1,0 0 0,1 0 0,0 0 1)),
((1 1 0,1 1 1,1 0 1,1 1 0)),((1 0 0,1 1 0,1 0 1,1 0 0)),
((0 1 0,0 1 1,1 1 1,0 1 0)),((1 1 0,0 1 0,1 1 1,1 1 0)),
((0 1 1,1 0 1,1 1 1,0 1 1)),((0 1 1,0 0 1,1 0 1,0 1 1)))</screen>
<para> <informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_tesselate02.png" />
</imageobject>
<caption><para>Tesselated Cube with triangles colored</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
<row>
<entry><para>
<programlisting>SELECT 'POLYGON (( 10 190, 10 70, 80 70, 80 130, 50 160, 120 160, 120 190, 10 190 ))'::geometry;</programlisting>
<informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_tesselate03.png" />
</imageobject>
<caption><para>Original polygon</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
<entry><para>
<programlisting>SELECT
ST_Tesselate('POLYGON (( 10 190, 10 70, 80 70, 80 130, 50 160, 120 160, 120 190, 10 190 ))'::geometry);</programlisting>
</para>
<para>ST_AsText output</para>
<screen>TIN(((80 130,50 160,80 70,80 130)),((50 160,10 190,10 70,50 160)),
((80 70,50 160,10 70,80 70)),((120 160,120 190,50 160,120 160)),
((120 190,10 190,50 160,120 190)))</screen>
<para><informalfigure>
<mediaobject>
<imageobject>
<imagedata fileref="images/st_tesselate04.png" />
</imageobject>
<caption><para>Tesselated Polygon</para></caption>
</mediaobject>
</informalfigure></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsection>
</refentry>
<refentry id="ST_Volume">
<refnamediv>
<refname>ST_Volume</refname>
<refpurpose>Computes the volume of a 3D solid. If applied to surface (even closed) geometries will return 0.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>float <function>ST_Volume</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.2.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Example</title>
<para>When closed surfaces are created with WKT, they are treated as areal rather than solid. To make them solid, you need to use <xref linkend="ST_MakeSolid" />.
Areal geometries have no volume. Here is an example to demonstrate.</para>
<programlisting>SELECT ST_Volume(geom) As cube_surface_vol,
ST_Volume(ST_MakeSolid(geom)) As solid_surface_vol
FROM (SELECT '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)) )'::geometry) As f(geom);
cube_surface_vol | solid_surface_vol
------------------+-------------------
0 | 1
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_3DArea" />, <xref linkend="ST_MakeSolid" />, <xref linkend="ST_IsSolid" /></para>
</refsection>
</refentry>
<refentry id="ST_MakeSolid">
<refnamediv>
<refname>ST_MakeSolid</refname>
<refpurpose>Cast the geometry into a solid. No check is performed. To obtain a valid solid, the input geometry must be a closed Polyhedral Surface or a closed TIN.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry<function>ST_MakeSolid</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.2.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
</refentry>
<refentry id="ST_IsSolid">
<refnamediv>
<refname>ST_IsSolid</refname>
<refpurpose>Test if the geometry is a solid. No validity check is performed.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>boolean<function>ST_IsSolid</function></funcdef>
<paramdef><type>geometry</type> <parameter>geom1</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Availability: 2.2.0</para>
<para>&sfcgal_required;</para>
<para>&Z_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
</refentry>
</sect1>
|