PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum RASTER_asRaster ( PG_FUNCTION_ARGS  )

Definition at line 11895 of file rt_pg.c.

References clamp_srid(), FLT_NEQ, gserialized_get_srid(), lwgeom_force_2d(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_is_empty(), lwgeom_ndims(), lwgeom_to_wkb(), MIN, POSTGIS_RT_DEBUG, POSTGIS_RT_DEBUGF, PT_64BF, PT_END, rtpixdump::rast, rt_pixtype_index_from_name(), rt_raster_destroy(), rt_raster_gdal_rasterize(), rt_raster_new(), rt_raster_serialize(), rt_raster_set_srid(), rtpg_getSR(), rtpg_trim(), rt_raster_serialized_t::size, SRID_UNKNOWN, TRUE, and WKB_SFSQL.

11896 {
11897  GSERIALIZED *gser = NULL;
11898 
11899  LWGEOM *geom = NULL;
11900  rt_raster rast = NULL;
11901  rt_pgraster *pgrast = NULL;
11902 
11903  unsigned char *wkb;
11904  size_t wkb_len = 0;
11905  unsigned char variant = WKB_SFSQL;
11906 
11907  double scale[2] = {0};
11908  double *scale_x = NULL;
11909  double *scale_y = NULL;
11910 
11911  int dim[2] = {0};
11912  int *dim_x = NULL;
11913  int *dim_y = NULL;
11914 
11915  ArrayType *array;
11916  Oid etype;
11917  Datum *e;
11918  bool *nulls;
11919  int16 typlen;
11920  bool typbyval;
11921  char typalign;
11922  int n = 0;
11923  int i = 0;
11924  int j = 0;
11925  int haserr = 0;
11926 
11927  text *pixeltypetext = NULL;
11928  char *pixeltype = NULL;
11929  rt_pixtype pixtype = PT_END;
11930  rt_pixtype *pixtypes = NULL;
11931  int pixtypes_len = 0;
11932 
11933  double *values = NULL;
11934  int values_len = 0;
11935 
11936  uint8_t *hasnodatas = NULL;
11937  double *nodatavals = NULL;
11938  int nodatavals_len = 0;
11939 
11940  double ulw[2] = {0};
11941  double *ul_xw = NULL;
11942  double *ul_yw = NULL;
11943 
11944  double gridw[2] = {0};
11945  double *grid_xw = NULL;
11946  double *grid_yw = NULL;
11947 
11948  double skew[2] = {0};
11949  double *skew_x = NULL;
11950  double *skew_y = NULL;
11951 
11952  char **options = NULL;
11953  int options_len = 0;
11954 
11955  uint32_t num_bands = 0;
11956 
11957  int srid = SRID_UNKNOWN;
11958  char *srs = NULL;
11959 
11960  POSTGIS_RT_DEBUG(3, "RASTER_asRaster: Starting");
11961 
11962  /* based upon LWGEOM_asBinary function in postgis/lwgeom_ogc.c */
11963 
11964  /* Get the geometry */
11965  if (PG_ARGISNULL(0))
11966  PG_RETURN_NULL();
11967 
11968  gser = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
11969  geom = lwgeom_from_gserialized(gser);
11970 
11971  /* Get a 2D version of the geometry if necessary */
11972  if (lwgeom_ndims(geom) > 2) {
11973  LWGEOM *geom2d = lwgeom_force_2d(geom);
11974  lwgeom_free(geom);
11975  geom = geom2d;
11976  }
11977 
11978  /* empty geometry, return empty raster */
11979  if (lwgeom_is_empty(geom)) {
11980  POSTGIS_RT_DEBUG(3, "Input geometry is empty. Returning empty raster");
11981  lwgeom_free(geom);
11982  PG_FREE_IF_COPY(gser, 0);
11983 
11984  rast = rt_raster_new(0, 0);
11985  if (rast == NULL)
11986  PG_RETURN_NULL();
11987 
11988  pgrast = rt_raster_serialize(rast);
11989  rt_raster_destroy(rast);
11990 
11991  if (NULL == pgrast)
11992  PG_RETURN_NULL();
11993 
11994  SET_VARSIZE(pgrast, pgrast->size);
11995  PG_RETURN_POINTER(pgrast);
11996  }
11997 
11998  /* scale x */
11999  if (!PG_ARGISNULL(1)) {
12000  scale[0] = PG_GETARG_FLOAT8(1);
12001  if (FLT_NEQ(scale[0], 0)) scale_x = &scale[0];
12002  }
12003 
12004  /* scale y */
12005  if (!PG_ARGISNULL(2)) {
12006  scale[1] = PG_GETARG_FLOAT8(2);
12007  if (FLT_NEQ(scale[1], 0)) scale_y = &scale[1];
12008  }
12009  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: scale (x, y) = %f, %f", scale[0], scale[1]);
12010 
12011  /* width */
12012  if (!PG_ARGISNULL(3)) {
12013  dim[0] = PG_GETARG_INT32(3);
12014  if (dim[0] < 0) dim[0] = 0;
12015  if (dim[0] != 0) dim_x = &dim[0];
12016  }
12017 
12018  /* height */
12019  if (!PG_ARGISNULL(4)) {
12020  dim[1] = PG_GETARG_INT32(4);
12021  if (dim[1] < 0) dim[1] = 0;
12022  if (dim[1] != 0) dim_y = &dim[1];
12023  }
12024  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: dim (x, y) = %d, %d", dim[0], dim[1]);
12025 
12026  /* pixeltype */
12027  if (!PG_ARGISNULL(5)) {
12028  array = PG_GETARG_ARRAYTYPE_P(5);
12029  etype = ARR_ELEMTYPE(array);
12030  get_typlenbyvalalign(etype, &typlen, &typbyval, &typalign);
12031 
12032  switch (etype) {
12033  case TEXTOID:
12034  break;
12035  default:
12036 
12037  lwgeom_free(geom);
12038  PG_FREE_IF_COPY(gser, 0);
12039 
12040  elog(ERROR, "RASTER_asRaster: Invalid data type for pixeltype");
12041  PG_RETURN_NULL();
12042  break;
12043  }
12044 
12045  deconstruct_array(array, etype, typlen, typbyval, typalign, &e,
12046  &nulls, &n);
12047 
12048  if (n) {
12049  pixtypes = (rt_pixtype *) palloc(sizeof(rt_pixtype) * n);
12050  /* clean each pixeltype */
12051  for (i = 0, j = 0; i < n; i++) {
12052  if (nulls[i]) {
12053  pixtypes[j++] = PT_64BF;
12054  continue;
12055  }
12056 
12057  pixeltype = NULL;
12058  switch (etype) {
12059  case TEXTOID:
12060  pixeltypetext = (text *) DatumGetPointer(e[i]);
12061  if (NULL == pixeltypetext) break;
12062  pixeltype = text_to_cstring(pixeltypetext);
12063 
12064  /* trim string */
12065  pixeltype = rtpg_trim(pixeltype);
12066  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: pixeltype is '%s'", pixeltype);
12067  break;
12068  }
12069 
12070  if (strlen(pixeltype)) {
12071  pixtype = rt_pixtype_index_from_name(pixeltype);
12072  if (pixtype == PT_END) {
12073 
12074  pfree(pixtypes);
12075 
12076  lwgeom_free(geom);
12077  PG_FREE_IF_COPY(gser, 0);
12078 
12079  elog(ERROR, "RASTER_asRaster: Invalid pixel type provided: %s", pixeltype);
12080  PG_RETURN_NULL();
12081  }
12082 
12083  pixtypes[j] = pixtype;
12084  j++;
12085  }
12086  }
12087 
12088  if (j > 0) {
12089  /* trim allocation */
12090  pixtypes = repalloc(pixtypes, j * sizeof(rt_pixtype));
12091  pixtypes_len = j;
12092  }
12093  else {
12094  pfree(pixtypes);
12095  pixtypes = NULL;
12096  pixtypes_len = 0;
12097  }
12098  }
12099  }
12100 #if POSTGIS_DEBUG_LEVEL > 0
12101  for (i = 0; i < pixtypes_len; i++)
12102  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: pixtypes[%d] = %d", i, (int) pixtypes[i]);
12103 #endif
12104 
12105  /* value */
12106  if (!PG_ARGISNULL(6)) {
12107  array = PG_GETARG_ARRAYTYPE_P(6);
12108  etype = ARR_ELEMTYPE(array);
12109  get_typlenbyvalalign(etype, &typlen, &typbyval, &typalign);
12110 
12111  switch (etype) {
12112  case FLOAT4OID:
12113  case FLOAT8OID:
12114  break;
12115  default:
12116 
12117  if (pixtypes_len) pfree(pixtypes);
12118 
12119  lwgeom_free(geom);
12120  PG_FREE_IF_COPY(gser, 0);
12121 
12122  elog(ERROR, "RASTER_asRaster: Invalid data type for value");
12123  PG_RETURN_NULL();
12124  break;
12125  }
12126 
12127  deconstruct_array(array, etype, typlen, typbyval, typalign, &e,
12128  &nulls, &n);
12129 
12130  if (n) {
12131  values = (double *) palloc(sizeof(double) * n);
12132  for (i = 0, j = 0; i < n; i++) {
12133  if (nulls[i]) {
12134  values[j++] = 1;
12135  continue;
12136  }
12137 
12138  switch (etype) {
12139  case FLOAT4OID:
12140  values[j] = (double) DatumGetFloat4(e[i]);
12141  break;
12142  case FLOAT8OID:
12143  values[j] = (double) DatumGetFloat8(e[i]);
12144  break;
12145  }
12146  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: values[%d] = %f", j, values[j]);
12147 
12148  j++;
12149  }
12150 
12151  if (j > 0) {
12152  /* trim allocation */
12153  values = repalloc(values, j * sizeof(double));
12154  values_len = j;
12155  }
12156  else {
12157  pfree(values);
12158  values = NULL;
12159  values_len = 0;
12160  }
12161  }
12162  }
12163 #if POSTGIS_DEBUG_LEVEL > 0
12164  for (i = 0; i < values_len; i++)
12165  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: values[%d] = %f", i, values[i]);
12166 #endif
12167 
12168  /* nodataval */
12169  if (!PG_ARGISNULL(7)) {
12170  array = PG_GETARG_ARRAYTYPE_P(7);
12171  etype = ARR_ELEMTYPE(array);
12172  get_typlenbyvalalign(etype, &typlen, &typbyval, &typalign);
12173 
12174  switch (etype) {
12175  case FLOAT4OID:
12176  case FLOAT8OID:
12177  break;
12178  default:
12179 
12180  if (pixtypes_len) pfree(pixtypes);
12181  if (values_len) pfree(values);
12182 
12183  lwgeom_free(geom);
12184  PG_FREE_IF_COPY(gser, 0);
12185 
12186  elog(ERROR, "RASTER_asRaster: Invalid data type for nodataval");
12187  PG_RETURN_NULL();
12188  break;
12189  }
12190 
12191  deconstruct_array(array, etype, typlen, typbyval, typalign, &e,
12192  &nulls, &n);
12193 
12194  if (n) {
12195  nodatavals = (double *) palloc(sizeof(double) * n);
12196  hasnodatas = (uint8_t *) palloc(sizeof(uint8_t) * n);
12197  for (i = 0, j = 0; i < n; i++) {
12198  if (nulls[i]) {
12199  hasnodatas[j] = 0;
12200  nodatavals[j] = 0;
12201  j++;
12202  continue;
12203  }
12204 
12205  hasnodatas[j] = 1;
12206  switch (etype) {
12207  case FLOAT4OID:
12208  nodatavals[j] = (double) DatumGetFloat4(e[i]);
12209  break;
12210  case FLOAT8OID:
12211  nodatavals[j] = (double) DatumGetFloat8(e[i]);
12212  break;
12213  }
12214  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: hasnodatas[%d] = %d", j, hasnodatas[j]);
12215  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: nodatavals[%d] = %f", j, nodatavals[j]);
12216 
12217  j++;
12218  }
12219 
12220  if (j > 0) {
12221  /* trim allocation */
12222  nodatavals = repalloc(nodatavals, j * sizeof(double));
12223  hasnodatas = repalloc(hasnodatas, j * sizeof(uint8_t));
12224  nodatavals_len = j;
12225  }
12226  else {
12227  pfree(nodatavals);
12228  pfree(hasnodatas);
12229  nodatavals = NULL;
12230  hasnodatas = NULL;
12231  nodatavals_len = 0;
12232  }
12233  }
12234  }
12235 #if POSTGIS_DEBUG_LEVEL > 0
12236  for (i = 0; i < nodatavals_len; i++) {
12237  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: hasnodatas[%d] = %d", i, hasnodatas[i]);
12238  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: nodatavals[%d] = %f", i, nodatavals[i]);
12239  }
12240 #endif
12241 
12242  /* upperleftx */
12243  if (!PG_ARGISNULL(8)) {
12244  ulw[0] = PG_GETARG_FLOAT8(8);
12245  ul_xw = &ulw[0];
12246  }
12247 
12248  /* upperlefty */
12249  if (!PG_ARGISNULL(9)) {
12250  ulw[1] = PG_GETARG_FLOAT8(9);
12251  ul_yw = &ulw[1];
12252  }
12253  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: upperleft (x, y) = %f, %f", ulw[0], ulw[1]);
12254 
12255  /* gridx */
12256  if (!PG_ARGISNULL(10)) {
12257  gridw[0] = PG_GETARG_FLOAT8(10);
12258  grid_xw = &gridw[0];
12259  }
12260 
12261  /* gridy */
12262  if (!PG_ARGISNULL(11)) {
12263  gridw[1] = PG_GETARG_FLOAT8(11);
12264  grid_yw = &gridw[1];
12265  }
12266  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: grid (x, y) = %f, %f", gridw[0], gridw[1]);
12267 
12268  /* check dependent variables */
12269  haserr = 0;
12270  do {
12271  /* only part of scale provided */
12272  if (
12273  (scale_x == NULL && scale_y != NULL) ||
12274  (scale_x != NULL && scale_y == NULL)
12275  ) {
12276  elog(NOTICE, "Values must be provided for both X and Y of scale if one is specified");
12277  haserr = 1;
12278  break;
12279  }
12280 
12281  /* only part of dimension provided */
12282  if (
12283  (dim_x == NULL && dim_y != NULL) ||
12284  (dim_x != NULL && dim_y == NULL)
12285  ) {
12286  elog(NOTICE, "Values must be provided for both width and height if one is specified");
12287  haserr = 1;
12288  break;
12289  }
12290 
12291  /* scale and dimension provided */
12292  if (
12293  (scale_x != NULL && scale_y != NULL) &&
12294  (dim_x != NULL && dim_y != NULL)
12295  ) {
12296  elog(NOTICE, "Values provided for X and Y of scale and width and height. Using the width and height");
12297  scale_x = NULL;
12298  scale_y = NULL;
12299  break;
12300  }
12301 
12302  /* neither scale or dimension provided */
12303  if (
12304  (scale_x == NULL && scale_y == NULL) &&
12305  (dim_x == NULL && dim_y == NULL)
12306  ) {
12307  elog(NOTICE, "Values must be provided for X and Y of scale or width and height");
12308  haserr = 1;
12309  break;
12310  }
12311 
12312  /* only part of upper-left provided */
12313  if (
12314  (ul_xw == NULL && ul_yw != NULL) ||
12315  (ul_xw != NULL && ul_yw == NULL)
12316  ) {
12317  elog(NOTICE, "Values must be provided for both X and Y when specifying the upper-left corner");
12318  haserr = 1;
12319  break;
12320  }
12321 
12322  /* only part of alignment provided */
12323  if (
12324  (grid_xw == NULL && grid_yw != NULL) ||
12325  (grid_xw != NULL && grid_yw == NULL)
12326  ) {
12327  elog(NOTICE, "Values must be provided for both X and Y when specifying the alignment");
12328  haserr = 1;
12329  break;
12330  }
12331 
12332  /* upper-left and alignment provided */
12333  if (
12334  (ul_xw != NULL && ul_yw != NULL) &&
12335  (grid_xw != NULL && grid_yw != NULL)
12336  ) {
12337  elog(NOTICE, "Values provided for both X and Y of upper-left corner and alignment. Using the values of upper-left corner");
12338  grid_xw = NULL;
12339  grid_yw = NULL;
12340  break;
12341  }
12342  }
12343  while (0);
12344 
12345  if (haserr) {
12346  if (pixtypes_len) pfree(pixtypes);
12347  if (values_len) pfree(values);
12348  if (nodatavals_len) {
12349  pfree(nodatavals);
12350  pfree(hasnodatas);
12351  }
12352 
12353  lwgeom_free(geom);
12354  PG_FREE_IF_COPY(gser, 0);
12355 
12356  PG_RETURN_NULL();
12357  }
12358 
12359  /* skewx */
12360  if (!PG_ARGISNULL(12)) {
12361  skew[0] = PG_GETARG_FLOAT8(12);
12362  if (FLT_NEQ(skew[0], 0)) skew_x = &skew[0];
12363  }
12364 
12365  /* skewy */
12366  if (!PG_ARGISNULL(13)) {
12367  skew[1] = PG_GETARG_FLOAT8(13);
12368  if (FLT_NEQ(skew[1], 0)) skew_y = &skew[1];
12369  }
12370  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: skew (x, y) = %f, %f", skew[0], skew[1]);
12371 
12372  /* all touched */
12373  if (!PG_ARGISNULL(14) && PG_GETARG_BOOL(14) == TRUE) {
12374  if (options_len < 1) {
12375  options_len = 1;
12376  options = (char **) palloc(sizeof(char *) * options_len);
12377  }
12378  else {
12379  options_len++;
12380  options = (char **) repalloc(options, sizeof(char *) * options_len);
12381  }
12382 
12383  options[options_len - 1] = palloc(sizeof(char*) * (strlen("ALL_TOUCHED=TRUE") + 1));
12384  options[options_len - 1] = "ALL_TOUCHED=TRUE";
12385  }
12386 
12387  if (options_len) {
12388  options_len++;
12389  options = (char **) repalloc(options, sizeof(char *) * options_len);
12390  options[options_len - 1] = NULL;
12391  }
12392 
12393  /* get geometry's srid */
12394  srid = gserialized_get_srid(gser);
12395 
12396  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: srid = %d", srid);
12397  if (clamp_srid(srid) != SRID_UNKNOWN) {
12398  srs = rtpg_getSR(srid);
12399  if (NULL == srs) {
12400 
12401  if (pixtypes_len) pfree(pixtypes);
12402  if (values_len) pfree(values);
12403  if (nodatavals_len) {
12404  pfree(hasnodatas);
12405  pfree(nodatavals);
12406  }
12407  if (options_len) pfree(options);
12408 
12409  lwgeom_free(geom);
12410  PG_FREE_IF_COPY(gser, 0);
12411 
12412  elog(ERROR, "RASTER_asRaster: Could not find srtext for SRID (%d)", srid);
12413  PG_RETURN_NULL();
12414  }
12415  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: srs is %s", srs);
12416  }
12417  else
12418  srs = NULL;
12419 
12420  /* determine number of bands */
12421  /* MIN macro is from GDAL's cpl_port.h */
12422  num_bands = MIN(pixtypes_len, values_len);
12423  num_bands = MIN(num_bands, nodatavals_len);
12424  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: pixtypes_len = %d", pixtypes_len);
12425  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: values_len = %d", values_len);
12426  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: nodatavals_len = %d", nodatavals_len);
12427  POSTGIS_RT_DEBUGF(3, "RASTER_asRaster: num_bands = %d", num_bands);
12428 
12429  /* warn of imbalanced number of band elements */
12430  if (!(
12431  (pixtypes_len == values_len) &&
12432  (values_len == nodatavals_len)
12433  )) {
12434  elog(
12435  NOTICE,
12436  "Imbalanced number of values provided for pixeltype (%d), value (%d) and nodataval (%d). Using the first %d values of each parameter",
12437  pixtypes_len,
12438  values_len,
12439  nodatavals_len,
12440  num_bands
12441  );
12442  }
12443 
12444  /* get wkb of geometry */
12445  POSTGIS_RT_DEBUG(3, "RASTER_asRaster: getting wkb of geometry");
12446  wkb = lwgeom_to_wkb(geom, variant, &wkb_len);
12447  lwgeom_free(geom);
12448  PG_FREE_IF_COPY(gser, 0);
12449 
12450  /* rasterize geometry */
12451  POSTGIS_RT_DEBUG(3, "RASTER_asRaster: rasterizing geometry");
12452  /* use nodatavals for the init parameter */
12453  rast = rt_raster_gdal_rasterize(wkb,
12454  (uint32_t) wkb_len, srs,
12455  num_bands, pixtypes,
12456  nodatavals, values,
12457  nodatavals, hasnodatas,
12458  dim_x, dim_y,
12459  scale_x, scale_y,
12460  ul_xw, ul_yw,
12461  grid_xw, grid_yw,
12462  skew_x, skew_y,
12463  options
12464  );
12465 
12466  if (pixtypes_len) pfree(pixtypes);
12467  if (values_len) pfree(values);
12468  if (nodatavals_len) {
12469  pfree(hasnodatas);
12470  pfree(nodatavals);
12471  }
12472  if (options_len) pfree(options);
12473 
12474  if (!rast) {
12475  elog(ERROR, "RASTER_asRaster: Could not rasterize geometry");
12476  PG_RETURN_NULL();
12477  }
12478 
12479  /* add target srid */
12480  rt_raster_set_srid(rast, srid);
12481 
12482  pgrast = rt_raster_serialize(rast);
12483  rt_raster_destroy(rast);
12484 
12485  if (NULL == pgrast) PG_RETURN_NULL();
12486 
12487  POSTGIS_RT_DEBUG(3, "RASTER_asRaster: done");
12488 
12489  SET_VARSIZE(pgrast, pgrast->size);
12490  PG_RETURN_POINTER(pgrast);
12491 }
#define FLT_NEQ(x, y)
Definition: rt_api.h:2158
int clamp_srid(int srid)
Return a valid SRID from an arbitrary integer Raises a notice if what comes out is different from wha...
Definition: lwutil.c:326
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
Definition: rt_api.c:8158
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_api.c:5387
static char * rtpg_trim(const char *input)
Definition: rt_pg.c:856
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
Definition: rt_api.h:184
static char * rtpg_getSR(int srid)
Definition: rt_pg.c:912
tuple rast
Definition: rtpixdump.py:62
#define MIN(a, b)
Definition: shpopen.c:284
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
Definition: rt_api.c:5668
int lwgeom_ndims(const LWGEOM *geom)
Return the number of dimensions (2, 3, 4) in a geometry.
Definition: lwgeom.c:806
#define WKB_SFSQL
Definition: liblwgeom.h:1768
uint8_t * lwgeom_to_wkb(const LWGEOM *geom, uint8_t variant, size_t *size_out)
Convert LWGEOM to a char* in WKB format.
Definition: lwout_wkb.c:692
rt_pixtype
Definition: rt_api.h:172
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rt_pg.h:58
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_api.c:10620
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:154
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
Definition: lwgeom.c:646
Struct definitions.
Definition: rt_api.h:2175
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rt_pg.h:62
rt_pixtype rt_pixtype_index_from_name(const char *pixname)
Definition: rt_api.c:1138
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1229
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_api.c:5353
#define TRUE
Definition: dbfopen.c:170
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:70

Here is the call graph for this function: