PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwgeom_scale()

void lwgeom_scale ( LWGEOM geom,
const POINT4D factor 
)

Definition at line 1742 of file lwgeom.c.

References LWGEOM::bbox, CIRCSTRINGTYPE, CURVEPOLYTYPE, LWCOLLECTION::geoms, LINETYPE, lwerror(), lwgeom_is_collection(), lwtype_name(), POINT4D::m, GBOX::mmax, GBOX::mmin, LWCOLLECTION::ngeoms, LWPOLY::nrings, LWCURVEPOLY::nrings, LWLINE::points, POINTTYPE, POLYGONTYPE, ptarray_scale(), LWPOLY::rings, LWCURVEPOLY::rings, TRIANGLETYPE, ovdump::type, LWGEOM::type, POINT4D::x, GBOX::xmax, GBOX::xmin, POINT4D::y, GBOX::ymax, GBOX::ymin, POINT4D::z, GBOX::zmax, and GBOX::zmin.

Referenced by ST_Scale(), and test_lwgeom_scale().

1743 {
1744  int type = geom->type;
1745  int i;
1746 
1747  switch(type)
1748  {
1749  /* Take advantage of fact tht pt/ln/circ/tri have same memory structure */
1750  case POINTTYPE:
1751  case LINETYPE:
1752  case CIRCSTRINGTYPE:
1753  case TRIANGLETYPE:
1754  {
1755  LWLINE *l = (LWLINE*)geom;
1756  ptarray_scale(l->points, factor);
1757  break;
1758  }
1759  case POLYGONTYPE:
1760  {
1761  LWPOLY *p = (LWPOLY*)geom;
1762  for( i = 0; i < p->nrings; i++ )
1763  ptarray_scale(p->rings[i], factor);
1764  break;
1765  }
1766  case CURVEPOLYTYPE:
1767  {
1768  LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
1769  for( i = 0; i < c->nrings; i++ )
1770  lwgeom_scale(c->rings[i], factor);
1771  break;
1772  }
1773  default:
1774  {
1775  if( lwgeom_is_collection(geom) )
1776  {
1777  LWCOLLECTION *c = (LWCOLLECTION*)geom;
1778  for( i = 0; i < c->ngeoms; i++ )
1779  {
1780  lwgeom_scale(c->geoms[i], factor);
1781  }
1782  }
1783  else
1784  {
1785  lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
1786  }
1787  }
1788  }
1789 
1790  /* Recompute bbox if needed */
1791 
1792  if ( geom->bbox )
1793  {
1794  /* TODO: expose a gbox_scale function */
1795  geom->bbox->xmin *= factor->x;
1796  geom->bbox->xmax *= factor->x;
1797  geom->bbox->ymin *= factor->y;
1798  geom->bbox->ymax *= factor->y;
1799  geom->bbox->zmin *= factor->z;
1800  geom->bbox->zmax *= factor->z;
1801  geom->bbox->mmin *= factor->m;
1802  geom->bbox->mmax *= factor->m;
1803  }
1804 }
double x
Definition: liblwgeom.h:336
#define LINETYPE
Definition: liblwgeom.h:71
GBOX * bbox
Definition: liblwgeom.h:382
double m
Definition: liblwgeom.h:336
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition: lwgeom.c:1742
LWGEOM ** rings
Definition: liblwgeom.h:519
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
Scale a pointarray.
Definition: ptarray.c:1804
#define POLYGONTYPE
Definition: liblwgeom.h:72
double xmax
Definition: liblwgeom.h:277
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define TRIANGLETYPE
Definition: liblwgeom.h:83
double zmax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:278
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
double xmin
Definition: liblwgeom.h:276
LWGEOM ** geoms
Definition: liblwgeom.h:493
POINTARRAY ** rings
Definition: liblwgeom.h:441
int nrings
Definition: liblwgeom.h:439
double ymax
Definition: liblwgeom.h:279
double z
Definition: liblwgeom.h:336
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:991
double mmin
Definition: liblwgeom.h:282
double zmin
Definition: liblwgeom.h:280
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
type
Definition: ovdump.py:41
double mmax
Definition: liblwgeom.h:283
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
double y
Definition: liblwgeom.h:336
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
POINTARRAY * points
Definition: liblwgeom.h:406
Here is the call graph for this function:
Here is the caller graph for this function: