PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwgeom_scale()

static void test_lwgeom_scale ( void  )
static

Definition at line 1045 of file cu_libgeom.c.

References ASSERT_DOUBLE_EQUAL, ASSERT_STRING_EQUAL, LWGEOM::bbox, LW_PARSER_CHECK_NONE, lwfree(), lwgeom_add_bbox(), lwgeom_free(), lwgeom_from_wkt(), lwgeom_scale(), lwgeom_to_ewkt(), POINT4D::m, GBOX::mmax, GBOX::mmin, test_gbox_same_2d(), POINT4D::x, GBOX::xmax, GBOX::xmin, POINT4D::y, GBOX::ymax, GBOX::ymin, POINT4D::z, GBOX::zmax, and GBOX::zmin.

Referenced by libgeom_suite_setup().

1046 {
1047  LWGEOM *geom;
1048  POINT4D factor;
1049  char *out_ewkt;
1050  GBOX *box;
1051 
1052  geom = lwgeom_from_wkt("SRID=4326;GEOMETRYCOLLECTION(POINT(0 1 2 3),POLYGON((-1 -1 0 1,-1 2.5 0 1,2 2 0 1,2 -1 0 1,-1 -1 0 1),(0 0 1 2,0 1 1 2,1 1 1 2,1 0 2 3,0 0 1 2)),LINESTRING(0 0 0 0, 1 2 3 4))", LW_PARSER_CHECK_NONE);
1053  factor.x = 2; factor.y = 3; factor.z = 4; factor.m = 5;
1054  lwgeom_scale(geom, &factor);
1055  out_ewkt = lwgeom_to_ewkt(geom);
1056  ASSERT_STRING_EQUAL(out_ewkt, "SRID=4326;GEOMETRYCOLLECTION(POINT(0 3 8 15),POLYGON((-2 -3 0 5,-2 7.5 0 5,4 6 0 5,4 -3 0 5,-2 -3 0 5),(0 0 4 10,0 3 4 10,2 3 4 10,2 0 8 15,0 0 4 10)),LINESTRING(0 0 0 0,2 6 12 20))");
1057  lwgeom_free(geom);
1058  lwfree(out_ewkt);
1059 
1060  geom = lwgeom_from_wkt("POINT(1 1 1 1)", LW_PARSER_CHECK_NONE);
1061  lwgeom_add_bbox(geom);
1062  factor.x = 2; factor.y = 3; factor.z = 4; factor.m = 5;
1063  lwgeom_scale(geom, &factor);
1064  box = geom->bbox;
1065  ASSERT_DOUBLE_EQUAL(box->xmin, 2);
1066  ASSERT_DOUBLE_EQUAL(box->xmax, 2);
1067  ASSERT_DOUBLE_EQUAL(box->ymin, 3);
1068  ASSERT_DOUBLE_EQUAL(box->ymax, 3);
1069  ASSERT_DOUBLE_EQUAL(box->zmin, 4);
1070  ASSERT_DOUBLE_EQUAL(box->zmax, 4);
1071  ASSERT_DOUBLE_EQUAL(box->mmin, 5);
1072  ASSERT_DOUBLE_EQUAL(box->mmax, 5);
1073  lwgeom_free(geom);
1074 }
double x
Definition: liblwgeom.h:352
GBOX * bbox
Definition: liblwgeom.h:398
double m
Definition: liblwgeom.h:352
void lwfree(void *mem)
Definition: lwutil.c:244
#define ASSERT_STRING_EQUAL(o, e)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:518
double xmax
Definition: liblwgeom.h:293
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
void lwgeom_scale(LWGEOM *geom, const POINT4D *factors)
Definition: lwgeom.c:1786
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
double xmin
Definition: liblwgeom.h:292
double ymax
Definition: liblwgeom.h:295
double z
Definition: liblwgeom.h:352
double mmin
Definition: liblwgeom.h:298
double zmin
Definition: liblwgeom.h:296
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:648
double mmax
Definition: liblwgeom.h:299
#define ASSERT_DOUBLE_EQUAL(o, e)
double y
Definition: liblwgeom.h:352
Here is the call graph for this function:
Here is the caller graph for this function: