PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_gdal_rasterize()

static void test_gdal_rasterize ( )
static

Definition at line 49 of file cu_gdal.c.

References cu_free_raster(), PT_8BUI, rtrowdump::raster, rt_raster_gdal_rasterize(), rt_raster_get_height(), rt_raster_get_num_bands(), rt_raster_get_width(), rt_raster_get_x_offset(), rt_raster_get_y_offset(), rtalloc(), rtdealloc(), and genraster::value.

Referenced by gdal_suite_setup().

49  {
51  char srs[] = "PROJCS[\"unnamed\",GEOGCS[\"unnamed ellipse\",DATUM[\"unknown\",SPHEROID[\"unnamed\",6370997,0]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"latitude_of_center\",45],PARAMETER[\"longitude_of_center\",-100],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"2163\"]]";
52  const char wkb_hex[] = "010300000001000000050000000000000080841ec100000000600122410000000080841ec100000000804f22410000000040e81dc100000000804f22410000000040e81dc100000000600122410000000080841ec10000000060012241";
53  const char *pos = wkb_hex;
54  unsigned char *wkb = NULL;
55  int wkb_len = 0;
56  int i;
57  double scale_x = 100;
58  double scale_y = -100;
59 
60  rt_pixtype pixtype[] = {PT_8BUI};
61  double init[] = {0};
62  double value[] = {1};
63  double nodata[] = {0};
64  uint8_t nodata_mask[] = {1};
65 
66  /* hex to byte */
67  wkb_len = (int) ceil(((double) strlen(wkb_hex)) / 2);
68  wkb = (unsigned char *) rtalloc(sizeof(unsigned char) * wkb_len);
69  for (i = 0; i < wkb_len; i++) {
70  sscanf(pos, "%2hhx", &wkb[i]);
71  pos += 2;
72  }
73 
74  raster = rt_raster_gdal_rasterize(
75  wkb,
76  wkb_len, srs,
77  1, pixtype,
78  init, value,
79  nodata, nodata_mask,
80  NULL, NULL,
81  &scale_x, &scale_y,
82  NULL, NULL,
83  NULL, NULL,
84  NULL, NULL,
85  NULL
86  );
87 
88  CU_ASSERT(raster != NULL);
89  CU_ASSERT_EQUAL(rt_raster_get_width(raster), 100);
90  CU_ASSERT_EQUAL(rt_raster_get_height(raster), 100);
91  CU_ASSERT_NOT_EQUAL(rt_raster_get_num_bands(raster), 0);
92  CU_ASSERT_DOUBLE_EQUAL(rt_raster_get_x_offset(raster), -500000, DBL_EPSILON);
93  CU_ASSERT_DOUBLE_EQUAL(rt_raster_get_y_offset(raster), 600000, DBL_EPSILON);
94 
95  rtdealloc(wkb);
96  cu_free_raster(raster);
97 }
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
Definition: rt_raster.c:213
int rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
raster
Be careful!! Zeros function&#39;s input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
rt_raster rt_raster_gdal_rasterize(const unsigned char *wkb, uint32_t wkb_len, const char *srs, uint32_t num_bands, rt_pixtype *pixtype, double *init, double *value, double *nodata, uint8_t *hasnodata, int *width, int *height, double *scale_x, double *scale_y, double *ul_xw, double *ul_yw, double *grid_xw, double *grid_yw, double *skew_x, double *skew_y, char **options)
Return a raster of the provided geometry.
Definition: rt_raster.c:2492
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
rt_pixtype
Definition: librtcore.h:185
void cu_free_raster(rt_raster raster)
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
void rtdealloc(void *mem)
Definition: rt_context.c:186
int value
Definition: genraster.py:61
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
unsigned char uint8_t
Definition: uthash.h:79
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
Definition: rt_raster.c:222
Here is the call graph for this function:
Here is the caller graph for this function: