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
|
<?xml version="1.0" encoding="UTF-8"?>
<sect1 id="Miscellaneous_Functions">
<title>Miscellaneous Functions</title>
<refentry id="ST_Accum">
<refnamediv>
<refname>ST_Accum</refname>
<refpurpose>Aggregate. Constructs an array of geometries.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry[] <function>ST_Accum</function></funcdef>
<paramdef><type>geometry set</type> <parameter>geomfield</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Aggregate. Constructs an array of geometries.</para>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles 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_Accum(the_geom)) As all_em, ST_AsText((ST_Accum(the_geom))[1]) As grabone,
(ST_Accum(the_geom))[2:4] as grab_rest
FROM (SELECT ST_MakePoint(a*CAST(random()*10 As integer), a*CAST(random()*10 As integer), a*CAST(random()*10 As integer)) As the_geom
FROM generate_series(1,4) a) As foo;
all_em|grabone | grab_rest
-------------------------------------------------------------------------------+
{0101000080000000000000144000000000000024400000000000001040:
0101000080000000000
00018400000000000002C400000000000003040:
0101000080000000000000354000000000000038400000000000001840:
010100008000000000000040400000000000003C400000000000003040} |
POINT(5 10) | {010100008000000000000018400000000000002C400000000000003040:
0101000080000000000000354000000000000038400000000000001840:
010100008000000000000040400000000000003C400000000000003040}
(1 row)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Collect" /></para>
</refsection>
</refentry>
<refentry id="Box2D">
<refnamediv>
<refname>Box2D</refname>
<refpurpose>Returns a BOX2D representing the maximum extents of the geometry.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>box2d <function>Box2D</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns a BOX2D representing the maximum extents of the geometry.</para>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para>&curve_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT Box2D(ST_GeomFromText('LINESTRING(1 2, 3 4, 5 6)'));
box2d
---------
BOX(1 2,5 6)
SELECT Box2D(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)'));
box2d
--------
BOX(220186.984375 150406,220288.25 150506.140625)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="Box3D" />, <xref linkend="ST_GeomFromText" /></para>
</refsection>
</refentry>
<refentry id="Box3D">
<refnamediv>
<refname>Box3D</refname>
<refpurpose>Returns a BOX3D representing the maximum extents of the geometry.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>box3d <function>Box3D</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns a BOX3D representing the maximum extents of the geometry.</para>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para>&curve_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
<para>&Z_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT Box3D(ST_GeomFromEWKT('LINESTRING(1 2 3, 3 4 5, 5 6 5)'));
Box3d
---------
BOX3D(1 2 3,5 6 5)
SELECT Box3D(ST_GeomFromEWKT('CIRCULARSTRING(220268 150415 1,220227 150505 1,220227 150406 1)'));
Box3d
--------
BOX3D(220227 150406 1,220268 150415 1)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="Box2D" />, <xref linkend="ST_GeomFromEWKT" /></para>
</refsection>
</refentry>
<refentry id="ST_EstimatedExtent">
<refnamediv>
<refname>ST_EstimatedExtent</refname>
<refpurpose>Return the 'estimated' extent of the given spatial table.
The estimated is taken from the geometry column's statistics. The
current schema will be used if not specified.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>box2d <function>ST_EstimatedExtent</function></funcdef>
<paramdef><type>text </type> <parameter>schema_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>geocolumn_name</parameter></paramdef>
<paramdef><type>boolean </type> <parameter>parent_ony</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>box2d <function>ST_EstimatedExtent</function></funcdef>
<paramdef><type>text </type> <parameter>schema_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>geocolumn_name</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>box2d <function>ST_EstimatedExtent</function></funcdef>
<paramdef><type>text </type> <parameter>table_name</parameter></paramdef>
<paramdef><type>text </type> <parameter>geocolumn_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Return the 'estimated' extent of the given spatial table.
The estimated is taken from the geometry column's statistics. The
current schema will be used if not specified. The default behavior
is to also use statistics collected from children tables (tables
with INHERITS) if available. If 'parent_ony' is set to TRUE, only
statistics for the given table are used and children tables are
ignored.
</para>
<para>For PostgreSQL>=8.0.0 statistics are gathered by VACUUM
ANALYZE and resulting extent will be about 95% of the real
one.</para>
<note>
<para>
In absence of statistics (empty table or no ANALYZE called) this function
returns NULL. Prior to version 1.5.4 an exception was thrown
instead.
</para>
</note>
<para>For PostgreSQL<8.0.0 statistics are gathered by
update_geometry_stats() and resulting extent will be exact.</para>
<para>Availability: 1.0.0</para>
<para>Changed: 2.1.0. Up to 2.0.x this was called ST_Estimated_Extent.</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_EstimatedExtent('ny', 'edges', 'the_geom');
--result--
BOX(-8877653 4912316,-8010225.5 5589284)
SELECT ST_EstimatedExtent('feature_poly', 'the_geom');
--result--
BOX(-124.659652709961 24.6830825805664,-67.7798080444336 49.0012092590332)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Extent" /></para>
</refsection>
</refentry>
<refentry id="ST_Expand">
<refnamediv>
<refname>ST_Expand</refname>
<refpurpose>Returns bounding box expanded in all directions from the bounding box of the input geometry. Uses double-precision</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_Expand</function></funcdef>
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
<paramdef><type>float</type> <parameter>units_to_expand</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Expand</function></funcdef>
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
<paramdef><type>float</type> <parameter>dx</parameter></paramdef>
<paramdef><type>float</type> <parameter>dy</parameter></paramdef>
<paramdef choice="opt"><type>float</type> <parameter>dz=0</parameter></paramdef>
<paramdef choice="opt"><type>float</type> <parameter>dm=0</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>box2d <function>ST_Expand</function></funcdef>
<paramdef><type>box2d </type> <parameter>box</parameter></paramdef>
<paramdef><type>float</type> <parameter>units_to_expand</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>box2d <function>ST_Expand</function></funcdef>
<paramdef><type>box2d </type> <parameter>box</parameter></paramdef>
<paramdef><type>float</type> <parameter>dx</parameter></paramdef>
<paramdef><type>float</type> <parameter>dy</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>box3d <function>ST_Expand</function></funcdef>
<paramdef><type>box3d </type> <parameter>box</parameter></paramdef>
<paramdef><type>float</type> <parameter>units_to_expand</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>box3d <function>ST_Expand</function></funcdef>
<paramdef><type>box3d </type> <parameter>box</parameter></paramdef>
<paramdef><type>float</type> <parameter>dx</parameter></paramdef>
<paramdef><type>float</type> <parameter>dy</parameter></paramdef>
<paramdef choice="opt"><type>float</type> <parameter>dz=0</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>This function returns a bounding box expanded from the bounding box of the input,
either by specifying a single distance with which the box should be expanded in all
directions, or by specifying an expansion distance for each direction.
Uses double-precision. Can be very useful for distance queries, or to add a bounding box
filter to a query to take advantage of a spatial index.</para>
<para>In addition to the geometry version of ST_Expand, which is the most commonly used, variants
are provided that accept and produce internal BOX2D and BOX3D data types.
</para>
<para>ST_Expand is similar in concept to ST_Buffer, except while buffer expands the geometry in all directions,
ST_Expand expands the bounding box an x,y,z unit amount.</para>
<para>Units are in the units of the spatial reference system in use denoted by the SRID.</para>
<note>
<para>Pre 1.3, ST_Expand was used in conjunction with distance to do indexable queries. Something of the form
<code>the_geom && ST_Expand('POINT(10 20)', 10) AND ST_Distance(the_geom, 'POINT(10 20)') < 10</code>
Post 1.2, this was replaced with the easier ST_DWithin construct.</para>
</note>
<note>
<para>Availability: 1.5.0 behavior changed to output double precision instead of float4 coordinates.</para>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para>Enhanced: 2.3.0 support was added to expand a box by different amounts in different dimensions.</para>
</note>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<note><para>Examples below use US National Atlas Equal Area (SRID=2163) which is a meter projection</para></note>
<programlisting>
<!-- TODO: fix results of documentation to reflect new behavior -->
--10 meter expanded box around bbox of a linestring
SELECT CAST(ST_Expand(ST_GeomFromText('LINESTRING(2312980 110676,2312923 110701,2312892 110714)', 2163),10) As box2d);
st_expand
------------------------------------
BOX(2312882 110666,2312990 110724)
--10 meter expanded 3d box of a 3d box
SELECT ST_Expand(CAST('BOX3D(778783 2951741 1,794875 2970042.61545891 10)' As box3d),10)
st_expand
-----------------------------------------------------
BOX3D(778773 2951731 -9,794885 2970052.61545891 20)
--10 meter geometry astext rep of a expand box around a point geometry
SELECT ST_AsEWKT(ST_Expand(ST_GeomFromEWKT('SRID=2163;POINT(2312980 110676)'),10));
st_asewkt
-------------------------------------------------------------------------------------------------
SRID=2163;POLYGON((2312970 110666,2312970 110686,2312990 110686,2312990 110666,2312970 110666))
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsEWKT" />, <xref linkend="ST_Buffer" />, <xref linkend="ST_DWithin" />, <xref linkend="ST_GeomFromEWKT" />, <xref linkend="ST_GeomFromText" />, <xref linkend="ST_SRID" /></para>
</refsection>
</refentry>
<refentry id="ST_Extent">
<refnamediv>
<refname>ST_Extent</refname>
<refpurpose>an aggregate function that returns the bounding box that bounds rows of geometries.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>box2d <function>ST_Extent</function></funcdef>
<paramdef><type>geometry set</type> <parameter>geomfield</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>ST_Extent returns a bounding box that encloses a set of geometries. The ST_Extent function is an "aggregate" function in the
terminology of SQL. That means that it operates on lists
of data, in the same way the SUM() and AVG() functions do.</para>
<para>Since it returns a bounding box, the spatial Units are in the units of the spatial reference system in use denoted by the SRID</para>
<para>ST_Extent is similar in concept to Oracle Spatial/Locator's SDO_AGGR_MBR</para>
<note>
<para>Since ST_Extent returns a bounding box, the SRID meta-data is lost. Use ST_SetSRID to force it back into
a geometry with SRID meta data. The coordinates are in the units of the spatial ref of the orginal geometries.</para>
</note>
<note>
<para>ST_Extent will return boxes with only an x and y component even with (x,y,z) coordinate geometries. To maintain x,y,z use ST_3DExtent instead.</para>
</note>
<note>
<para>Availability: 1.4.0</para>
</note>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<note><para>Examples below use Massachusetts State Plane ft (SRID=2249)</para></note>
<programlisting>
SELECT ST_Extent(the_geom) as bextent FROM sometable;
st_bextent
------------------------------------
BOX(739651.875 2908247.25,794875.8125 2970042.75)
--Return extent of each category of geometries
SELECT ST_Extent(the_geom) as bextent
FROM sometable
GROUP BY category ORDER BY category;
bextent | name
----------------------------------------------------+----------------
BOX(778783.5625 2951741.25,794875.8125 2970042.75) | A
BOX(751315.8125 2919164.75,765202.6875 2935417.25) | B
BOX(739651.875 2917394.75,756688.375 2935866) | C
--Force back into a geometry
-- and render the extended text representation of that geometry
SELECT ST_SetSRID(ST_Extent(the_geom),2249) as bextent FROM sometable;
bextent
--------------------------------------------------------------------------------
SRID=2249;POLYGON((739651.875 2908247.25,739651.875 2970042.75,794875.8125 2970042.75,
794875.8125 2908247.25,739651.875 2908247.25))
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_AsEWKT" />, <xref linkend="ST_3DExtent" />, <xref linkend="ST_SetSRID" />, <xref linkend="ST_SRID" /></para>
</refsection>
</refentry>
<refentry id="ST_3DExtent">
<refnamediv>
<refname>ST_3DExtent</refname>
<refpurpose>an aggregate function that returns the box3D bounding box that bounds rows of geometries.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>box3d <function>ST_3DExtent</function></funcdef>
<paramdef><type>geometry set</type> <parameter>geomfield</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>ST_3DExtent returns a box3d (includes Z coordinate) bounding box that encloses a set of geometries. The ST_3DExtent function is an "aggregate" function in the
terminology of SQL. That means that it operates on lists
of data, in the same way the SUM() and AVG() functions do.</para>
<para>Since it returns a bounding box, the spatial Units are in the units of the spatial reference system in use denoted by the SRID</para>
<note>
<para>Since ST_3DExtent returns a bounding box, the SRID meta-data is lost. Use ST_SetSRID to force it back into
a geometry with SRID meta data. The coordinates are in the units of the spatial ref of the orginal geometries.</para>
</note>
<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para>Changed: 2.0.0 In prior versions this used to be called ST_Extent3D</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_3DExtent(foo.the_geom) As b3extent
FROM (SELECT ST_MakePoint(x,y,z) As the_geom
FROM generate_series(1,3) As x
CROSS JOIN generate_series(1,2) As y
CROSS JOIN generate_series(0,2) As Z) As foo;
b3extent
--------------------
BOX3D(1 1 0,3 2 2)
--Get the extent of various elevated circular strings
SELECT ST_3DExtent(foo.the_geom) As b3extent
FROM (SELECT ST_Translate(ST_Force_3DZ(ST_LineToCurve(ST_Buffer(ST_MakePoint(x,y),1))),0,0,z) As the_geom
FROM generate_series(1,3) As x
CROSS JOIN generate_series(1,2) As y
CROSS JOIN generate_series(0,2) As Z) As foo;
b3extent
--------------------
BOX3D(1 0 0,4 2 2)
</programlisting>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Extent" />, <xref linkend="ST_Force_3DZ" /></para>
</refsection>
</refentry>
<refentry id="Find_SRID">
<refnamediv>
<refname>Find_SRID</refname>
<refpurpose>The syntax is find_srid(a_db_schema, a_table,
a_column) and the function returns the integer SRID of the
specified column by searching through the GEOMETRY_COLUMNS table.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>integer <function>Find_SRID</function></funcdef>
<paramdef><type>varchar </type> <parameter>a_schema_name</parameter></paramdef>
<paramdef><type>varchar </type> <parameter>a_table_name</parameter></paramdef>
<paramdef><type>varchar </type> <parameter>a_geomfield_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>The syntax is find_srid(<db/schema>, <table>,
<column>) and the function returns the integer SRID of the
specified column by searching through the GEOMETRY_COLUMNS table.
If the geometry column has not been properly added with the
AddGeometryColumns() function, this function will not work
either.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting> SELECT Find_SRID('public', 'tiger_us_state_2007', 'the_geom_4269');
find_srid
----------
4269
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_SRID" /></para>
</refsection>
</refentry>
<refentry id="ST_MemSize">
<refnamediv>
<refname>ST_MemSize</refname>
<refpurpose>Returns the amount of space (in bytes) the geometry takes.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>integer <function>ST_MemSize</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns the amount of space (in bytes) the geometry takes. </para>
<para>This is a nice compliment to PostgreSQL built in functions pg_column_size, pg_size_pretty, pg_relation_size, pg_total_relation_size.</para>
<note><para>pg_relation_size which gives the byte size of a table may return byte size lower than ST_MemSize. This is because
pg_relation_size does not add toasted table contribution and large geometries are stored in TOAST tables.</para>
<para>pg_total_relation_size - includes, the table, the toasted tables, and the indexes.</para>
<para>pg_column_size returns how much space a geometry would take in a column considering compression, so may be lower than ST_MemSize</para>
</note>
<para>&Z_support;</para>
<para>&curve_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
<para>Changed: 2.2.0 name changed to ST_MemSize to follow naming convention. In prior versions this function was called ST_Mem_Size, old name deprecated though still available.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
--Return how much byte space Boston takes up in our Mass data set
SELECT pg_size_pretty(SUM(ST_MemSize(the_geom))) as totgeomsum,
pg_size_pretty(SUM(CASE WHEN town = 'BOSTON' THEN ST_MemSize(the_geom) ELSE 0 END)) As bossum,
CAST(SUM(CASE WHEN town = 'BOSTON' THEN ST_MemSize(the_geom) ELSE 0 END)*1.00 /
SUM(ST_MemSize(the_geom))*100 As numeric(10,2)) As perbos
FROM towns;
totgeomsum bossum perbos
---------- ------ ------
1522 kB 30 kB 1.99
SELECT ST_MemSize(ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)'));
---
73
--What percentage of our table is taken up by just the geometry
SELECT pg_total_relation_size('public.neighborhoods') As fulltable_size, sum(ST_MemSize(the_geom)) As geomsize,
sum(ST_MemSize(the_geom))*1.00/pg_total_relation_size('public.neighborhoods')*100 As pergeom
FROM neighborhoods;
fulltable_size geomsize pergeom
------------------------------------------------
262144 96238 36.71188354492187500000
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para></para>
</refsection>
</refentry>
<refentry id="ST_Point_Inside_Circle">
<refnamediv>
<refname>ST_PointInsideCircle</refname>
<refpurpose>Is the point geometry inside the circle defined by center_x, center_y, radius</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>boolean <function>ST_PointInsideCircle</function></funcdef>
<paramdef><type>geometry </type> <parameter>a_point</parameter></paramdef>
<paramdef><type>float </type> <parameter>center_x</parameter></paramdef>
<paramdef><type>float </type> <parameter>center_y</parameter></paramdef>
<paramdef><type>float </type> <parameter>radius</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>The syntax for this functions is
ST_PointInsideCircle(<geometry>,<circle_center_x>,<circle_center_y>,<radius>).
Returns the true if the geometry is a point and is inside the
circle. Returns false otherwise.</para>
<note><para>This only works for points as the name suggests</para></note>
<para>Availability: 1.2</para>
<para>Changed: 2.2.0 In prior versions this used to be called ST_Point_Inside_Circle</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_PointInsideCircle(ST_Point(1,2), 0.5, 2, 3);
st_pointinsidecircle
------------------------
t
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_DWithin" /></para>
</refsection>
</refentry>
</sect1>
|