PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_scale()

void lwgeom_scale ( LWGEOM geom,
const POINT4D factor 
)

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

1787 {
1788  int type = geom->type;
1789  int i;
1790 
1791  switch(type)
1792  {
1793  /* Take advantage of fact tht pt/ln/circ/tri have same memory structure */
1794  case POINTTYPE:
1795  case LINETYPE:
1796  case CIRCSTRINGTYPE:
1797  case TRIANGLETYPE:
1798  {
1799  LWLINE *l = (LWLINE*)geom;
1800  ptarray_scale(l->points, factor);
1801  break;
1802  }
1803  case POLYGONTYPE:
1804  {
1805  LWPOLY *p = (LWPOLY*)geom;
1806  for( i = 0; i < p->nrings; i++ )
1807  ptarray_scale(p->rings[i], factor);
1808  break;
1809  }
1810  case CURVEPOLYTYPE:
1811  {
1812  LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
1813  for( i = 0; i < c->nrings; i++ )
1814  lwgeom_scale(c->rings[i], factor);
1815  break;
1816  }
1817  default:
1818  {
1819  if( lwgeom_is_collection(geom) )
1820  {
1821  LWCOLLECTION *c = (LWCOLLECTION*)geom;
1822  for( i = 0; i < c->ngeoms; i++ )
1823  {
1824  lwgeom_scale(c->geoms[i], factor);
1825  }
1826  }
1827  else
1828  {
1829  lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
1830  }
1831  }
1832  }
1833 
1834  /* Recompute bbox if needed */
1835 
1836  if ( geom->bbox )
1837  {
1838  /* TODO: expose a gbox_scale function */
1839  geom->bbox->xmin *= factor->x;
1840  geom->bbox->xmax *= factor->x;
1841  geom->bbox->ymin *= factor->y;
1842  geom->bbox->ymax *= factor->y;
1843  geom->bbox->zmin *= factor->z;
1844  geom->bbox->zmax *= factor->z;
1845  geom->bbox->mmin *= factor->m;
1846  geom->bbox->mmax *= factor->m;
1847  }
1848 }
double x
Definition: liblwgeom.h:352
#define LINETYPE
Definition: liblwgeom.h:86
GBOX * bbox
Definition: liblwgeom.h:398
double m
Definition: liblwgeom.h:352
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition: lwgeom.c:1786
LWGEOM ** rings
Definition: liblwgeom.h:535
void ptarray_scale(POINTARRAY *pa, const POINT4D *factor)
Scale a pointarray.
Definition: ptarray.c:1851
#define POLYGONTYPE
Definition: liblwgeom.h:87
double xmax
Definition: liblwgeom.h:293
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define TRIANGLETYPE
Definition: liblwgeom.h:98
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
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:292
LWGEOM ** geoms
Definition: liblwgeom.h:509
POINTARRAY ** rings
Definition: liblwgeom.h:457
int nrings
Definition: liblwgeom.h:455
double ymax
Definition: liblwgeom.h:295
double z
Definition: liblwgeom.h:352
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition: lwgeom.c:1040
double mmin
Definition: liblwgeom.h:298
double zmin
Definition: liblwgeom.h:296
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
type
Definition: ovdump.py:41
double mmax
Definition: liblwgeom.h:299
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
double y
Definition: liblwgeom.h:352
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: