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