PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ lwgeom_scale()

void lwgeom_scale ( LWGEOM geom,
const POINT4D factors 
)

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

2021 {
2022  int type = geom->type;
2023  uint32_t i;
2024 
2025  switch(type)
2026  {
2027  /* Take advantage of fact tht pt/ln/circ/tri have same memory structure */
2028  case POINTTYPE:
2029  case LINETYPE:
2030  case CIRCSTRINGTYPE:
2031  case TRIANGLETYPE:
2032  {
2033  LWLINE *l = (LWLINE*)geom;
2034  ptarray_scale(l->points, factor);
2035  break;
2036  }
2037  case POLYGONTYPE:
2038  {
2039  LWPOLY *p = (LWPOLY*)geom;
2040  for( i = 0; i < p->nrings; i++ )
2041  ptarray_scale(p->rings[i], factor);
2042  break;
2043  }
2044  case CURVEPOLYTYPE:
2045  {
2046  LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
2047  for( i = 0; i < c->nrings; i++ )
2048  lwgeom_scale(c->rings[i], factor);
2049  break;
2050  }
2051  default:
2052  {
2053  if( lwgeom_is_collection(geom) )
2054  {
2055  LWCOLLECTION *c = (LWCOLLECTION*)geom;
2056  for( i = 0; i < c->ngeoms; i++ )
2057  {
2058  lwgeom_scale(c->geoms[i], factor);
2059  }
2060  }
2061  else
2062  {
2063  lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
2064  }
2065  }
2066  }
2067 
2068  /* Recompute bbox if needed */
2069 
2070  if ( geom->bbox )
2071  {
2072  /* TODO: expose a gbox_scale function */
2073  geom->bbox->xmin *= factor->x;
2074  geom->bbox->xmax *= factor->x;
2075  geom->bbox->ymin *= factor->y;
2076  geom->bbox->ymax *= factor->y;
2077  geom->bbox->zmin *= factor->z;
2078  geom->bbox->zmax *= factor->z;
2079  geom->bbox->mmin *= factor->m;
2080  geom->bbox->mmax *= factor->m;
2081  }
2082 }
#define LINETYPE
Definition: liblwgeom.h:85
GBOX * bbox
Definition: liblwgeom.h:400
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition: lwgeom.c:2020
LWGEOM ** rings
Definition: liblwgeom.h:537
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
WARNING, make sure you send in only 16-member double arrays or obviously things will go pear-shaped f...
Definition: ptarray.c:1983
#define POLYGONTYPE
Definition: liblwgeom.h:86
double xmax
Definition: liblwgeom.h:295
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define TRIANGLETYPE
Definition: liblwgeom.h:97
uint32_t ngeoms
Definition: liblwgeom.h:509
uint32_t nrings
Definition: liblwgeom.h:457
unsigned int uint32_t
Definition: uthash.h:78
double zmax
Definition: liblwgeom.h:299
double ymin
Definition: liblwgeom.h:296
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:294
LWGEOM ** geoms
Definition: liblwgeom.h:511
POINTARRAY ** rings
Definition: liblwgeom.h:459
double ymax
Definition: liblwgeom.h:297
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1085
double mmin
Definition: liblwgeom.h:300
double zmin
Definition: liblwgeom.h:298
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:398
type
Definition: ovdump.py:41
double mmax
Definition: liblwgeom.h:301
uint32_t nrings
Definition: liblwgeom.h:535
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:424
Here is the call graph for this function:
Here is the caller graph for this function: