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