PostGIS  3.1.6dev-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 
33 uint8_t
35  return (uint8_t)fmin(fmax((value), 0), POSTGIS_RT_1BBMAX);
36 }
37 
38 uint8_t
40  return (uint8_t)fmin(fmax((value), 0), POSTGIS_RT_2BUIMAX);
41 }
42 
43 uint8_t
45  return (uint8_t)fmin(fmax((value), 0), POSTGIS_RT_4BUIMAX);
46 }
47 
48 int8_t
50  return (int8_t)fmin(fmax((value), SCHAR_MIN), SCHAR_MAX);
51 }
52 
53 uint8_t
55  return (uint8_t)fmin(fmax((value), 0), UCHAR_MAX);
56 }
57 
58 int16_t
60  return (int16_t)fmin(fmax((value), SHRT_MIN), SHRT_MAX);
61 }
62 
63 uint16_t
65  return (uint16_t)fmin(fmax((value), 0), USHRT_MAX);
66 }
67 
68 int32_t
70  return (int32_t)fmin(fmax((value), INT_MIN), INT_MAX);
71 }
72 
73 uint32_t
75  return (uint32_t)fmin(fmax((value), 0), UINT_MAX);
76 }
77 
78 float
80  if (isnan(value))
81  return value;
82  return (float)fmin(fmax((value), -FLT_MAX), FLT_MAX);
83 }
84 
92 GDALResampleAlg
93 rt_util_gdal_resample_alg(const char *algname) {
94  assert(algname != NULL && strlen(algname) > 0);
95 
96  if (strcmp(algname, "NEARESTNEIGHBOUR") == 0)
97  return GRA_NearestNeighbour;
98  else if (strcmp(algname, "NEARESTNEIGHBOR") == 0)
99  return GRA_NearestNeighbour;
100  else if (strcmp(algname, "BILINEAR") == 0)
101  return GRA_Bilinear;
102  else if (strcmp(algname, "CUBICSPLINE") == 0)
103  return GRA_CubicSpline;
104  else if (strcmp(algname, "CUBIC") == 0)
105  return GRA_Cubic;
106  else if (strcmp(algname, "LANCZOS") == 0)
107  return GRA_Lanczos;
108 
109  return GRA_NearestNeighbour;
110 }
111 
119 GDALDataType
121  switch (pt) {
122  case PT_1BB:
123  case PT_2BUI:
124  case PT_4BUI:
125  case PT_8BUI:
126  return GDT_Byte;
127  case PT_8BSI:
128  case PT_16BSI:
129  return GDT_Int16;
130  case PT_16BUI:
131  return GDT_UInt16;
132  case PT_32BSI:
133  return GDT_Int32;
134  case PT_32BUI:
135  return GDT_UInt32;
136  case PT_32BF:
137  return GDT_Float32;
138  case PT_64BF:
139  return GDT_Float64;
140  default:
141  return GDT_Unknown;
142  }
143 
144  return GDT_Unknown;
145 }
146 
156  switch (gdt) {
157  case GDT_Byte:
158  return PT_8BUI;
159  case GDT_UInt16:
160  return PT_16BUI;
161  case GDT_Int16:
162  return PT_16BSI;
163  case GDT_UInt32:
164  return PT_32BUI;
165  case GDT_Int32:
166  return PT_32BSI;
167  case GDT_Float32:
168  return PT_32BF;
169  case GDT_Float64:
170  return PT_64BF;
171  default:
172  return PT_END;
173  }
174 
175  return PT_END;
176 }
177 
178 /*
179  get GDAL runtime version information
180 */
181 const char*
182 rt_util_gdal_version(const char *request) {
183  if (NULL == request || !strlen(request))
184  return GDALVersionInfo("RELEASE_NAME");
185  else
186  return GDALVersionInfo(request);
187 }
188 
189 /*
190  computed extent type
191 */
193 rt_util_extent_type(const char *name) {
194  assert(name != NULL && strlen(name) > 0);
195 
196  if (strcmp(name, "UNION") == 0)
197  return ET_UNION;
198  else if (strcmp(name, "FIRST") == 0)
199  return ET_FIRST;
200  else if (strcmp(name, "SECOND") == 0)
201  return ET_SECOND;
202  else if (strcmp(name, "LAST") == 0)
203  return ET_LAST;
204  else if (strcmp(name, "CUSTOM") == 0)
205  return ET_CUSTOM;
206  else
207  return ET_INTERSECTION;
208 }
209 
210 /*
211  convert the spatial reference string from a GDAL recognized format to either WKT or Proj4
212 */
213 char*
214 rt_util_gdal_convert_sr(const char *srs, int proj4) {
215  OGRSpatialReferenceH hsrs;
216  char *rtn = NULL;
217 
218  assert(srs != NULL);
219 
220  hsrs = OSRNewSpatialReference(NULL);
221  if (OSRSetFromUserInput(hsrs, srs) == OGRERR_NONE) {
222  if (proj4)
223  OSRExportToProj4(hsrs, &rtn);
224  else
225  OSRExportToWkt(hsrs, &rtn);
226  }
227  else {
228  rterror("rt_util_gdal_convert_sr: Could not process the provided srs: %s", srs);
229  return NULL;
230  }
231 
232  OSRDestroySpatialReference(hsrs);
233  if (rtn == NULL) {
234  rterror("rt_util_gdal_convert_sr: Could not process the provided srs: %s", srs);
235  return NULL;
236  }
237 
238  return rtn;
239 }
240 
241 /*
242  is the spatial reference string supported by GDAL
243 */
244 int
245 rt_util_gdal_supported_sr(const char *srs) {
246  OGRSpatialReferenceH hsrs;
247  OGRErr rtn = OGRERR_NONE;
248 
249  assert(srs != NULL);
250 
251  hsrs = OSRNewSpatialReference(NULL);
252  rtn = OSRSetFromUserInput(hsrs, srs);
253  OSRDestroySpatialReference(hsrs);
254 
255  if (rtn == OGRERR_NONE)
256  return 1;
257  else
258  return 0;
259 }
260 
272 rt_util_gdal_sr_auth_info(GDALDatasetH hds, char **authname, char **authcode) {
273  const char *srs = NULL;
274 
275  assert(authname != NULL);
276  assert(authcode != NULL);
277 
278  *authname = NULL;
279  *authcode = NULL;
280 
281  srs = GDALGetProjectionRef(hds);
282  if (srs != NULL && srs[0] != '\0') {
283  OGRSpatialReferenceH hSRS = OSRNewSpatialReference(NULL);
284 
285  if (OSRSetFromUserInput(hSRS, srs) == OGRERR_NONE) {
286  const char* pszAuthorityName = OSRGetAuthorityName(hSRS, NULL);
287  const char* pszAuthorityCode = OSRGetAuthorityCode(hSRS, NULL);
288 
289  if (pszAuthorityName != NULL && pszAuthorityCode != NULL) {
290  size_t authorityName_len = strlen(pszAuthorityName) +1;
291  size_t authorityCode_len = strlen(pszAuthorityCode) + 1;
292  *authname = rtalloc(sizeof(char) * authorityName_len);
293  *authcode = rtalloc(sizeof(char) * authorityCode_len);
294 
295  if (*authname == NULL || *authcode == NULL) {
296  rterror("rt_util_gdal_sr_auth_info: Could not allocate memory for auth name and code");
297  if (*authname != NULL) rtdealloc(*authname);
298  if (*authcode != NULL) rtdealloc(*authcode);
299  OSRDestroySpatialReference(hSRS);
300  return ES_ERROR;
301  }
302 
303  strncpy(*authname, pszAuthorityName, authorityName_len);
304  strncpy(*authcode, pszAuthorityCode, authorityCode_len);
305  }
306  }
307 
308  OSRDestroySpatialReference(hSRS);
309  }
310 
311  return ES_NONE;
312 }
313 
314 /*
315  is GDAL configured correctly?
316 */
318 
319  /* set of EPSG codes */
320  if (!rt_util_gdal_supported_sr("EPSG:4326"))
321  return 0;
322  if (!rt_util_gdal_supported_sr("EPSG:4269"))
323  return 0;
324  if (!rt_util_gdal_supported_sr("EPSG:4267"))
325  return 0;
326  if (!rt_util_gdal_supported_sr("EPSG:3310"))
327  return 0;
328  if (!rt_util_gdal_supported_sr("EPSG:2163"))
329  return 0;
330 
331  return 1;
332 }
333 
334 /*
335  register all GDAL drivers
336 */
337 int
338 rt_util_gdal_register_all(int force_register_all) {
339  static int registered = 0;
340 
341  if (registered && !force_register_all) {
342  RASTER_DEBUG(3, "Already called once... not calling GDALAllRegister");
343  return 0;
344  }
345 
346  RASTER_DEBUG(3, "Calling GDALAllRegister");
347  GDALAllRegister();
348  registered = 1;
349 
350  return 1;
351 }
352 
353 /*
354  is the driver registered?
355 */
356 int
358  int count = GDALGetDriverCount();
359  int i = 0;
360  GDALDriverH hdrv = NULL;
361 
362  if (drv == NULL || !strlen(drv) || count < 1)
363  return 0;
364 
365  for (i = 0; i < count; i++) {
366  hdrv = GDALGetDriver(i);
367  if (hdrv == NULL) continue;
368 
369  if (strcmp(drv, GDALGetDriverShortName(hdrv)) == 0)
370  return 1;
371  }
372 
373  return 0;
374 }
375 
376 /* variable for PostgreSQL GUC: postgis.gdal_enabled_drivers */
377 char *gdal_enabled_drivers = NULL;
378 
379 /*
380  wrapper for GDALOpen and GDALOpenShared
381 */
382 GDALDatasetH
383 rt_util_gdal_open(const char *fn, GDALAccess fn_access, int shared) {
384  assert(NULL != fn);
385 
386  if (gdal_enabled_drivers != NULL) {
387  if (strstr(gdal_enabled_drivers, GDAL_DISABLE_ALL) != NULL) {
388  rterror("rt_util_gdal_open: Cannot open file. All GDAL drivers disabled");
389  return NULL;
390  }
391  else if (strstr(gdal_enabled_drivers, GDAL_ENABLE_ALL) != NULL) {
392  /* do nothing */
393  }
394  else if (
395  (strstr(fn, "/vsi") != NULL) &&
396  (strstr(fn, "/vsimem") == NULL) &&
397  (strstr(gdal_enabled_drivers, GDAL_VSICURL) == NULL)
398  ) {
399  rterror("rt_util_gdal_open: Cannot open %s file. %s disabled", GDAL_VSICURL, GDAL_VSICURL);
400  return NULL;
401  }
402  }
403 
404  if (shared)
405  return GDALOpenShared(fn, fn_access);
406  else
407  return GDALOpen(fn, fn_access);
408 }
409 
410 void
412  OGREnvelope env,
413  rt_envelope *ext
414 ) {
415  assert(ext != NULL);
416 
417  ext->MinX = env.MinX;
418  ext->MaxX = env.MaxX;
419  ext->MinY = env.MinY;
420  ext->MaxY = env.MaxY;
421 
422  ext->UpperLeftX = env.MinX;
423  ext->UpperLeftY = env.MaxY;
424 }
425 
426 void
428  rt_envelope ext,
429  OGREnvelope *env
430 ) {
431  assert(env != NULL);
432 
433  env->MinX = ext.MinX;
434  env->MaxX = ext.MaxX;
435  env->MinY = ext.MinY;
436  env->MaxY = ext.MaxY;
437 }
438 
439 LWPOLY *
441  rt_envelope env
442 ) {
443  LWPOLY *npoly = NULL;
444  POINTARRAY **rings = NULL;
445  POINTARRAY *pts = NULL;
446  POINT4D p4d;
447 
448  rings = (POINTARRAY **) rtalloc(sizeof (POINTARRAY*));
449  if (!rings) {
450  rterror("rt_util_envelope_to_lwpoly: Out of memory building envelope's geometry");
451  return NULL;
452  }
453  rings[0] = ptarray_construct(0, 0, 5);
454  if (!rings[0]) {
455  rterror("rt_util_envelope_to_lwpoly: Out of memory building envelope's geometry ring");
456  return NULL;
457  }
458 
459  pts = rings[0];
460 
461  /* Upper-left corner (first and last points) */
462  p4d.x = env.MinX;
463  p4d.y = env.MaxY;
464  ptarray_set_point4d(pts, 0, &p4d);
465  ptarray_set_point4d(pts, 4, &p4d);
466 
467  /* Upper-right corner (we go clockwise) */
468  p4d.x = env.MaxX;
469  p4d.y = env.MaxY;
470  ptarray_set_point4d(pts, 1, &p4d);
471 
472  /* Lower-right corner */
473  p4d.x = env.MaxX;
474  p4d.y = env.MinY;
475  ptarray_set_point4d(pts, 2, &p4d);
476 
477  /* Lower-left corner */
478  p4d.x = env.MinX;
479  p4d.y = env.MinY;
480  ptarray_set_point4d(pts, 3, &p4d);
481 
482  npoly = lwpoly_construct(SRID_UNKNOWN, 0, 1, rings);
483  if (npoly == NULL) {
484  rterror("rt_util_envelope_to_lwpoly: Could not build envelope's geometry");
485  return NULL;
486  }
487 
488  return npoly;
489 }
490 
491 int
492 rt_util_same_geotransform_matrix(double *gt1, double *gt2) {
493  int k = 0;
494 
495  if (gt1 == NULL || gt2 == NULL)
496  return FALSE;
497 
498  for (k = 0; k < 6; k++) {
499  if (FLT_NEQ(gt1[k], gt2[k]))
500  return FALSE;
501  }
502 
503  return TRUE;
504 }
505 
506 /* coordinates in RGB and HSV are floating point values between 0 and 1 */
508 rt_util_rgb_to_hsv(double rgb[3], double hsv[3]) {
509  int i;
510 
511  double minc;
512  double maxc;
513 
514  double h = 0.;
515  double s = 0.;
516  double v = 0.;
517 
518  minc = rgb[0];
519  maxc = rgb[0];
520 
521  /* get min and max values from RGB */
522  for (i = 1; i < 3; i++) {
523  if (rgb[i] > maxc)
524  maxc = rgb[i];
525  if (rgb[i] < minc)
526  minc = rgb[i];
527  }
528  v = maxc;
529 
530  if (maxc != minc) {
531  double diff = 0.;
532  double rc = 0.;
533  double gc = 0.;
534  double bc = 0.;
535  double junk = 0.;
536 
537  diff = maxc - minc;
538  s = diff / maxc;
539  rc = (maxc - rgb[0]) / diff;
540  gc = (maxc - rgb[1]) / diff;
541  bc = (maxc - rgb[2]) / diff;
542 
543  if (DBL_EQ(rgb[0], maxc))
544  h = bc - gc;
545  else if (DBL_EQ(rgb[1], maxc))
546  h = 2.0 + rc - bc;
547  else
548  h = 4.0 + gc - rc;
549 
550  h = modf((h / 6.0), &junk);
551  }
552 
553  hsv[0] = h;
554  hsv[1] = s;
555  hsv[2] = v;
556 
557  return ES_NONE;
558 }
559 
560 /* coordinates in RGB and HSV are floating point values between 0 and 1 */
562 rt_util_hsv_to_rgb(double hsv[3], double rgb[3]) {
563  double r = 0;
564  double g = 0;
565  double b = 0;
566  double v = hsv[2];
567 
568  if (DBL_EQ(hsv[1], 0.))
569  r = g = b = v;
570  else {
571  double i;
572  double f;
573  double p;
574  double q;
575  double t;
576 
577  int a;
578 
579  i = floor(hsv[0] * 6.);
580  f = (hsv[0] * 6.0) - i;
581  p = v * (1. - hsv[1]);
582  q = v * (1. - hsv[1] * f);
583  t = v * (1. - hsv[1] * (1. - f));
584 
585  a = (int) i;
586  switch (a) {
587  case 1:
588  r = q;
589  g = v;
590  b = p;
591  break;
592  case 2:
593  r = p;
594  g = v;
595  b = t;
596  break;
597  case 3:
598  r = p;
599  g = q;
600  b = v;
601  break;
602  case 4:
603  r = t;
604  g = p;
605  b = v;
606  break;
607  case 5:
608  r = v;
609  g = p;
610  b = q;
611  break;
612  case 0:
613  case 6:
614  default:
615  r = v;
616  g = t;
617  b = p;
618  break;
619  }
620  }
621 
622  rgb[0] = r;
623  rgb[1] = g;
624  rgb[2] = b;
625 
626  return ES_NONE;
627 }
628 
629 int
631  double initialvalue,
632  int32_t checkvalint, uint32_t checkvaluint,
633  float checkvalfloat, double checkvaldouble,
634  rt_pixtype pixtype
635 ) {
636  int result = 0;
637 
638  switch (pixtype) {
639  case PT_1BB:
640  case PT_2BUI:
641  case PT_4BUI:
642  case PT_8BSI:
643  case PT_8BUI:
644  case PT_16BSI:
645  case PT_16BUI:
646  case PT_32BSI: {
647  if (fabs(checkvalint - initialvalue) >= 1) {
648 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
649  rtwarn("Value set for %s band got clamped from %f to %d",
650  rt_pixtype_name(pixtype),
651  initialvalue, checkvalint
652  );
653 #endif
654  result = 1;
655  }
656  else if (checkvalint != initialvalue)
657  {
658 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
659  rtwarn("Value set for %s band got truncated from %f to %d",
660  rt_pixtype_name(pixtype),
661  initialvalue, checkvalint
662  );
663 #endif
664  result = 1;
665  }
666  break;
667  }
668  case PT_32BUI: {
669  if (fabs(checkvaluint - initialvalue) >= 1) {
670 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
671  rtwarn("Value set for %s band got clamped from %f to %u",
672  rt_pixtype_name(pixtype),
673  initialvalue, checkvaluint
674  );
675 #endif
676  result = 1;
677  }
678  else if (checkvaluint != initialvalue)
679  {
680 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
681  rtwarn("Value set for %s band got truncated from %f to %u",
682  rt_pixtype_name(pixtype),
683  initialvalue, checkvaluint
684  );
685 #endif
686  result = 1;
687  }
688  break;
689  }
690  case PT_32BF: {
691  /*
692  For float, because the initial value is a double,
693  there is very often a difference between the desired value and the obtained one
694  */
695  if (FLT_NEQ(checkvalfloat, initialvalue)) {
696 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
697  rtwarn("Value set for %s band got converted from %f to %f",
698  rt_pixtype_name(pixtype),
699  initialvalue, checkvalfloat
700  );
701 #endif
702  result = 1;
703  }
704  break;
705  }
706  case PT_64BF: {
707  if (FLT_NEQ(checkvaldouble, initialvalue)) {
708 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
709  rtwarn("Value set for %s band got converted from %f to %f",
710  rt_pixtype_name(pixtype),
711  initialvalue, checkvaldouble
712  );
713 #endif
714  result = 1;
715  }
716  break;
717  }
718  case PT_END:
719  break;
720  }
721 
722  return result;
723 }
724 
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:229
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:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
#define FLT_NEQ(x, y)
Definition: librtcore.h:2234
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:295
rt_pixtype
Definition: librtcore.h:185
@ PT_32BUI
Definition: librtcore.h:194
@ PT_2BUI
Definition: librtcore.h:187
@ PT_32BSI
Definition: librtcore.h:193
@ PT_END
Definition: librtcore.h:197
@ PT_4BUI
Definition: librtcore.h:188
@ PT_32BF
Definition: librtcore.h:195
@ PT_1BB
Definition: librtcore.h:186
@ PT_16BUI
Definition: librtcore.h:192
@ PT_8BSI
Definition: librtcore.h:189
@ PT_16BSI
Definition: librtcore.h:191
@ PT_64BF
Definition: librtcore.h:196
@ PT_8BUI
Definition: librtcore.h:190
#define POSTGIS_RT_4BUIMAX
Definition: librtcore.h:2062
void rtwarn(const char *fmt,...)
Definition: rt_context.c:224
rt_errorstate
Enum definitions.
Definition: librtcore.h:179
@ ES_NONE
Definition: librtcore.h:180
@ ES_ERROR
Definition: librtcore.h:181
#define DBL_EQ(x, y)
Definition: librtcore.h:2237
#define GDAL_ENABLE_ALL
Definition: librtcore.h:2048
#define GDAL_DISABLE_ALL
Definition: librtcore.h:2049
#define GDAL_VSICURL
Definition: librtcore.h:2050
rt_extenttype
Definition: librtcore.h:200
@ ET_CUSTOM
Definition: librtcore.h:206
@ ET_LAST
Definition: librtcore.h:205
@ ET_INTERSECTION
Definition: librtcore.h:201
@ ET_UNION
Definition: librtcore.h:202
@ ET_SECOND
Definition: librtcore.h:204
@ ET_FIRST
Definition: librtcore.h:203
#define POSTGIS_RT_2BUIMAX
Definition: librtcore.h:2061
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_pixel.c:110
#define POSTGIS_RT_1BBMAX
Definition: librtcore.h:2060
void rtdealloc(void *mem)
Definition: rt_context.c:186
This library is the generic raster handling section of PostGIS.
int value
Definition: genraster.py:62
int count
Definition: genraster.py:57
rt_pixtype rt_util_gdal_datatype_to_pixtype(GDALDataType gdt)
Convert GDALDataType to rt_pixtype.
Definition: rt_util.c:155
rt_errorstate rt_util_rgb_to_hsv(double rgb[3], double hsv[3])
Definition: rt_util.c:508
int rt_util_gdal_register_all(int force_register_all)
Definition: rt_util.c:338
int rt_util_gdal_configured(void)
Definition: rt_util.c:317
int8_t rt_util_clamp_to_8BSI(double value)
Definition: rt_util.c:49
uint8_t rt_util_clamp_to_1BB(double value)
Definition: rt_util.c:34
int32_t rt_util_clamp_to_32BSI(double value)
Definition: rt_util.c:69
char * rt_util_gdal_convert_sr(const char *srs, int proj4)
Definition: rt_util.c:214
const char * rt_util_gdal_version(const char *request)
Definition: rt_util.c:182
rt_extenttype rt_util_extent_type(const char *name)
Definition: rt_util.c:193
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:630
GDALDataType rt_util_pixtype_to_gdal_datatype(rt_pixtype pt)
Convert rt_pixtype to GDALDataType.
Definition: rt_util.c:120
uint8_t rt_util_clamp_to_2BUI(double value)
Definition: rt_util.c:39
uint8_t rt_util_clamp_to_8BUI(double value)
Definition: rt_util.c:54
GDALDatasetH rt_util_gdal_open(const char *fn, GDALAccess fn_access, int shared)
Definition: rt_util.c:383
int rt_util_gdal_supported_sr(const char *srs)
Definition: rt_util.c:245
int16_t rt_util_clamp_to_16BSI(double value)
Definition: rt_util.c:59
GDALResampleAlg rt_util_gdal_resample_alg(const char *algname)
Convert cstring name to GDAL Resample Algorithm.
Definition: rt_util.c:93
int rt_util_gdal_driver_registered(const char *drv)
Definition: rt_util.c:357
uint8_t rt_util_clamp_to_4BUI(double value)
Definition: rt_util.c:44
rt_errorstate rt_util_hsv_to_rgb(double hsv[3], double rgb[3])
Definition: rt_util.c:562
void rt_util_to_ogr_envelope(rt_envelope ext, OGREnvelope *env)
Definition: rt_util.c:427
rt_errorstate rt_util_gdal_sr_auth_info(GDALDatasetH hds, char **authname, char **authcode)
Get auth name and code.
Definition: rt_util.c:272
uint16_t rt_util_clamp_to_16BUI(double value)
Definition: rt_util.c:64
uint32_t rt_util_clamp_to_32BUI(double value)
Definition: rt_util.c:74
LWPOLY * rt_util_envelope_to_lwpoly(rt_envelope env)
Definition: rt_util.c:440
char * gdal_enabled_drivers
Definition: rt_util.c:377
int rt_util_same_geotransform_matrix(double *gt1, double *gt2)
Definition: rt_util.c:492
float rt_util_clamp_to_32F(double value)
Definition: rt_util.c:79
void rt_util_from_ogr_envelope(OGREnvelope env, rt_envelope *ext)
Definition: rt_util.c:411
double x
Definition: liblwgeom.h:428
double y
Definition: liblwgeom.h:428
double MinX
Definition: librtcore.h:165
double UpperLeftY
Definition: librtcore.h:171
double UpperLeftX
Definition: librtcore.h:170
double MaxX
Definition: librtcore.h:166
double MinY
Definition: librtcore.h:167
double MaxY
Definition: librtcore.h:168