536 {
537 const char *filename = POSTGIS_TOP_SRC_DIR "/raster/test/regress/loader/Projected.tif";
538
539 GDALDatasetH hDS_in = NULL;
542 int band_count_in, band_count_out, i;
543
544
545
546
547
548
549
550 double max_err = 0.125;
551 GDALResampleAlg alg = GRA_NearestNeighbour;
552
553 const char *src_srs = "EPSG:4326";
554 const char *dst_srs = "EPSG:3857";
555
556
557 GDALAllRegister();
558 hDS_in = GDALOpen(filename, GA_ReadOnly);
559 CU_ASSERT(hDS_in != NULL);
560
561
563 CU_ASSERT(rast_in != NULL);
564
565
567 src_srs, dst_srs,
568 NULL, NULL,
569 NULL, NULL,
570 NULL, NULL,
571 NULL, NULL,
572 NULL, NULL,
573 alg, max_err);
574 CU_ASSERT(rast_out != NULL);
575
578 CU_ASSERT_EQUAL(band_count_in, band_count_out);
579
580 for (i = 0; i < band_count_in; i++) {
581 double tolerance = 0.1;
585
586 CU_ASSERT(band_in != NULL);
587 CU_ASSERT(band_out != NULL);
588
591
592 CU_ASSERT_DOUBLE_EQUAL(stats_in->
min, stats_out->
min, fabs(stats_in->
min) * tolerance);
593 CU_ASSERT_DOUBLE_EQUAL(stats_in->
max, stats_out->
max, fabs(stats_in->
max) * tolerance);
594 CU_ASSERT_DOUBLE_EQUAL(stats_in->
mean, stats_out->
mean, fabs(stats_in->
mean) * tolerance);
595 }
596
599 GDALClose(hDS_in);
600}
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds)
Return a raster from a GDAL dataset.
uint16_t rt_raster_get_num_bands(rt_raster raster)
rt_raster rt_raster_gdal_warp(rt_raster raster, const char *src_srs, const char *dst_srs, double *scale_x, double *scale_y, int *width, int *height, double *ul_xw, double *ul_yw, double *grid_xw, double *grid_yw, double *skew_x, double *skew_y, GDALResampleAlg resample_alg, double max_err)
Return a warped raster using GDAL Warp API.
rt_bandstats rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample, int inc_vals, uint64_t *cK, double *cM, double *cQ)
Compute summary statistics for a band.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.