PostGIS  3.4.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  case PT_16BSI:
133  return GDT_Int16;
134  case PT_16BUI:
135  return GDT_UInt16;
136  case PT_32BSI:
137  return GDT_Int32;
138  case PT_32BUI:
139  return GDT_UInt32;
140  case PT_32BF:
141  return GDT_Float32;
142  case PT_64BF:
143  return GDT_Float64;
144  default:
145  return GDT_Unknown;
146  }
147 
148  return GDT_Unknown;
149 }
150 
160  switch (gdt) {
161  case GDT_Byte:
162  return PT_8BUI;
163  case GDT_UInt16:
164  return PT_16BUI;
165  case GDT_Int16:
166  return PT_16BSI;
167  case GDT_UInt32:
168  return PT_32BUI;
169  case GDT_Int32:
170  return PT_32BSI;
171  case GDT_Float32:
172  return PT_32BF;
173  case GDT_Float64:
174  return PT_64BF;
175  default:
176  return PT_END;
177  }
178 
179  return PT_END;
180 }
181 
182 /*
183  get GDAL runtime version information
184 */
185 const char*
186 rt_util_gdal_version(const char *request) {
187  if (NULL == request || !strlen(request))
188  return GDALVersionInfo("RELEASE_NAME");
189  else
190  return GDALVersionInfo(request);
191 }
192 
193 /*
194  computed extent type
195 */
197 rt_util_extent_type(const char *name) {
198  assert(name != NULL && strlen(name) > 0);
199 
200  if (strcmp(name, "UNION") == 0)
201  return ET_UNION;
202  else if (strcmp(name, "FIRST") == 0)
203  return ET_FIRST;
204  else if (strcmp(name, "SECOND") == 0)
205  return ET_SECOND;
206  else if (strcmp(name, "LAST") == 0)
207  return ET_LAST;
208  else if (strcmp(name, "CUSTOM") == 0)
209  return ET_CUSTOM;
210  else
211  return ET_INTERSECTION;
212 }
213 
214 /*
215  convert the spatial reference string from a GDAL recognized format to either WKT or Proj4
216 */
217 char*
218 rt_util_gdal_convert_sr(const char *srs, int proj4) {
219  OGRSpatialReferenceH hsrs;
220  char *rtn = NULL;
221 
222  assert(srs != NULL);
223 
224  hsrs = OSRNewSpatialReference(NULL);
225  if (OSRSetFromUserInput(hsrs, srs) == OGRERR_NONE) {
226  if (proj4)
227  OSRExportToProj4(hsrs, &rtn);
228  else
229  OSRExportToWkt(hsrs, &rtn);
230  }
231  else {
232  rterror("rt_util_gdal_convert_sr: Could not process the provided srs: %s", srs);
233  return NULL;
234  }
235 
236  OSRDestroySpatialReference(hsrs);
237  if (rtn == NULL) {
238  rterror("rt_util_gdal_convert_sr: Could not process the provided srs: %s", srs);
239  return NULL;
240  }
241 
242  return rtn;
243 }
244 
245 /*
246  is the spatial reference string supported by GDAL
247 */
248 int
249 rt_util_gdal_supported_sr(const char *srs) {
250  OGRSpatialReferenceH hsrs;
251  OGRErr rtn = OGRERR_NONE;
252 
253  assert(srs != NULL);
254 
255  hsrs = OSRNewSpatialReference(NULL);
256  rtn = OSRSetFromUserInput(hsrs, srs);
257  OSRDestroySpatialReference(hsrs);
258 
259  if (rtn == OGRERR_NONE)
260  return 1;
261  else
262  return 0;
263 }
264 
276 rt_util_gdal_sr_auth_info(GDALDatasetH hds, char **authname, char **authcode) {
277  const char *srs = NULL;
278 
279  assert(authname != NULL);
280  assert(authcode != NULL);
281 
282  *authname = NULL;
283  *authcode = NULL;
284 
285  srs = GDALGetProjectionRef(hds);
286  if (srs != NULL && srs[0] != '\0') {
287  OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
288 
289  if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
290  const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
291  const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
292 
293  if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
294  size_t authorityName_len = strlen(pszAuthorityName) +1;
295  size_t authorityCode_len = strlen(pszAuthorityCode) + 1;
296  *authname = rtalloc(sizeof(char) * authorityName_len);
297  *authcode = rtalloc(sizeof(char) * authorityCode_len);
298 
299  if (*authname == NULL || *authcode == NULL) {
300  rterror("rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
301  if (*authname != NULL) rtdealloc(*authname);
302  if (*authcode != NULL) rtdealloc(*authcode);
303  OSRDestroySpatialReference(hSRS);
304  return ES_ERROR;
305  }
306 
307  strncpy(*authname, pszAuthorityName, authorityName_len);
308  strncpy(*authcode, pszAuthorityCode, authorityCode_len);
309  }
310  }
311 
312  OSRDestroySpatialReference(hSRS);
313  }
314 
315  return ES_NONE;
316 }
317 
318 /*
319  is GDAL configured correctly?
320 */
322 
323  /* set of EPSG codes */
324  if (!rt_util_gdal_supported_sr("EPSG:4326"))
325  return 0;
326  if (!rt_util_gdal_supported_sr("EPSG:4269"))
327  return 0;
328  if (!rt_util_gdal_supported_sr("EPSG:4267"))
329  return 0;
330  if (!rt_util_gdal_supported_sr("EPSG:3310"))
331  return 0;
332  if (!rt_util_gdal_supported_sr("EPSG:2163"))
333  return 0;
334 
335  return 1;
336 }
337 
338 /*
339  register all GDAL drivers
340 */
341 int
342 rt_util_gdal_register_all(int force_register_all) {
343  static int registered = 0;
344 
345  if (registered && !force_register_all) {
346  RASTER_DEBUG(3, "Already called once... not calling GDALAllRegister");
347  return 0;
348  }
349 
350  RASTER_DEBUG(3, "Calling GDALAllRegister");
351  GDALAllRegister();
352  registered = 1;
353 
354  return 1;
355 }
356 
357 /*
358  is the driver registered?
359 */
360 int
362  int count = GDALGetDriverCount();
363  int i = 0;
364  GDALDriverH hdrv = NULL;
365 
366  if (drv == NULL || !strlen(drv) || count < 1)
367  return 0;
368 
369  for (i = 0; i < count; i++) {
370  hdrv = GDALGetDriver(i);
371  if (hdrv == NULL) continue;
372 
373  if (strcmp(drv, GDALGetDriverShortName(hdrv)) == 0)
374  return 1;
375  }
376 
377  return 0;
378 }
379 
380 /* variable for PostgreSQL GUC: postgis.gdal_enabled_drivers */
381 char *gdal_enabled_drivers = NULL;
382 
383 
384 
385 /*
386  wrapper for GDALOpen and GDALOpenShared
387 */
388 GDALDatasetH
390  const char *fn,
391  GDALAccess fn_access,
392  int shared
393 ) {
394  char *vsi_options_str = rtoptions("gdal_vsi_options");
395 
396  /* Parse vsi options string */
397  if (vsi_options_str && strlen(vsi_options_str) > 0) {
398  size_t sz;
399  char *olist[OPTION_LIST_SIZE];
400  rtinfo("postgis.gdal_vsi_options is set");
401  memset(olist, 0, sizeof(olist));
402  option_list_parse(vsi_options_str, olist);
403  sz = option_list_length(olist);
404  if (sz % 2 == 0) {
405  size_t i;
406  for (i = 0; i < sz; i += 2)
407  {
408  char *key = olist[i];
409  char *val = olist[i+1];
410  /* GDAL_SKIP is where the disallowed drivers are set */
411  /* We cannot allow user-level over-ride of that config option */
412  if (strcmp(key, "gdal_skip") == 0) {
413  rtwarn("Unable to set GDAL_SKIP config option");
414  continue;
415  }
416  rtinfo("CPLSetConfigOption(%s)", key);
417  CPLSetConfigOption(key, val);
418  }
419  }
420  }
421 
422  unsigned int open_flags;
423  assert(NULL != fn);
424 
425  if (gdal_enabled_drivers != NULL) {
426  if (strstr(gdal_enabled_drivers, GDAL_DISABLE_ALL) != NULL) {
427  rterror("rt_util_gdal_open: Cannot open file. All GDAL drivers disabled");
428  return NULL;
429  }
430  else if (strstr(gdal_enabled_drivers, GDAL_ENABLE_ALL) != NULL) {
431  /* do nothing */
432  }
433  else if (
434  (strstr(fn, "/vsi") != NULL) &&
435  (strstr(fn, "/vsimem") == NULL) &&
436  (strstr(gdal_enabled_drivers, GDAL_VSICURL) == NULL)
437  ) {
438  rterror("rt_util_gdal_open: Cannot open %s file. %s disabled", GDAL_VSICURL, GDAL_VSICURL);
439  return NULL;
440  }
441  }
442 
443  open_flags = GDAL_OF_RASTER
444  | GDAL_OF_VERBOSE_ERROR
445  | (fn_access == GA_Update ? GDAL_OF_UPDATE : 0)
446  | (shared ? GDAL_OF_SHARED : 0);
447 
448  return GDALOpenEx(fn /* filename */,
449  open_flags,
450  NULL, /* allowed drivers */
451  NULL, /* open options */
452  NULL /* sibling files */
453  );
454 }
455 
456 void
458  OGREnvelope env,
459  rt_envelope *ext
460 ) {
461  assert(ext != NULL);
462 
463  ext->MinX = env.MinX;
464  ext->MaxX = env.MaxX;
465  ext->MinY = env.MinY;
466  ext->MaxY = env.MaxY;
467 
468  ext->UpperLeftX = env.MinX;
469  ext->UpperLeftY = env.MaxY;
470 }
471 
472 void
474  rt_envelope ext,
475  OGREnvelope *env
476 ) {
477  assert(env != NULL);
478 
479  env->MinX = ext.MinX;
480  env->MaxX = ext.MaxX;
481  env->MinY = ext.MinY;
482  env->MaxY = ext.MaxY;
483 }
484 
485 LWPOLY *
487  rt_envelope env
488 ) {
489  LWPOLY *npoly = NULL;
490  POINTARRAY **rings = NULL;
491  POINTARRAY *pts = NULL;
492  POINT4D p4d;
493 
494  rings = (POINTARRAY **) rtalloc(sizeof (POINTARRAY*));
495  if (!rings) {
496  rterror("rt_util_envelope_to_lwpoly: Out of memory building envelope's geometry");
497  return NULL;
498  }
499  rings[0] = ptarray_construct(0, 0, 5);
500  if (!rings[0]) {
501  rterror("rt_util_envelope_to_lwpoly: Out of memory building envelope's geometry ring");
502  return NULL;
503  }
504 
505  pts = rings[0];
506 
507  /* Upper-left corner (first and last points) */
508  p4d.x = env.MinX;
509  p4d.y = env.MaxY;
510  ptarray_set_point4d(pts, 0, &p4d);
511  ptarray_set_point4d(pts, 4, &p4d);
512 
513  /* Upper-right corner (we go clockwise) */
514  p4d.x = env.MaxX;
515  p4d.y = env.MaxY;
516  ptarray_set_point4d(pts, 1, &p4d);
517 
518  /* Lower-right corner */
519  p4d.x = env.MaxX;
520  p4d.y = env.MinY;
521  ptarray_set_point4d(pts, 2, &p4d);
522 
523  /* Lower-left corner */
524  p4d.x = env.MinX;
525  p4d.y = env.MinY;
526  ptarray_set_point4d(pts, 3, &p4d);
527 
528  npoly = lwpoly_construct(SRID_UNKNOWN, 0, 1, rings);
529  if (npoly == NULL) {
530  rterror("rt_util_envelope_to_lwpoly: Could not build envelope's geometry");
531  return NULL;
532  }
533 
534  return npoly;
535 }
536 
537 int
538 rt_util_same_geotransform_matrix(double *gt1, double *gt2) {
539  int k = 0;
540 
541  if (gt1 == NULL || gt2 == NULL)
542  return FALSE;
543 
544  for (k = 0; k < 6; k++) {
545  if (FLT_NEQ(gt1[k], gt2[k]))
546  return FALSE;
547  }
548 
549  return TRUE;
550 }
551 
552 /* coordinates in RGB and HSV are floating point values between 0 and 1 */
554 rt_util_rgb_to_hsv(double rgb[3], double hsv[3]) {
555  int i;
556 
557  double minc;
558  double maxc;
559 
560  double h = 0.;
561  double s = 0.;
562  double v = 0.;
563 
564  minc = rgb[0];
565  maxc = rgb[0];
566 
567  /* get min and max values from RGB */
568  for (i = 1; i < 3; i++) {
569  if (rgb[i] > maxc)
570  maxc = rgb[i];
571  if (rgb[i] < minc)
572  minc = rgb[i];
573  }
574  v = maxc;
575 
576  if (maxc != minc) {
577  double diff = 0.;
578  double rc = 0.;
579  double gc = 0.;
580  double bc = 0.;
581  double junk = 0.;
582 
583  diff = maxc - minc;
584  s = diff / maxc;
585  rc = (maxc - rgb[0]) / diff;
586  gc = (maxc - rgb[1]) / diff;
587  bc = (maxc - rgb[2]) / diff;
588 
589  if (DBL_EQ(rgb[0], maxc))
590  h = bc - gc;
591  else if (DBL_EQ(rgb[1], maxc))
592  h = 2.0 + rc - bc;
593  else
594  h = 4.0 + gc - rc;
595 
596  h = modf((h / 6.0), &junk);
597  }
598 
599  hsv[0] = h;
600  hsv[1] = s;
601  hsv[2] = v;
602 
603  return ES_NONE;
604 }
605 
606 /* coordinates in RGB and HSV are floating point values between 0 and 1 */
608 rt_util_hsv_to_rgb(double hsv[3], double rgb[3]) {
609  double r = 0;
610  double g = 0;
611  double b = 0;
612  double v = hsv[2];
613 
614  if (DBL_EQ(hsv[1], 0.))
615  r = g = b = v;
616  else {
617  double i;
618  double f;
619  double p;
620  double q;
621  double t;
622 
623  int a;
624 
625  i = floor(hsv[0] * 6.);
626  f = (hsv[0] * 6.0) - i;
627  p = v * (1. - hsv[1]);
628  q = v * (1. - hsv[1] * f);
629  t = v * (1. - hsv[1] * (1. - f));
630 
631  a = (int) i;
632  switch (a) {
633  case 1:
634  r = q;
635  g = v;
636  b = p;
637  break;
638  case 2:
639  r = p;
640  g = v;
641  b = t;
642  break;
643  case 3:
644  r = p;
645  g = q;
646  b = v;
647  break;
648  case 4:
649  r = t;
650  g = p;
651  b = v;
652  break;
653  case 5:
654  r = v;
655  g = p;
656  b = q;
657  break;
658  case 0:
659  case 6:
660  default:
661  r = v;
662  g = t;
663  b = p;
664  break;
665  }
666  }
667 
668  rgb[0] = r;
669  rgb[1] = g;
670  rgb[2] = b;
671 
672  return ES_NONE;
673 }
674 
675 int
677  double initialvalue,
678  int32_t checkvalint, uint32_t checkvaluint,
679  float checkvalfloat, double checkvaldouble,
680  rt_pixtype pixtype
681 ) {
682  int result = 0;
683 
684  switch (pixtype) {
685  case PT_1BB:
686  case PT_2BUI:
687  case PT_4BUI:
688  case PT_8BSI:
689  case PT_8BUI:
690  case PT_16BSI:
691  case PT_16BUI:
692  case PT_32BSI: {
693  if (fabs(checkvalint - initialvalue) >= 1) {
694 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
695  rtwarn("Value set for %s band got clamped from %f to %d",
696  rt_pixtype_name(pixtype),
697  initialvalue, checkvalint
698  );
699 #endif
700  result = 1;
701  }
702  else if (checkvalint != initialvalue)
703  {
704 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
705  rtwarn("Value set for %s band got truncated from %f to %d",
706  rt_pixtype_name(pixtype),
707  initialvalue, checkvalint
708  );
709 #endif
710  result = 1;
711  }
712  break;
713  }
714  case PT_32BUI: {
715  if (fabs(checkvaluint - initialvalue) >= 1) {
716 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
717  rtwarn("Value set for %s band got clamped from %f to %u",
718  rt_pixtype_name(pixtype),
719  initialvalue, checkvaluint
720  );
721 #endif
722  result = 1;
723  }
724  else if (checkvaluint != initialvalue)
725  {
726 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
727  rtwarn("Value set for %s band got truncated from %f to %u",
728  rt_pixtype_name(pixtype),
729  initialvalue, checkvaluint
730  );
731 #endif
732  result = 1;
733  }
734  break;
735  }
736  case PT_32BF: {
737  /*
738  For float, because the initial value is a double,
739  there is very often a difference between the desired value and the obtained one
740  */
741  if (FLT_NEQ(checkvalfloat, initialvalue)) {
742 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
743  rtwarn("Value set for %s band got converted from %f to %f",
744  rt_pixtype_name(pixtype),
745  initialvalue, checkvalfloat
746  );
747 #endif
748  result = 1;
749  }
750  break;
751  }
752  case PT_64BF: {
753  if (FLT_NEQ(checkvaldouble, initialvalue)) {
754 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
755  rtwarn("Value set for %s band got converted from %f to %f",
756  rt_pixtype_name(pixtype),
757  initialvalue, checkvaldouble
758  );
759 #endif
760  result = 1;
761  }
762  break;
763  }
764  case PT_END:
765  break;
766  }
767 
768  return result;
769 }
770 
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:262
#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,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:219
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:191
#define FLT_NEQ(x, y)
Definition: librtcore.h:2386
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:302
void rtinfo(const char *fmt,...)
Definition: rt_context.c:231
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:2206
char * rtoptions(const char *varname)
Wrappers used for options.
Definition: rt_context.c:256
void rtwarn(const char *fmt,...)
Definition: rt_context.c:244
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:2389
#define GDAL_ENABLE_ALL
Definition: librtcore.h:2192
#define GDAL_DISABLE_ALL
Definition: librtcore.h:2193
#define GDAL_VSICURL
Definition: librtcore.h:2194
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:2205
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_pixel.c:110
#define POSTGIS_RT_1BBMAX
Definition: librtcore.h:2204
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:159
rt_errorstate rt_util_rgb_to_hsv(double rgb[3], double hsv[3])
Definition: rt_util.c:554
int rt_util_gdal_register_all(int force_register_all)
Definition: rt_util.c:342
int rt_util_gdal_configured(void)
Definition: rt_util.c:321
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:218
const char * rt_util_gdal_version(const char *request)
Definition: rt_util.c:186
rt_extenttype rt_util_extent_type(const char *name)
Definition: rt_util.c:197
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:676
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:389
int rt_util_gdal_supported_sr(const char *srs)
Definition: rt_util.c:249
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:361
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:608
void rt_util_to_ogr_envelope(rt_envelope ext, OGREnvelope *env)
Definition: rt_util.c:473
rt_errorstate rt_util_gdal_sr_auth_info(GDALDatasetH hds, char **authname, char **authcode)
Get auth name and code.
Definition: rt_util.c:276
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:486
char * gdal_enabled_drivers
Definition: rt_util.c:381
int rt_util_same_geotransform_matrix(double *gt1, double *gt2)
Definition: rt_util.c:538
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:457
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