PostGIS  2.5.0dev-r@@SVN_REVISION@@
void lwgeom_scale ( LWGEOM geom,
const POINT4D factor 
)

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

2014 {
2015  int type = geom->type;
2016  uint32_t i;
2017 
2018  switch(type)
2019  {
2020  /* Take advantage of fact tht pt/ln/circ/tri have same memory structure */
2021  case POINTTYPE:
2022  case LINETYPE:
2023  case CIRCSTRINGTYPE:
2024  case TRIANGLETYPE:
2025  {
2026  LWLINE *l = (LWLINE*)geom;
2027  ptarray_scale(l->points, factor);
2028  break;
2029  }
2030  case POLYGONTYPE:
2031  {
2032  LWPOLY *p = (LWPOLY*)geom;
2033  for( i = 0; i < p->nrings; i++ )
2034  ptarray_scale(p->rings[i], factor);
2035  break;
2036  }
2037  case CURVEPOLYTYPE:
2038  {
2039  LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
2040  for( i = 0; i < c->nrings; i++ )
2041  lwgeom_scale(c->rings[i], factor);
2042  break;
2043  }
2044  default:
2045  {
2046  if( lwgeom_is_collection(geom) )
2047  {
2048  LWCOLLECTION *c = (LWCOLLECTION*)geom;
2049  for( i = 0; i < c->ngeoms; i++ )
2050  {
2051  lwgeom_scale(c->geoms[i], factor);
2052  }
2053  }
2054  else
2055  {
2056  lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
2057  }
2058  }
2059  }
2060 
2061  /* Recompute bbox if needed */
2062 
2063  if ( geom->bbox )
2064  {
2065  /* TODO: expose a gbox_scale function */
2066  geom->bbox->xmin *= factor->x;
2067  geom->bbox->xmax *= factor->x;
2068  geom->bbox->ymin *= factor->y;
2069  geom->bbox->ymax *= factor->y;
2070  geom->bbox->zmin *= factor->z;
2071  geom->bbox->zmax *= factor->z;
2072  geom->bbox->mmin *= factor->m;
2073  geom->bbox->mmax *= factor->m;
2074  }
2075 }
double x
Definition: liblwgeom.h:351
#define LINETYPE
Definition: liblwgeom.h:85
GBOX * bbox
Definition: liblwgeom.h:397
double m
Definition: liblwgeom.h:351
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition: lwgeom.c:2013
LWGEOM ** rings
Definition: liblwgeom.h:534
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
Scale a pointarray.
Definition: ptarray.c:1840
#define POLYGONTYPE
Definition: liblwgeom.h:86
double xmax
Definition: liblwgeom.h:292
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define TRIANGLETYPE
Definition: liblwgeom.h:97
uint32_t ngeoms
Definition: liblwgeom.h:506
uint32_t nrings
Definition: liblwgeom.h:454
unsigned int uint32_t
Definition: uthash.h:78
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:218
double xmin
Definition: liblwgeom.h:291
LWGEOM ** geoms
Definition: liblwgeom.h:508
POINTARRAY ** rings
Definition: liblwgeom.h:456
double ymax
Definition: liblwgeom.h:294
double z
Definition: liblwgeom.h:351
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1078
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
double mmax
Definition: liblwgeom.h:298
uint32_t nrings
Definition: liblwgeom.h:532
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
double y
Definition: liblwgeom.h:351
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: