PostGIS: test

您所在的位置:网站首页 gdal读写tif PostGIS: test

PostGIS: test

2023-04-09 06:18| 来源: 网络整理| 查看: 265

Definition at line 357 of file cu_gdal.c.

357  { 358  rt_pixtype pixtype = PT_64BF; 359  rt_raster raster = NULL; 360  rt_band band = NULL; 361  uint32_t x; 362  uint32_t width = 100; 363  uint32_t y; 364  uint32_t height = 100; 365  char srs[] = "PROJCS[\"unnamed\",GEOGCS[\"unnamed ellipse\",DATUM[\"unknown\",SPHEROID[\"unnamed\",6370997,0]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"latitude_of_center\",45],PARAMETER[\"longitude_of_center\",-100],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"2163\"]]"; 366  367  uint64_t gdalSize; 368  uint8_t *gdal = NULL; 369  370  raster = rt_raster_new(width, height); 371  CU_ASSERT(raster != NULL); /* or we're out of virtual memory */ 372  373  band = cu_add_band(raster, pixtype, 1, 0); 374  CU_ASSERT(band != NULL); 375  376  rt_raster_set_offsets(raster, -500000, 600000); 377  rt_raster_set_scale(raster, 1000, -1000); 378  379  for (x = 0; x < width; x++) { 380  for (y = 0; y < height; y++) { 381  rt_band_set_pixel(band, x, y, (((double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL); 382  } 383  } 384  385  gdal = rt_raster_to_gdal(raster, srs, "GTiff", NULL, &gdalSize); 386  /*printf("gdalSize: %d\n", (int) gdalSize);*/ 387  CU_ASSERT(gdalSize); 388  389  /* 390  FILE *fh = NULL; 391  fh = fopen("/tmp/out.tif", "w"); 392  fwrite(gdal, sizeof(uint8_t), gdalSize, fh); 393  fclose(fh); 394  */ 395  396  if (gdal) CPLFree(gdal); 397  398  cu_free_raster(raster); 399  400  raster = rt_raster_new(width, height); 401  CU_ASSERT(raster != NULL); /* or we're out of virtual memory */ 402  403  band = cu_add_band(raster, pixtype, 1, 0); 404  CU_ASSERT(band != NULL); 405  406  rt_raster_set_offsets(raster, -500000, 600000); 407  rt_raster_set_scale(raster, 1000, -1000); 408  409  for (x = 0; x < width; x++) { 410  for (y = 0; y < height; y++) { 411  rt_band_set_pixel(band, x, y, x, NULL); 412  } 413  } 414  415  /* add check that band isn't NODATA */ 416  CU_ASSERT_EQUAL(rt_band_check_is_nodata(band), FALSE); 417  418  gdal = rt_raster_to_gdal(raster, srs, "PNG", NULL, &gdalSize); 419  /*printf("gdalSize: %d\n", (int) gdalSize);*/ 420  CU_ASSERT(gdalSize); 421  422  if (gdal) CPLFree(gdal); 423  424  gdal = rt_raster_to_gdal(raster, srs, "PCIDSK", NULL, &gdalSize); 425  CU_ASSERT(gdal == NULL); 426  427  cu_free_raster(raster); 428 } FALSE#define FALSEDefinition: dbfopen.c:72 rt_raster_set_scalevoid rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)Set scale in projection units.Definition: rt_raster.c:141 rt_raster_to_gdaluint8_t * rt_raster_to_gdal(rt_raster raster, const char *srs, char *format, char **options, uint64_t *gdalsize)Return formatted GDAL raster from raster.Definition: rt_raster.c:1720 rt_pixtypert_pixtypeDefinition: librtcore.h:187 PT_64BF@ PT_64BFDefinition: librtcore.h:198 rt_raster_newrt_raster rt_raster_new(uint32_t width, uint32_t height)Construct a raster with given dimensions.Definition: rt_raster.c:52 rt_band_check_is_nodataint rt_band_check_is_nodata(rt_band band)Returns TRUE if the band is only nodata values.Definition: rt_band.c:1908 rt_band_set_pixelrt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)Set single pixel's value.Definition: rt_band.c:974 rt_raster_set_offsetsvoid rt_raster_set_offsets(rt_raster raster, double x, double y)Set insertion points in projection units.Definition: rt_raster.c:203 ovdump.bandbandDefinition: ovdump.py:58 pixval.yyDefinition: pixval.py:55 pixval.xxDefinition: pixval.py:54 rtrowdump.rasterrasterBe careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...Definition: rtrowdump.py:121 cu_add_bandrt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)Definition: raster/test/cunit/cu_tester.c:224 cu_free_rastervoid cu_free_raster(rt_raster raster)Definition: raster/test/cunit/cu_tester.c:211 rt_band_tDefinition: librtcore.h:2459 rt_raster_tDefinition: librtcore.h:2430

References ovdump::band, cu_add_band(), cu_free_raster(), FALSE, PT_64BF, rtrowdump::raster, rt_band_check_is_nodata(), rt_band_set_pixel(), rt_raster_new(), rt_raster_set_offsets(), rt_raster_set_scale(), rt_raster_to_gdal(), pixval::x, and pixval::y.

Referenced by gdal_suite_setup().

Here is the call graph for this function: Here is the caller graph for this function:


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3