PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwgeom_scale()

void lwgeom_scale ( LWGEOM geom,
const POINT4D factor 
)

Definition at line 2029 of file lwgeom.c.

2030{
2031 int type = geom->type;
2032 uint32_t i;
2033
2034 switch(type)
2035 {
2036 /* Take advantage of fact tht pt/ln/circ/tri have same memory structure */
2037 case POINTTYPE:
2038 case LINETYPE:
2039 case CIRCSTRINGTYPE:
2040 case TRIANGLETYPE:
2041 {
2042 LWLINE *l = (LWLINE*)geom;
2043 ptarray_scale(l->points, factor);
2044 break;
2045 }
2046 case POLYGONTYPE:
2047 {
2048 LWPOLY *p = (LWPOLY*)geom;
2049 for( i = 0; i < p->nrings; i++ )
2050 ptarray_scale(p->rings[i], factor);
2051 break;
2052 }
2053 case CURVEPOLYTYPE:
2054 {
2055 LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
2056 for( i = 0; i < c->nrings; i++ )
2057 lwgeom_scale(c->rings[i], factor);
2058 break;
2059 }
2060 default:
2061 {
2062 if( lwgeom_is_collection(geom) )
2063 {
2064 LWCOLLECTION *c = (LWCOLLECTION*)geom;
2065 for( i = 0; i < c->ngeoms; i++ )
2066 {
2067 lwgeom_scale(c->geoms[i], factor);
2068 }
2069 }
2070 else
2071 {
2072 lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
2073 }
2074 }
2075 }
2076
2077 /* Recompute bbox if needed */
2078 if (geom->bbox)
2079 lwgeom_refresh_bbox(geom);
2080}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define CURVEPOLYTYPE
Definition liblwgeom.h:125
#define LINETYPE
Definition liblwgeom.h:117
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:116
#define POLYGONTYPE
Definition liblwgeom.h:118
#define CIRCSTRINGTYPE
Definition liblwgeom.h:123
#define TRIANGLETYPE
Definition liblwgeom.h:129
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:1953
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition lwgeom.c:689
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition lwgeom.c:1079
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition lwgeom.c:2029
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
uint32_t ngeoms
Definition liblwgeom.h:566
LWGEOM ** geoms
Definition liblwgeom.h:561
LWGEOM ** rings
Definition liblwgeom.h:589
uint32_t nrings
Definition liblwgeom.h:594
uint8_t type
Definition liblwgeom.h:448
GBOX * bbox
Definition liblwgeom.h:444
POINTARRAY * points
Definition liblwgeom.h:469
POINTARRAY ** rings
Definition liblwgeom.h:505
uint32_t nrings
Definition liblwgeom.h:510

References LWGEOM::bbox, CIRCSTRINGTYPE, CURVEPOLYTYPE, LWCOLLECTION::geoms, LINETYPE, lwerror(), lwgeom_is_collection(), lwgeom_refresh_bbox(), lwgeom_scale(), lwtype_name(), LWCOLLECTION::ngeoms, LWPOLY::nrings, LWCURVEPOLY::nrings, LWLINE::points, POINTTYPE, POLYGONTYPE, ptarray_scale(), LWPOLY::rings, LWCURVEPOLY::rings, TRIANGLETYPE, and LWGEOM::type.

Referenced by lwgeom_scale(), ST_Scale(), and test_lwgeom_scale().

Here is the call graph for this function:
Here is the caller graph for this function: