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
|
<!-- Converted by db4-upgrade version 1.1 -->
<section xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Affine_Transformation">
<title>Affine Transformations</title><info>
<abstract>
<para>These functions change the position and shape of geometries using
<link xlink:href="https://en.wikipedia.org/wiki/Affine_transformation">affine transformations</link>.</para>
</abstract>
</info>
<refentry xml:id="ST_Affine">
<refnamediv>
<refname>ST_Affine</refname>
<refpurpose>Apply a 3D affine transformation to a geometry.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_Affine</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float </type> <parameter>a</parameter></paramdef>
<paramdef><type>float </type> <parameter>b</parameter></paramdef>
<paramdef><type>float </type> <parameter>c</parameter></paramdef>
<paramdef><type>float </type> <parameter>d</parameter></paramdef>
<paramdef><type>float </type> <parameter>e</parameter></paramdef>
<paramdef><type>float </type> <parameter>f</parameter></paramdef>
<paramdef><type>float </type> <parameter>g</parameter></paramdef>
<paramdef><type>float </type> <parameter>h</parameter></paramdef>
<paramdef><type>float </type> <parameter>i</parameter></paramdef>
<paramdef><type>float </type> <parameter>xoff</parameter></paramdef>
<paramdef><type>float </type> <parameter>yoff</parameter></paramdef>
<paramdef><type>float </type> <parameter>zoff</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Affine</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float </type> <parameter>a</parameter></paramdef>
<paramdef><type>float </type> <parameter>b</parameter></paramdef>
<paramdef><type>float </type> <parameter>d</parameter></paramdef>
<paramdef><type>float </type> <parameter>e</parameter></paramdef>
<paramdef><type>float </type> <parameter>xoff</parameter></paramdef>
<paramdef><type>float </type> <parameter>yoff</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Applies a 3D affine transformation to the geometry to do things like translate, rotate, scale in one step.</para>
<para>
Version 1: The
call <programlisting>ST_Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff) </programlisting>
represents the transformation matrix <programlisting>/ a b c xoff \
| d e f yoff |
| g h i zoff |
\ 0 0 0 1 /</programlisting> and the vertices are transformed as
follows: <programlisting>x' = a*x + b*y + c*z + xoff
y' = d*x + e*y + f*z + yoff
z' = g*x + h*y + i*z + zoff</programlisting> All of the translate / scale
functions below are expressed via such an affine
transformation.</para>
<para>Version 2: Applies a 2d affine transformation to the geometry. The
call <programlisting>ST_Affine(geom, a, b, d, e, xoff, yoff)</programlisting>
represents the transformation matrix <programlisting>/ a b 0 xoff \ / a b xoff \
| d e 0 yoff | rsp. | d e yoff |
| 0 0 1 0 | \ 0 0 1 /
\ 0 0 0 1 /</programlisting> and the vertices are transformed as
follows: <programlisting>x' = a*x + b*y + xoff
y' = d*x + e*y + yoff
z' = z </programlisting> This method is a subcase of the 3D method
above.</para>
<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para role="availability" conformance="1.1.2.">Availability: 1.1.2. Name changed from Affine to ST_Affine in 1.2.2</para>
<note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</para></note>
<para>&P_support;</para>
<para>&T_support;</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
--Rotate a 3d line 180 degrees about the z axis. Note this is long-hand for doing ST_Rotate();
SELECT ST_AsEWKT(ST_Affine(geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0, 1, 0, 0, 0)) As using_affine,
ST_AsEWKT(ST_Rotate(geom, pi())) As using_rotate
FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As geom) As foo;
using_affine | using_rotate
-----------------------------+-----------------------------
LINESTRING(-1 -2 3,-1 -4 3) | LINESTRING(-1 -2 3,-1 -4 3)
(1 row)
--Rotate a 3d line 180 degrees in both the x and z axis
SELECT ST_AsEWKT(ST_Affine(geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0))
FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As geom) As foo;
st_asewkt
-------------------------------
LINESTRING(-1 -2 -3,-1 -4 -3)
(1 row)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Rotate"/>, <xref linkend="ST_Scale"/>, <xref linkend="ST_Translate"/>, <xref linkend="ST_TransScale"/></para>
</refsection>
</refentry>
<refentry xml:id="ST_Rotate">
<refnamediv>
<refname>ST_Rotate</refname>
<refpurpose>Rotates a geometry about an origin point.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_Rotate</function></funcdef>
<paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Rotate</function></funcdef>
<paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
<paramdef><type>float</type> <parameter>x0</parameter></paramdef>
<paramdef><type>float</type> <parameter>y0</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Rotate</function></funcdef>
<paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>pointOrigin</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Rotates geometry rotRadians counter-clockwise about the origin point. The rotation origin can be
specified either as a POINT geometry, or as x and y coordinates. If the origin is not
specified, the geometry is rotated about POINT(0 0).</para>
<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 additional parameters for specifying the origin of rotation were added.</para>
<para role="availability" conformance="1.1.2.">Availability: 1.1.2. Name changed from Rotate to ST_Rotate in 1.2.2</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
--Rotate 180 degrees
SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()));
st_asewkt
---------------------------------------
LINESTRING(-50 -160,-50 -50,-100 -50)
(1 row)
--Rotate 30 degrees counter-clockwise at x=50, y=160
SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()/6, 50, 160));
st_asewkt
---------------------------------------------------------------------------
LINESTRING(50 160,105 64.7372055837117,148.301270189222 89.7372055837117)
(1 row)
--Rotate 60 degrees clockwise from centroid
SELECT ST_AsEWKT(ST_Rotate(geom, -pi()/3, ST_Centroid(geom)))
FROM (SELECT 'LINESTRING (50 160, 50 50, 100 50)'::geometry AS geom) AS foo;
st_asewkt
--------------------------------------------------------------
LINESTRING(116.4225 130.6721,21.1597 75.6721,46.1597 32.3708)
(1 row)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Affine"/>, <xref linkend="ST_RotateX"/>, <xref linkend="ST_RotateY"/>, <xref linkend="ST_RotateZ"/></para>
</refsection>
</refentry>
<refentry xml:id="ST_RotateX">
<refnamediv>
<refname>ST_RotateX</refname>
<refpurpose>Rotates a geometry about the X axis.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_RotateX</function></funcdef>
<paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Rotates a geometry geomA - rotRadians about the X axis.</para>
<note><para><code>ST_RotateX(geomA, rotRadians)</code>
is short-hand for <code>ST_Affine(geomA, 1, 0, 0, 0, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0)</code>.</para></note>
<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para role="availability" conformance="1.1.2.">Availability: 1.1.2. Name changed from RotateX to ST_RotateX in 1.2.2</para>
<para>&P_support;</para>
<para>&Z_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
--Rotate a line 90 degrees along x-axis
SELECT ST_AsEWKT(ST_RotateX(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
st_asewkt
---------------------------
LINESTRING(1 -3 2,1 -1 1)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Affine"/>, <xref linkend="ST_RotateY"/>, <xref linkend="ST_RotateZ"/></para>
</refsection>
</refentry>
<refentry xml:id="ST_RotateY">
<refnamediv>
<refname>ST_RotateY</refname>
<refpurpose>Rotates a geometry about the Y axis.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_RotateY</function></funcdef>
<paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Rotates a geometry geomA - rotRadians about the y axis.</para>
<note><para><code>ST_RotateY(geomA, rotRadians)</code>
is short-hand for <code>ST_Affine(geomA, cos(rotRadians), 0, sin(rotRadians), 0, 1, 0, -sin(rotRadians), 0, cos(rotRadians), 0, 0, 0)</code>.</para></note>
<para role="availability" conformance="1.1.2.">Availability: 1.1.2. Name changed from RotateY to ST_RotateY in 1.2.2</para>
<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para>&P_support;</para>
<para>&Z_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
--Rotate a line 90 degrees along y-axis
SELECT ST_AsEWKT(ST_RotateY(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
st_asewkt
---------------------------
LINESTRING(3 2 -1,1 1 -1)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Affine"/>, <xref linkend="ST_RotateX"/>, <xref linkend="ST_RotateZ"/></para>
</refsection>
</refentry>
<refentry xml:id="ST_RotateZ">
<refnamediv>
<refname>ST_RotateZ</refname>
<refpurpose>Rotates a geometry about the Z axis.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_RotateZ</function></funcdef>
<paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Rotates a geometry geomA - rotRadians about the Z axis.</para>
<note><para>This is a synonym for ST_Rotate</para></note>
<note><para><code>ST_RotateZ(geomA, rotRadians)</code>
is short-hand for <code>SELECT ST_Affine(geomA, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0, 1, 0, 0, 0)</code>.</para></note>
<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para role="availability" conformance="1.1.2.">Availability: 1.1.2. Name changed from RotateZ to ST_RotateZ in 1.2.2</para>
<note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</para></note>
<para>&Z_support;</para>
<para>&curve_support;</para>
<para>&P_support;</para>
<para>&T_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>
--Rotate a line 90 degrees along z-axis
SELECT ST_AsEWKT(ST_RotateZ(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
st_asewkt
---------------------------
LINESTRING(-2 1 3,-1 1 1)
--Rotate a curved circle around z-axis
SELECT ST_AsEWKT(ST_RotateZ(geom, pi()/2))
FROM (SELECT ST_LineToCurve(ST_Buffer(ST_GeomFromText('POINT(234 567)'), 3)) As geom) As foo;
st_asewkt
----------------------------------------------------------------------------------------------------------------------------
CURVEPOLYGON(CIRCULARSTRING(-567 237,-564.87867965644 236.12132034356,-564 234,-569.12132034356 231.87867965644,-567 237))
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Affine"/>, <xref linkend="ST_RotateX"/>, <xref linkend="ST_RotateY"/></para>
</refsection>
</refentry>
<refentry xml:id="ST_Scale">
<refnamediv>
<refname>ST_Scale</refname>
<refpurpose>Scales a geometry by given factors.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_Scale</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
<paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
<paramdef><type>float</type> <parameter>ZFactor</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Scale</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
<paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Scale</function></funcdef>
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>factor</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Scale</function></funcdef>
<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>factor</parameter></paramdef>
<paramdef><type>geometry</type> <parameter>origin</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Scales the geometry to a new size by multiplying the
ordinates with the corresponding factor parameters.
</para>
<para>
The version taking a geometry as the <varname>factor</varname> parameter
allows passing a 2d, 3dm, 3dz or 4d point to set scaling factor for all
supported dimensions. Missing dimensions in the <varname>factor</varname>
point are equivalent to no scaling the corresponding dimension.
</para>
<para>
The three-geometry variant allows a "false origin" for the scaling to be passed in. This allows "scaling in place", for example using the centroid of the geometry as the false origin. Without a false origin, scaling takes place relative to the actual origin, so all coordinates are just multiplied by the scale factor.
</para>
<note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</para></note>
<para role="availability" conformance="1.1.0.">Availability: 1.1.0.</para>
<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
<para role="enhanced" conformance="2.2.0">Enhanced: 2.2.0 support for scaling all dimension (<varname>factor</varname> parameter) was introduced.</para>
<para role="enhanced" conformance="2.5.0">Enhanced: 2.5.0 support for scaling relative to a local origin (<varname>origin</varname> parameter) was introduced.</para>
<para>&P_support;</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
<para>&T_support;</para>
<para>&M_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>--Version 1: scale X, Y, Z
SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75, 0.8));
st_asewkt
--------------------------------------
LINESTRING(0.5 1.5 2.4,0.5 0.75 0.8)
--Version 2: Scale X Y
SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75));
st_asewkt
----------------------------------
LINESTRING(0.5 1.5 3,0.5 0.75 1)
--Version 3: Scale X Y Z M
SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3 4, 1 1 1 1)'),
ST_MakePoint(0.5, 0.75, 2, -1)));
st_asewkt
----------------------------------------
LINESTRING(0.5 1.5 6 -4,0.5 0.75 2 -1)
--Version 4: Scale X Y using false origin
SELECT ST_AsText(ST_Scale('LINESTRING(1 1, 2 2)', 'POINT(2 2)', 'POINT(1 1)'::geometry));
st_astext
---------------------
LINESTRING(1 1,3 3)
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Affine"/>, <xref linkend="ST_TransScale"/></para>
</refsection>
</refentry>
<refentry xml:id="ST_Translate">
<refnamediv>
<refname>ST_Translate</refname>
<refpurpose>Translates a geometry by given offsets.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_Translate</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>float </type> <parameter>deltax</parameter></paramdef>
<paramdef><type>float </type> <parameter>deltay</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>geometry <function>ST_Translate</function></funcdef>
<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
<paramdef><type>float </type> <parameter>deltax</parameter></paramdef>
<paramdef><type>float </type> <parameter>deltay</parameter></paramdef>
<paramdef><type>float </type> <parameter>deltaz</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Returns a new geometry whose coordinates are translated delta x,delta y,delta z units. Units are
based on the units defined in spatial reference (SRID) for this geometry.</para>
<note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</para></note>
<para role="availability" conformance="1.2.2">Availability: 1.2.2</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<para>Move a point 1 degree longitude</para>
<programlisting>
SELECT ST_AsText(ST_Translate(ST_GeomFromText('POINT(-71.01 42.37)',4326),1,0)) As wgs_transgeomtxt;
wgs_transgeomtxt
---------------------
POINT(-70.01 42.37)
</programlisting>
<para>Move a linestring 1 degree longitude and 1/2 degree latitude</para>
<programlisting>SELECT ST_AsText(ST_Translate(ST_GeomFromText('LINESTRING(-71.01 42.37,-71.11 42.38)',4326),1,0.5)) As wgs_transgeomtxt;
wgs_transgeomtxt
---------------------------------------
LINESTRING(-70.01 42.87,-70.11 42.88)
</programlisting>
<para>Move a 3d point</para>
<programlisting>SELECT ST_AsEWKT(ST_Translate(CAST('POINT(0 0 0)' As geometry), 5, 12,3));
st_asewkt
---------
POINT(5 12 3)
</programlisting>
<para>Move a curve and a point</para>
<programlisting>SELECT ST_AsText(ST_Translate(ST_Collect('CURVEPOLYGON(CIRCULARSTRING(4 3,3.12 0.878,1 0,-1.121 5.1213,6 7, 8 9,4 3))','POINT(1 3)'),1,2));
st_astext
------------------------------------------------------------------------------------------------------------
GEOMETRYCOLLECTION(CURVEPOLYGON(CIRCULARSTRING(5 5,4.12 2.878,2 2,-0.121 7.1213,7 9,9 11,5 5)),POINT(2 5))
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Affine"/>, <xref linkend="ST_AsText"/>, <xref linkend="ST_GeomFromText"/></para>
</refsection>
</refentry>
<refentry xml:id="ST_TransScale">
<refnamediv>
<refname>ST_TransScale</refname>
<refpurpose>Translates and scales a geometry by given offsets and factors.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
<funcdef>geometry <function>ST_TransScale</function></funcdef>
<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
<paramdef><type>float</type> <parameter>deltaX</parameter></paramdef>
<paramdef><type>float</type> <parameter>deltaY</parameter></paramdef>
<paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
<paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>Translates the geometry using the deltaX and deltaY args,
then scales it using the XFactor, YFactor args, working in 2D only.</para>
<note><para><code>ST_TransScale(geomA, deltaX, deltaY, XFactor, YFactor)</code>
is short-hand for <code>ST_Affine(geomA, XFactor, 0, 0, 0, YFactor, 0,
0, 0, 1, deltaX*XFactor, deltaY*YFactor, 0)</code>.</para></note>
<note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+</para></note>
<para role="availability" conformance="1.1.0.">Availability: 1.1.0.</para>
<para>&Z_support;</para>
<para>&curve_support;</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting>SELECT ST_AsEWKT(ST_TransScale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 1, 1, 2));
st_asewkt
-----------------------------
LINESTRING(1.5 6 3,1.5 4 1)
--Buffer a point to get an approximation of a circle, convert to curve and then translate 1,2 and scale it 3,4
SELECT ST_AsText(ST_Transscale(ST_LineToCurve(ST_Buffer('POINT(234 567)', 3)),1,2,3,4));
st_astext
------------------------------------------------------------------------------------------------------------------------------
CURVEPOLYGON(CIRCULARSTRING(714 2276,711.363961030679 2267.51471862576,705 2264,698.636038969321 2284.48528137424,714 2276))
</programlisting>
</refsection>
<!-- Optionally add a "See Also" section -->
<refsection>
<title>See Also</title>
<para><xref linkend="ST_Affine"/>, <xref linkend="ST_Translate"/></para>
</refsection>
</refentry>
</section>
|