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

◆ lwgeom_scale()

void lwgeom_scale ( LWGEOM geom,
const POINT4D factor 
)

Definition at line 2165 of file lwgeom.c.

2166{
2167 int type = geom->type;
2168 uint32_t i;
2169
2170 switch(type)
2171 {
2172 /* Take advantage of fact that pt/ln/circ/tri have same memory structure */
2173 case POINTTYPE:
2174 case LINETYPE:
2175 case CIRCSTRINGTYPE:
2176 case TRIANGLETYPE:
2177 {
2178 LWLINE *l = (LWLINE*)geom;
2179 ptarray_scale(l->points, factor);
2180 break;
2181 }
2182 case POLYGONTYPE:
2183 {
2184 LWPOLY *p = (LWPOLY*)geom;
2185 for( i = 0; i < p->nrings; i++ )
2186 ptarray_scale(p->rings[i], factor);
2187 break;
2188 }
2189 case CURVEPOLYTYPE:
2190 {
2191 LWCURVEPOLY *c = (LWCURVEPOLY*)geom;
2192 for( i = 0; i < c->nrings; i++ )
2193 lwgeom_scale(c->rings[i], factor);
2194 break;
2195 }
2196 default:
2197 {
2198 if( lwgeom_is_collection(geom) )
2199 {
2200 LWCOLLECTION *c = (LWCOLLECTION*)geom;
2201 for( i = 0; i < c->ngeoms; i++ )
2202 {
2203 lwgeom_scale(c->geoms[i], factor);
2204 }
2205 }
2206 else
2207 {
2208 lwerror("lwgeom_scale: unable to handle type '%s'", lwtype_name(type));
2209 }
2210 }
2211 }
2212
2213 /* Recompute bbox if needed */
2214 if (geom->bbox)
2215 lwgeom_refresh_bbox(geom);
2216}
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:111
#define LINETYPE
Definition liblwgeom.h:103
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
#define POLYGONTYPE
Definition liblwgeom.h:104
#define CIRCSTRINGTYPE
Definition liblwgeom.h:109
#define TRIANGLETYPE
Definition liblwgeom.h:115
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:2201
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition lwgeom.c:735
int lwgeom_is_collection(const LWGEOM *geom)
Determine whether a LWGEOM contains sub-geometries or not This basically just checks that the struct ...
Definition lwgeom.c:1125
void lwgeom_scale(LWGEOM *geom, const POINT4D *factor)
Definition lwgeom.c:2165
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
uint32_t ngeoms
Definition liblwgeom.h:580
LWGEOM ** geoms
Definition liblwgeom.h:575
LWGEOM ** rings
Definition liblwgeom.h:603
uint32_t nrings
Definition liblwgeom.h:608
uint8_t type
Definition liblwgeom.h:462
GBOX * bbox
Definition liblwgeom.h:458
POINTARRAY * points
Definition liblwgeom.h:483
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524

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: