PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_gdal_rasterize()

static void test_gdal_rasterize ( )
static

Definition at line 49 of file cu_gdal.c.

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  int b = 0;
71  sscanf(pos, "%2x", &b);
72  wkb[i] = (unsigned char)b;
73  pos += 2;
74  }
75 
77  wkb,
78  wkb_len, srs,
79  1, pixtype,
80  init, value,
81  nodata, nodata_mask,
82  NULL, NULL,
83  &scale_x, &scale_y,
84  NULL, NULL,
85  NULL, NULL,
86  NULL, NULL,
87  NULL
88  );
89 
90  CU_ASSERT(raster != NULL);
91  CU_ASSERT_EQUAL(rt_raster_get_width(raster), 100);
92  CU_ASSERT_EQUAL(rt_raster_get_height(raster), 100);
93  CU_ASSERT_NOT_EQUAL(rt_raster_get_num_bands(raster), 0);
94  CU_ASSERT_DOUBLE_EQUAL(rt_raster_get_x_offset(raster), -500000, DBL_EPSILON);
95  CU_ASSERT_DOUBLE_EQUAL(rt_raster_get_y_offset(raster), 600000, DBL_EPSILON);
96 
97  rtdealloc(wkb);
99 }
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
Definition: rt_raster.c:213
rt_pixtype
Definition: librtcore.h:185
@ PT_8BUI
Definition: librtcore.h:190
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:2509
uint16_t rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
void rtdealloc(void *mem)
Definition: rt_context.c:186
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
Definition: rt_raster.c:222
int value
Definition: genraster.py:61
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
void cu_free_raster(rt_raster raster)
unsigned char uint8_t
Definition: uthash.h:79

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().

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