PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwgeom_scale()

void lwgeom_scale ( LWGEOM geom,
const POINT4D factors 
)

Definition at line 1755 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().

1756 {
1757  int type = geom->type;
1758  int i;
1759 
1760  switch(type)
1761  {
1762  /* Take advantage of fact tht pt/ln/circ/tri have same memory structure */
1763  case POINTTYPE:
1764  case LINETYPE:
1765  case CIRCSTRINGTYPE:
1766  case TRIANGLETYPE:
1767  {
1768  LWLINE *l = (LWLINE*)geom;
1769  ptarray_scale(l->points, factor);
1770  break;
1771  }
1772  case POLYGONTYPE:
1773  {
1774  LWPOLY *p = (LWPOLY*)geom;
1775  for( i = 0; i < p->nrings; i++ )
1776  ptarray_scale(p->rings[i], factor);
1777  break;
1778  }
1779  case CURVEPOLYTYPE:
1780  {
1781  LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
1782  for( i = 0; i < c->nrings; i++ )
1783  lwgeom_scale(c->rings[i], factor);
1784  break;
1785  }
1786  default:
1787  {
1788  if( lwgeom_is_collection(geom) )
1789  {
1790  LWCOLLECTION *c = (LWCOLLECTION*)geom;
1791  for( i = 0; i < c->ngeoms; i++ )
1792  {
1793  lwgeom_scale(c->geoms[i], factor);
1794  }
1795  }
1796  else
1797  {
1798  lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
1799  }
1800  }
1801  }
1802 
1803  /* Recompute bbox if needed */
1804 
1805  if ( geom->bbox )
1806  {
1807  /* TODO: expose a gbox_scale function */
1808  geom->bbox->xmin *= factor->x;
1809  geom->bbox->xmax *= factor->x;
1810  geom->bbox->ymin *= factor->y;
1811  geom->bbox->ymax *= factor->y;
1812  geom->bbox->zmin *= factor->z;
1813  geom->bbox->zmax *= factor->z;
1814  geom->bbox->mmin *= factor->m;
1815  geom->bbox->mmax *= factor->m;
1816  }
1817 }
#define LINETYPE
Definition: liblwgeom.h:85
GBOX * bbox
Definition: liblwgeom.h:397
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition: lwgeom.c:1755
LWGEOM ** rings
Definition: liblwgeom.h:534
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
Scale a pointarray.
Definition: ptarray.c:1811
#define POLYGONTYPE
Definition: liblwgeom.h:86
double xmax
Definition: liblwgeom.h:292
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define TRIANGLETYPE
Definition: liblwgeom.h:97
double zmax
Definition: liblwgeom.h:296
double ymin
Definition: liblwgeom.h:293
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
double xmin
Definition: liblwgeom.h:291
LWGEOM ** geoms
Definition: liblwgeom.h:508
POINTARRAY ** rings
Definition: liblwgeom.h:456
int nrings
Definition: liblwgeom.h:454
double ymax
Definition: liblwgeom.h:294
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1004
double mmin
Definition: liblwgeom.h:297
double zmin
Definition: liblwgeom.h:295
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:395
type
Definition: ovdump.py:41
double mmax
Definition: liblwgeom.h:298
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
POINTARRAY * points
Definition: liblwgeom.h:421
Here is the call graph for this function:
Here is the caller graph for this function: