PostGIS  3.7.0dev-r@@SVN_REVISION@@
rt_util.c
Go to the documentation of this file.
1 /*
2  *
3  * WKTRaster - Raster Types for PostGIS
4  * http://trac.osgeo.org/postgis/wiki/WKTRaster
5  *
6  * Copyright (C) 2011-2013 Regents of the University of California
7  * <bkpark@ucdavis.edu>
8  * Copyright (C) 2010-2011 Jorge Arevalo <jorge.arevalo@deimos-space.com>
9  * Copyright (C) 2010-2011 David Zwarg <dzwarg@azavea.com>
10  * Copyright (C) 2009-2011 Pierre Racine <pierre.racine@sbf.ulaval.ca>
11  * Copyright (C) 2009-2011 Mateusz Loskot <mateusz@loskot.net>
12  * Copyright (C) 2008-2009 Sandro Santilli <strk@kbt.io>
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software Foundation,
26  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27  *
28  */
29 
30 #include "librtcore.h"
31 #include "librtcore_internal.h"
32 #include "optionlist.h"
33 
34 uint8_t
36  return (uint8_t)fmin(fmax((value), 0), POSTGIS_RT_1BBMAX);
37 }
38 
39 uint8_t
41  return (uint8_t)fmin(fmax((value), 0), POSTGIS_RT_2BUIMAX);
42 }
43 
44 uint8_t
46  return (uint8_t)fmin(fmax((value), 0), POSTGIS_RT_4BUIMAX);
47 }
48 
49 int8_t
51  return (int8_t)fmin(fmax((value), SCHAR_MIN), SCHAR_MAX);
52 }
53 
54 uint8_t
56  return (uint8_t)fmin(fmax((value), 0), UCHAR_MAX);
57 }
58 
59 int16_t
61  return (int16_t)fmin(fmax((value), SHRT_MIN), SHRT_MAX);
62 }
63 
64 uint16_t
66  return (uint16_t)fmin(fmax((value), 0), USHRT_MAX);
67 }
68 
69 int32_t
71  return (int32_t)fmin(fmax((value), INT_MIN), INT_MAX);
72 }
73 
74 uint32_t
76  return (uint32_t)fmin(fmax((value), 0), UINT_MAX);
77 }
78 
79 float
81  if (isnan(value))
82  return value;
83  return (float)fmin(fmax((value), -FLT_MAX), FLT_MAX);
84 }
85 
93 GDALResampleAlg
94 rt_util_gdal_resample_alg(const char *algname) {
95  assert(algname != NULL && strlen(algname) > 0);
96 
97  if (strcmp(algname, "NEARESTNEIGHBOUR") == 0)
98  return GRA_NearestNeighbour;
99  else if (strcmp(algname, "NEARESTNEIGHBOR") == 0)
100  return GRA_NearestNeighbour;
101  else if (strcmp(algname, "BILINEAR") == 0)
102  return GRA_Bilinear;
103  else if (strcmp(algname, "CUBICSPLINE") == 0)
104  return GRA_CubicSpline;
105  else if (strcmp(algname, "CUBIC") == 0)
106  return GRA_Cubic;
107  else if (strcmp(algname, "LANCZOS") == 0)
108  return GRA_Lanczos;
109  else if (strcmp(algname, "MAX") == 0)
110  return GRA_Max;
111  else if (strcmp(algname, "MIN") == 0)
112  return GRA_Min;
113  return GRA_NearestNeighbour;
114 }
115 
123 GDALDataType
125  switch (pt) {
126  case PT_1BB:
127  case PT_2BUI:
128  case PT_4BUI:
129  case PT_8BUI:
130  return GDT_Byte;
131  case PT_8BSI:
132 #if POSTGIS_GDAL_VERSION >= 30700
133  return GDT_Int8;
134 #endif
135  case PT_16BSI:
136  return GDT_Int16;
137  case PT_16BUI:
138  return GDT_UInt16;
139  case PT_32BSI:
140  return GDT_Int32;
141  case PT_32BUI:
142  return GDT_UInt32;
143  case PT_32BF:
144  return GDT_Float32;
145  case PT_64BF:
146  return GDT_Float64;
147  default:
148  return GDT_Unknown;
149  }
150 
151  return GDT_Unknown;
152 }
153 
163  switch (gdt) {
164  case GDT_Byte:
165  return PT_8BUI;
166 #if POSTGIS_GDAL_VERSION >= 30700
167  case GDT_Int8:
168  return PT_8BSI;
169 #endif
170  case GDT_UInt16:
171  return PT_16BUI;
172  case GDT_Int16:
173  return PT_16BSI;
174  case GDT_UInt32:
175  return PT_32BUI;
176  case GDT_Int32:
177  return PT_32BSI;
178  case GDT_Float32:
179  return PT_32BF;
180  case GDT_Float64:
181  return PT_64BF;
182  default:
183  return PT_END;
184  }
185 
186  return PT_END;
187 }
188 
189 /*
190  get GDAL runtime version information
191 */
192 const char*
193 rt_util_gdal_version(const char *request) {
194  if (NULL == request || !strlen(request))
195  return GDALVersionInfo("RELEASE_NAME");
196  else
197  return GDALVersionInfo(request);
198 }
199 
200 /*
201  computed extent type
202 */
204 rt_util_extent_type(const char *name) {
205  assert(name != NULL && strlen(name) > 0);
206 
207  if (strcmp(name, "UNION") == 0)
208  return ET_UNION;
209  else if (strcmp(name, "FIRST") == 0)
210  return ET_FIRST;
211  else if (strcmp(name, "SECOND") == 0)
212  return ET_SECOND;
213  else if (strcmp(name, "LAST") == 0)
214  return ET_LAST;
215  else if (strcmp(name, "CUSTOM") == 0)
216  return ET_CUSTOM;
217  else
218  return ET_INTERSECTION;
219 }
220 
221 /*
222  convert the spatial reference string from a GDAL recognized format to either WKT or Proj4
223 */
224 char*
225 rt_util_gdal_convert_sr(const char *srs, int proj4) {
226  OGRSpatialReferenceH hsrs;
227  char *rtn = NULL;
228 
229  assert(srs != NULL);
230 
231  hsrs = OSRNewSpatialReference(NULL);
232  if (OSRSetFromUserInput(hsrs, srs) == OGRERR_NONE) {
233  if (proj4)
234  OSRExportToProj4(hsrs, &rtn);
235  else
236  OSRExportToWkt(hsrs, &rtn);
237  }
238  else {
239  rterror("rt_util_gdal_convert_sr: Could not process the provided srs: %s", srs);
240  return NULL;
241  }
242 
243  OSRDestroySpatialReference(hsrs);
244  if (rtn == NULL) {
245  rterror("rt_util_gdal_convert_sr: Could not process the provided srs: %s", srs);
246  return NULL;
247  }
248 
249  return rtn;
250 }
251 
252 /*
253  is the spatial reference string supported by GDAL
254 */
255 int
256 rt_util_gdal_supported_sr(const char *srs) {
257  OGRSpatialReferenceH hsrs;
258  OGRErr rtn = OGRERR_NONE;
259 
260  assert(srs != NULL);
261 
262  hsrs = OSRNewSpatialReference(NULL);
263  rtn = OSRSetFromUserInput(hsrs, srs);
264  OSRDestroySpatialReference(hsrs);
265 
266  if (rtn == OGRERR_NONE)
267  return 1;
268  else
269  return 0;
270 }
271 
283 rt_util_gdal_sr_auth_info(GDALDatasetH hds, char **authname, char **authcode) {
284  const char *srs = NULL;
285 
286  assert(authname != NULL);
287  assert(authcode != NULL);
288 
289  *authname = NULL;
290  *authcode = NULL;
291 
292  srs = GDALGetProjectionRef(hds);
293  if (srs != NULL && srs[0] != '\0') {
294  OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
295 
296  if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
297  const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
298  const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
299 
300  if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
301  size_t authorityName_len = strlen(pszAuthorityName) +1;
302  size_t authorityCode_len = strlen(pszAuthorityCode) + 1;
303  *authname = rtalloc(sizeof(char) * authorityName_len);
304  *authcode = rtalloc(sizeof(char) * authorityCode_len);
305 
306  if (*authname == NULL || *authcode == NULL) {
307  rterror("rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
308  if (*authname != NULL) rtdealloc(*authname);
309  if (*authcode != NULL) rtdealloc(*authcode);
310  OSRDestroySpatialReference(hSRS);
311  return ES_ERROR;
312  }
313 
314  strncpy(*authname, pszAuthorityName, authorityName_len);
315  strncpy(*authcode, pszAuthorityCode, authorityCode_len);
316  }
317  }
318 
319  OSRDestroySpatialReference(hSRS);
320  }
321 
322  return ES_NONE;
323 }
324 
325 /*
326  is GDAL configured correctly?
327 */
329 
330  /* set of EPSG codes */
331  if (!rt_util_gdal_supported_sr("EPSG:4326"))
332  return 0;
333  if (!rt_util_gdal_supported_sr("EPSG:4269"))
334  return 0;
335  if (!rt_util_gdal_supported_sr("EPSG:4267"))
336  return 0;
337  if (!rt_util_gdal_supported_sr("EPSG:3310"))
338  return 0;
339 
340  return 1;
341 }
342 
343 /*
344  register all GDAL drivers
345 */
346 int
347 rt_util_gdal_register_all(int force_register_all) {
348  static int registered = 0;
349 
350  if (registered && !force_register_all) {
351  RASTER_DEBUG(3, "Already called once... not calling GDALAllRegister");
352  return 0;
353  }
354 
355  RASTER_DEBUG(3, "Calling GDALAllRegister");
356  GDALAllRegister();
357  registered = 1;
358 
359  return 1;
360 }
361 
362 /*
363  is the driver registered?
364 */
365 int
367  int count = GDALGetDriverCount();
368  int i = 0;
369  GDALDriverH hdrv = NULL;
370 
371  if (drv == NULL || !strlen(drv) || count < 1)
372  return 0;
373 
374  for (i = 0; i < count; i++) {
375  hdrv = GDALGetDriver(i);
376  if (hdrv == NULL) continue;
377 
378  if (strcmp(drv, GDALGetDriverShortName(hdrv)) == 0)
379  return 1;
380  }
381 
382  return 0;
383 }
384 
385 /* variable for PostgreSQL GUC: postgis.gdal_enabled_drivers */
386 char *gdal_enabled_drivers = NULL;
387 
388 
389 
390 /*
391  wrapper for GDALOpen and GDALOpenShared
392 */
393 GDALDatasetH
395  const char *fn,
396  GDALAccess fn_access,
397  int shared
398 ) {
399  char *vsi_options_str = rtoptions("gdal_vsi_options");
400 
401  /* Parse vsi options string */
402  if (vsi_options_str && strlen(vsi_options_str) > 0) {
403  size_t sz;
404  char *olist[OPTION_LIST_SIZE];
405  rtinfo("postgis.gdal_vsi_options is set");
406  memset(olist, 0, sizeof(olist));
407  option_list_parse(vsi_options_str, olist);
408  sz = option_list_length(olist);
409  if (sz % 2 == 0) {
410  size_t i;
411  for (i = 0; i < sz; i += 2)
412  {
413  char *key = olist[i];
414  char *val = olist[i+1];
415  /* GDAL_SKIP is where the disallowed drivers are set */
416  /* We cannot allow user-level over-ride of that config option */
417  if (strcmp(key, "gdal_skip") == 0) {
418  rtwarn("Unable to set GDAL_SKIP config option");
419  continue;
420  }
421  rtinfo("CPLSetConfigOption(%s)", key);
422  CPLSetConfigOption(key, val);
423  }
424  }
425  }
426 
427  unsigned int open_flags;
428  assert(NULL != fn);
429 
430  if (gdal_enabled_drivers != NULL) {
431  if (strstr(gdal_enabled_drivers, GDAL_DISABLE_ALL) != NULL) {
432  rterror("rt_util_gdal_open: Cannot open file. All GDAL drivers disabled");
433  return NULL;
434  }
435  else if (strstr(gdal_enabled_drivers, GDAL_ENABLE_ALL) != NULL) {
436  /* do nothing */
437  }
438  else if (
439  (strstr(fn, "/vsi") != NULL) &&
440  (strstr(fn, "/vsimem") == NULL) &&
441  (strstr(gdal_enabled_drivers, GDAL_VSICURL) == NULL)
442  ) {
443  rterror("rt_util_gdal_open: Cannot open %s file. %s disabled", GDAL_VSICURL, GDAL_VSICURL);
444  return NULL;
445  }
446  }
447 
448  open_flags = GDAL_OF_RASTER
449  | GDAL_OF_VERBOSE_ERROR
450  | (fn_access == GA_Update ? GDAL_OF_UPDATE : 0)
451  | (shared ? GDAL_OF_SHARED : 0);
452 
453  return GDALOpenEx(fn /* filename */,
454  open_flags,
455  NULL, /* allowed drivers */
456  NULL, /* open options */
457  NULL /* sibling files */
458  );
459 }
460 
461 void
463  OGREnvelope env,
464  rt_envelope *ext
465 ) {
466  assert(ext != NULL);
467 
468  ext->MinX = env.MinX;
469  ext->MaxX = env.MaxX;
470  ext->MinY = env.MinY;
471  ext->MaxY = env.MaxY;
472 
473  ext->UpperLeftX = env.MinX;
474  ext->UpperLeftY = env.MaxY;
475 }
476 
477 void
479  rt_envelope ext,
480  OGREnvelope *env
481 ) {
482  assert(env != NULL);
483 
484  env->MinX = ext.MinX;
485  env->MaxX = ext.MaxX;
486  env->MinY = ext.MinY;
487  env->MaxY = ext.MaxY;
488 }
489 
490 LWPOLY *
492  rt_envelope env
493 ) {
494  LWPOLY *npoly = NULL;
495  POINTARRAY **rings = NULL;
496  POINTARRAY *pts = NULL;
497  POINT4D p4d;
498 
499  rings = (POINTARRAY **) rtalloc(sizeof (POINTARRAY*));
500  if (!rings) {
501  rterror("rt_util_envelope_to_lwpoly: Out of memory building envelope's geometry");
502  return NULL;
503  }
504  rings[0] = ptarray_construct(0, 0, 5);
505  if (!rings[0]) {
506  rterror("rt_util_envelope_to_lwpoly: Out of memory building envelope's geometry ring");
507  return NULL;
508  }
509 
510  pts = rings[0];
511 
512  /* Upper-left corner (first and last points) */
513  p4d.x = env.MinX;
514  p4d.y = env.MaxY;
515  ptarray_set_point4d(pts, 0, &p4d);
516  ptarray_set_point4d(pts, 4, &p4d);
517 
518  /* Upper-right corner (we go clockwise) */
519  p4d.x = env.MaxX;
520  p4d.y = env.MaxY;
521  ptarray_set_point4d(pts, 1, &p4d);
522 
523  /* Lower-right corner */
524  p4d.x = env.MaxX;
525  p4d.y = env.MinY;
526  ptarray_set_point4d(pts, 2, &p4d);
527 
528  /* Lower-left corner */
529  p4d.x = env.MinX;
530  p4d.y = env.MinY;
531  ptarray_set_point4d(pts, 3, &p4d);
532 
533  npoly = lwpoly_construct(SRID_UNKNOWN, 0, 1, rings);
534  if (npoly == NULL) {
535  rterror("rt_util_envelope_to_lwpoly: Could not build envelope's geometry");
536  return NULL;
537  }
538 
539  return npoly;
540 }
541 
542 int
543 rt_util_same_geotransform_matrix(double *gt1, double *gt2) {
544  int k = 0;
545 
546  if (gt1 == NULL || gt2 == NULL)
547  return FALSE;
548 
549  for (k = 0; k < 6; k++) {
550  if (FLT_NEQ(gt1[k], gt2[k]))
551  return FALSE;
552  }
553 
554  return TRUE;
555 }
556 
557 /* coordinates in RGB and HSV are floating point values between 0 and 1 */
559 rt_util_rgb_to_hsv(double rgb[3], double hsv[3]) {
560  int i;
561 
562  double minc;
563  double maxc;
564 
565  double h = 0.;
566  double s = 0.;
567  double v = 0.;
568 
569  minc = rgb[0];
570  maxc = rgb[0];
571 
572  /* get min and max values from RGB */
573  for (i = 1; i < 3; i++) {
574  if (rgb[i] > maxc)
575  maxc = rgb[i];
576  if (rgb[i] < minc)
577  minc = rgb[i];
578  }
579  v = maxc;
580 
581  if (maxc != minc) {
582  double diff = 0.;
583  double rc = 0.;
584  double gc = 0.;
585  double bc = 0.;
586  double junk = 0.;
587 
588  diff = maxc - minc;
589  s = diff / maxc;
590  rc = (maxc - rgb[0]) / diff;
591  gc = (maxc - rgb[1]) / diff;
592  bc = (maxc - rgb[2]) / diff;
593 
594  if (DBL_EQ(rgb[0], maxc))
595  h = bc - gc;
596  else if (DBL_EQ(rgb[1], maxc))
597  h = 2.0 + rc - bc;
598  else
599  h = 4.0 + gc - rc;
600 
601  h = modf((h / 6.0), &junk);
602  }
603 
604  hsv[0] = h;
605  hsv[1] = s;
606  hsv[2] = v;
607 
608  return ES_NONE;
609 }
610 
611 /* coordinates in RGB and HSV are floating point values between 0 and 1 */
613 rt_util_hsv_to_rgb(double hsv[3], double rgb[3]) {
614  double r = 0;
615  double g = 0;
616  double b = 0;
617  double v = hsv[2];
618 
619  if (DBL_EQ(hsv[1], 0.))
620  r = g = b = v;
621  else {
622  double i;
623  double f;
624  double p;
625  double q;
626  double t;
627 
628  int a;
629 
630  i = floor(hsv[0] * 6.);
631  f = (hsv[0] * 6.0) - i;
632  p = v * (1. - hsv[1]);
633  q = v * (1. - hsv[1] * f);
634  t = v * (1. - hsv[1] * (1. - f));
635 
636  a = (int) i;
637  switch (a) {
638  case 1:
639  r = q;
640  g = v;
641  b = p;
642  break;
643  case 2:
644  r = p;
645  g = v;
646  b = t;
647  break;
648  case 3:
649  r = p;
650  g = q;
651  b = v;
652  break;
653  case 4:
654  r = t;
655  g = p;
656  b = v;
657  break;
658  case 5:
659  r = v;
660  g = p;
661  b = q;
662  break;
663  case 0:
664  case 6:
665  default:
666  r = v;
667  g = t;
668  b = p;
669  break;
670  }
671  }
672 
673  rgb[0] = r;
674  rgb[1] = g;
675  rgb[2] = b;
676 
677  return ES_NONE;
678 }
679 
680 int
682  double initialvalue,
683  int32_t checkvalint, uint32_t checkvaluint,
684  float checkvalfloat, double checkvaldouble,
685  rt_pixtype pixtype
686 ) {
687  int result = 0;
688 
689  switch (pixtype) {
690  case PT_1BB:
691  case PT_2BUI:
692  case PT_4BUI:
693  case PT_8BSI:
694  case PT_8BUI:
695  case PT_16BSI:
696  case PT_16BUI:
697  case PT_32BSI: {
698  if (fabs(checkvalint - initialvalue) >= 1) {
699 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
700  rtwarn("Value set for %s band got clamped from %f to %d",
701  rt_pixtype_name(pixtype),
702  initialvalue, checkvalint
703  );
704 #endif
705  result = 1;
706  }
707  else if (checkvalint != initialvalue)
708  {
709 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
710  rtwarn("Value set for %s band got truncated from %f to %d",
711  rt_pixtype_name(pixtype),
712  initialvalue, checkvalint
713  );
714 #endif
715  result = 1;
716  }
717  break;
718  }
719  case PT_32BUI: {
720  if (fabs(checkvaluint - initialvalue) >= 1) {
721 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
722  rtwarn("Value set for %s band got clamped from %f to %u",
723  rt_pixtype_name(pixtype),
724  initialvalue, checkvaluint
725  );
726 #endif
727  result = 1;
728  }
729  else if (checkvaluint != initialvalue)
730  {
731 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
732  rtwarn("Value set for %s band got truncated from %f to %u",
733  rt_pixtype_name(pixtype),
734  initialvalue, checkvaluint
735  );
736 #endif
737  result = 1;
738  }
739  break;
740  }
741  case PT_32BF: {
742  /*
743  For float, because the initial value is a double,
744  there is very often a difference between the desired value and the obtained one
745  */
746  if (FLT_NEQ(checkvalfloat, initialvalue)) {
747 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
748  rtwarn("Value set for %s band got converted from %f to %f",
749  rt_pixtype_name(pixtype),
750  initialvalue, checkvalfloat
751  );
752 #endif
753  result = 1;
754  }
755  break;
756  }
757  case PT_64BF: {
758  if (FLT_NEQ(checkvaldouble, initialvalue)) {
759 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
760  rtwarn("Value set for %s band got converted from %f to %f",
761  rt_pixtype_name(pixtype),
762  initialvalue, checkvaldouble
763  );
764 #endif
765  result = 1;
766  }
767  break;
768  }
769  case PT_END:
770  break;
771  }
772 
773  return result;
774 }
775 
char * s
Definition: cu_in_wkt.c:23
char * r
Definition: cu_in_wkt.c:24
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
#define TRUE
Definition: dbfopen.c:73
#define FALSE
Definition: dbfopen.c:72
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:51
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:215
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:369
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:191
void void void char * rtoptions(const char *varname)
Wrappers used for options.
Definition: rt_context.c:256
#define FLT_NEQ(x, y)
Definition: librtcore.h:2423
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:302
void void rtinfo(const char *fmt,...) __attribute__((format(printf
void void void rtwarn(const char *fmt,...) __attribute__((format(printf
rt_pixtype
Definition: librtcore.h:187
@ PT_32BUI
Definition: librtcore.h:196
@ PT_2BUI
Definition: librtcore.h:189
@ PT_32BSI
Definition: librtcore.h:195
@ PT_END
Definition: librtcore.h:199
@ PT_4BUI
Definition: librtcore.h:190
@ PT_32BF
Definition: librtcore.h:197
@ PT_1BB
Definition: librtcore.h:188
@ PT_16BUI
Definition: librtcore.h:194
@ PT_8BSI
Definition: librtcore.h:191
@ PT_16BSI
Definition: librtcore.h:193
@ PT_64BF
Definition: librtcore.h:198
@ PT_8BUI
Definition: librtcore.h:192
#define POSTGIS_RT_4BUIMAX
Definition: librtcore.h:2251
rt_errorstate
Enum definitions.
Definition: librtcore.h:181
@ ES_NONE
Definition: librtcore.h:182
@ ES_ERROR
Definition: librtcore.h:183
#define DBL_EQ(x, y)
Definition: librtcore.h:2426
#define GDAL_ENABLE_ALL
Definition: librtcore.h:2237
#define GDAL_DISABLE_ALL
Definition: librtcore.h:2238
#define GDAL_VSICURL
Definition: librtcore.h:2239
rt_extenttype
Definition: librtcore.h:202
@ ET_CUSTOM
Definition: librtcore.h:208
@ ET_LAST
Definition: librtcore.h:207
@ ET_INTERSECTION
Definition: librtcore.h:203
@ ET_UNION
Definition: librtcore.h:204
@ ET_SECOND
Definition: librtcore.h:206
@ ET_FIRST
Definition: librtcore.h:205
#define POSTGIS_RT_2BUIMAX
Definition: librtcore.h:2250
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_pixel.c:110
#define POSTGIS_RT_1BBMAX
Definition: librtcore.h:2249
void rtdealloc(void *mem)
Definition: rt_context.c:206
This library is the generic raster handling section of PostGIS.
int value
Definition: genraster.py:62
int count
Definition: genraster.py:57
size_t option_list_length(char **olist)
Returns the total number of keys and values in the list.
Definition: optionlist.c:73
void option_list_parse(char *input, char **olist)
option_list is a null-terminated list of strings, where every odd string is a key and every even stri...
Definition: optionlist.c:86
#define OPTION_LIST_SIZE
Definition: optionlist.h:31
rt_pixtype rt_util_gdal_datatype_to_pixtype(GDALDataType gdt)
Convert GDALDataType to rt_pixtype.
Definition: rt_util.c:162
rt_errorstate rt_util_rgb_to_hsv(double rgb[3], double hsv[3])
Definition: rt_util.c:559
int rt_util_gdal_register_all(int force_register_all)
Definition: rt_util.c:347
int rt_util_gdal_configured(void)
Definition: rt_util.c:328
int8_t rt_util_clamp_to_8BSI(double value)
Definition: rt_util.c:50
uint8_t rt_util_clamp_to_1BB(double value)
Definition: rt_util.c:35
int32_t rt_util_clamp_to_32BSI(double value)
Definition: rt_util.c:70
char * rt_util_gdal_convert_sr(const char *srs, int proj4)
Definition: rt_util.c:225
const char * rt_util_gdal_version(const char *request)
Definition: rt_util.c:193
rt_extenttype rt_util_extent_type(const char *name)
Definition: rt_util.c:204
int rt_util_dbl_trunc_warning(double initialvalue, int32_t checkvalint, uint32_t checkvaluint, float checkvalfloat, double checkvaldouble, rt_pixtype pixtype)
Definition: rt_util.c:681
GDALDataType rt_util_pixtype_to_gdal_datatype(rt_pixtype pt)
Convert rt_pixtype to GDALDataType.
Definition: rt_util.c:124
uint8_t rt_util_clamp_to_2BUI(double value)
Definition: rt_util.c:40
uint8_t rt_util_clamp_to_8BUI(double value)
Definition: rt_util.c:55
GDALDatasetH rt_util_gdal_open(const char *fn, GDALAccess fn_access, int shared)
Definition: rt_util.c:394
int rt_util_gdal_supported_sr(const char *srs)
Definition: rt_util.c:256
int16_t rt_util_clamp_to_16BSI(double value)
Definition: rt_util.c:60
GDALResampleAlg rt_util_gdal_resample_alg(const char *algname)
Convert cstring name to GDAL Resample Algorithm.
Definition: rt_util.c:94
int rt_util_gdal_driver_registered(const char *drv)
Definition: rt_util.c:366
uint8_t rt_util_clamp_to_4BUI(double value)
Definition: rt_util.c:45
rt_errorstate rt_util_hsv_to_rgb(double hsv[3], double rgb[3])
Definition: rt_util.c:613
void rt_util_to_ogr_envelope(rt_envelope ext, OGREnvelope *env)
Definition: rt_util.c:478
rt_errorstate rt_util_gdal_sr_auth_info(GDALDatasetH hds, char **authname, char **authcode)
Get auth name and code.
Definition: rt_util.c:283
uint16_t rt_util_clamp_to_16BUI(double value)
Definition: rt_util.c:65
uint32_t rt_util_clamp_to_32BUI(double value)
Definition: rt_util.c:75
LWPOLY * rt_util_envelope_to_lwpoly(rt_envelope env)
Definition: rt_util.c:491
char * gdal_enabled_drivers
Definition: rt_util.c:386
int rt_util_same_geotransform_matrix(double *gt1, double *gt2)
Definition: rt_util.c:543
float rt_util_clamp_to_32F(double value)
Definition: rt_util.c:80
void rt_util_from_ogr_envelope(OGREnvelope env, rt_envelope *ext)
Definition: rt_util.c:462
double x
Definition: liblwgeom.h:414
double y
Definition: liblwgeom.h:414
double MinX
Definition: librtcore.h:167
double UpperLeftY
Definition: librtcore.h:173
double UpperLeftX
Definition: librtcore.h:172
double MaxX
Definition: librtcore.h:168
double MinY
Definition: librtcore.h:169
double MaxY
Definition: librtcore.h:170