PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ lwgeom_scale()

void lwgeom_scale ( LWGEOM geom,
const POINT4D factor 
)

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

1962 {
1963  int type = geom->type;
1964  uint32_t i;
1965 
1966  switch(type)
1967  {
1968  /* Take advantage of fact tht pt/ln/circ/tri have same memory structure */
1969  case POINTTYPE:
1970  case LINETYPE:
1971  case CIRCSTRINGTYPE:
1972  case TRIANGLETYPE:
1973  {
1974  LWLINE *l = (LWLINE*)geom;
1975  ptarray_scale(l->points, factor);
1976  break;
1977  }
1978  case POLYGONTYPE:
1979  {
1980  LWPOLY *p = (LWPOLY*)geom;
1981  for( i = 0; i < p->nrings; i++ )
1982  ptarray_scale(p->rings[i], factor);
1983  break;
1984  }
1985  case CURVEPOLYTYPE:
1986  {
1987  LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
1988  for( i = 0; i < c->nrings; i++ )
1989  lwgeom_scale(c->rings[i], factor);
1990  break;
1991  }
1992  default:
1993  {
1994  if( lwgeom_is_collection(geom) )
1995  {
1996  LWCOLLECTION *c = (LWCOLLECTION*)geom;
1997  for( i = 0; i < c->ngeoms; i++ )
1998  {
1999  lwgeom_scale(c->geoms[i], factor);
2000  }
2001  }
2002  else
2003  {
2004  lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
2005  }
2006  }
2007  }
2008 
2009  /* Recompute bbox if needed */
2010 
2011  if ( geom->bbox )
2012  {
2013  /* TODO: expose a gbox_scale function */
2014  geom->bbox->xmin *= factor->x;
2015  geom->bbox->xmax *= factor->x;
2016  geom->bbox->ymin *= factor->y;
2017  geom->bbox->ymax *= factor->y;
2018  geom->bbox->zmin *= factor->z;
2019  geom->bbox->zmax *= factor->z;
2020  geom->bbox->mmin *= factor->m;
2021  geom->bbox->mmax *= factor->m;
2022  }
2023 }
double x
Definition: liblwgeom.h:354
#define LINETYPE
Definition: liblwgeom.h:85
GBOX * bbox
Definition: liblwgeom.h:400
double m
Definition: liblwgeom.h:354
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition: lwgeom.c:1961
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:1921
#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:216
double xmin
Definition: liblwgeom.h:294
LWGEOM ** geoms
Definition: liblwgeom.h:511
POINTARRAY ** rings
Definition: liblwgeom.h:459
double ymax
Definition: liblwgeom.h:297
double z
Definition: liblwgeom.h:354
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1069
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
double y
Definition: liblwgeom.h:354
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: