[postgis-commits] svn - r3610 - spike/wktraster/rt_core

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Mon Feb 2 06:29:30 PST 2009


Author: strk
Date: 2009-02-02 06:29:30 -0800 (Mon, 02 Feb 2009)
New Revision: 3610

Modified:
   spike/wktraster/rt_core/testwkb.c
Log:
test some bands, both endianness, 16int

Modified: spike/wktraster/rt_core/testwkb.c
===================================================================
--- spike/wktraster/rt_core/testwkb.c	2009-02-02 13:50:52 UTC (rev 3609)
+++ spike/wktraster/rt_core/testwkb.c	2009-02-02 14:29:30 UTC (rev 3610)
@@ -158,7 +158,7 @@
     {
         rt_band band = rt_raster_get_band(ctx, raster, 0);
         CHECK(band);
-        CHECK_EQUALS(rt_band_get_pixtype(ctx, band), PT_1BB);
+        CHECK_EQUALS(rt_band_get_pixtype(ctx, band), PT_8BSI);
         CHECK(!rt_band_is_offline(ctx, band));
         CHECK_EQUALS(rt_band_get_nodata(ctx, band), -1);
         CHECK_EQUALS(rt_band_get_pixel(ctx, band, 0, 0), -1);
@@ -171,6 +171,108 @@
 
     /* ------------------------------------------------------ */
 
+    hexwkb =
+"01"               /* little endian (uint8 ndr) */
+"0000"             /* version (uint16 0) */
+"0100"             /* nBands (uint16 1) */
+"000000000000F03F" /* scaleX (float64 1) */
+"0000000000000040" /* scaleY (float64 2) */
+"0000000000000840" /* ipX (float64 3) */
+"0000000000001040" /* ipY (float64 4) */
+"0000000000001440" /* skewX (float64 5) */
+"0000000000001840" /* skewY (float64 6) */
+"0A000000"         /* SRID (int32 10) */
+"0300"             /* width (uint16 3) */
+"0200"             /* height (uint16 2) */
+"05"               /* First band type (16BSI, in memory) */
+"FFFF"               /* nodata value (-1) */
+"FFFF"               /* pix(0,0) == -1 */
+"0000"               /* pix(1,0) ==  0 */
+"F0FF"               /* pix(2,0) == -16 */
+"7F00"               /* pix(0,1) == 127 */
+"0A00"               /* pix(1,1) == 10 */
+"0200"               /* pix(2,1) == 2 */
+    ;
+
+    raster = rt_raster_from_hexwkb(ctx, hexwkb, strlen(hexwkb));
+    CHECK(raster);
+    CHECK_EQUALS(rt_raster_get_num_bands(ctx, raster), 1);
+    CHECK_EQUALS(rt_raster_get_pixel_width(ctx, raster), 1);
+    CHECK_EQUALS(rt_raster_get_pixel_height(ctx, raster), 2);
+    CHECK_EQUALS(rt_raster_get_x_offset(ctx, raster), 3);
+    CHECK_EQUALS(rt_raster_get_y_offset(ctx, raster), 4);
+    CHECK_EQUALS(rt_raster_get_x_rotation(ctx, raster), 5);
+    CHECK_EQUALS(rt_raster_get_y_rotation(ctx, raster), 6);
+    CHECK_EQUALS(rt_raster_get_srid(ctx, raster), 10);
+    CHECK_EQUALS(rt_raster_get_width(ctx, raster), 3);
+    CHECK_EQUALS(rt_raster_get_height(ctx, raster), 2);
+    {
+        rt_band band = rt_raster_get_band(ctx, raster, 0);
+        CHECK(band);
+        CHECK_EQUALS(rt_band_get_pixtype(ctx, band), PT_16BSI);
+        CHECK(!rt_band_is_offline(ctx, band));
+        CHECK_EQUALS(rt_band_get_nodata(ctx, band), -1);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 0, 0), -1);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 1, 0), 0);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 2, 0), -16);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 0, 1), 127);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 1, 1), 10);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 2, 1), 2);
+    }
+
+    /* ------------------------------------------------------ */
+
+    hexwkb =
+"00"               /* big endian (uint8 xdr) */
+"0000"             /* version (uint16 0) */
+"0001"             /* nBands (uint16 1) */
+"3FF0000000000000" /* scaleX (float64 1) */
+"4000000000000000" /* scaleY (float64 2) */
+"4008000000000000" /* ipX (float64 3) */
+"4010000000000000" /* ipY (float64 4) */
+"4014000000000000" /* skewX (float64 5) */
+"4018000000000000" /* skewY (float64 6) */
+"0000000A"         /* SRID (int32 10) */
+"0003"             /* width (uint16 3) */
+"0002"             /* height (uint16 2) */
+"05"               /* First band type (16BSI, in memory) */
+"FFFF"               /* nodata value (-1) */
+"FFFF"               /* pix(0,0) == -1 */
+"0000"               /* pix(1,0) ==  0 */
+"FFF0"               /* pix(2,0) == -16 */
+"007F"               /* pix(0,1) == 127 */
+"000A"               /* pix(1,1) == 10 */
+"0002"               /* pix(2,1) == 2 */
+    ;
+
+    raster = rt_raster_from_hexwkb(ctx, hexwkb, strlen(hexwkb));
+    CHECK(raster);
+    CHECK_EQUALS(rt_raster_get_num_bands(ctx, raster), 1);
+    CHECK_EQUALS(rt_raster_get_pixel_width(ctx, raster), 1);
+    CHECK_EQUALS(rt_raster_get_pixel_height(ctx, raster), 2);
+    CHECK_EQUALS(rt_raster_get_x_offset(ctx, raster), 3);
+    CHECK_EQUALS(rt_raster_get_y_offset(ctx, raster), 4);
+    CHECK_EQUALS(rt_raster_get_x_rotation(ctx, raster), 5);
+    CHECK_EQUALS(rt_raster_get_y_rotation(ctx, raster), 6);
+    CHECK_EQUALS(rt_raster_get_srid(ctx, raster), 10);
+    CHECK_EQUALS(rt_raster_get_width(ctx, raster), 3);
+    CHECK_EQUALS(rt_raster_get_height(ctx, raster), 2);
+    {
+        rt_band band = rt_raster_get_band(ctx, raster, 0);
+        CHECK(band);
+        CHECK_EQUALS(rt_band_get_pixtype(ctx, band), PT_16BSI);
+        CHECK(!rt_band_is_offline(ctx, band));
+        CHECK_EQUALS(rt_band_get_nodata(ctx, band), -1);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 0, 0), -1);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 1, 0), 0);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 2, 0), -16);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 0, 1), 127);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 1, 1), 10);
+        CHECK_EQUALS(rt_band_get_pixel(ctx, band, 2, 1), 2);
+    }
+
+    /* ------------------------------------------------------ */
+
     printf("All tests successful !\n");
 
     return EXIT_SUCCESS;



More information about the postgis-commits mailing list