[postgis-commits] svn - r3618 - spike/wktraster/rt_core
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Mon Feb 2 11:22:43 PST 2009
Author: strk
Date: 2009-02-02 11:22:43 -0800 (Mon, 02 Feb 2009)
New Revision: 3618
Modified:
spike/wktraster/rt_core/rt_api.c
spike/wktraster/rt_core/testwkb.c
Log:
Add naive test for serialization/deserialization - drop use of TYPEALIGN (assumed it would have done something different)
Modified: spike/wktraster/rt_core/rt_api.c
===================================================================
--- spike/wktraster/rt_core/rt_api.c 2009-02-02 18:26:53 UTC (rev 3617)
+++ spike/wktraster/rt_core/rt_api.c 2009-02-02 19:22:43 UTC (rev 3618)
@@ -179,11 +179,6 @@
/*- rt_pixeltype -----------------------------------------------------*/
-#ifndef TYPEALIGN
-# define TYPEALIGN(ALIGNVAL,LEN) \
- (((long) (LEN) + ((ALIGNVAL) - 1)) & ~((long) ((ALIGNVAL) - 1)))
-#endif
-
int
rt_pixtype_size(rt_context ctx, rt_pixtype pixtype)
{
@@ -2134,6 +2129,9 @@
uint32_t size = sizeof(struct rt_raster_serialized_t);
uint16_t i;
+ printf("Serialized size with just header:%d - now adding size of %d bands\n",
+ size, raster->numBands);
+
for (i=0; i<raster->numBands; ++i)
{
rt_band band = raster->bands[i];
@@ -2166,9 +2164,10 @@
size += pixbytes*raster->width*raster->height;
}
-
+ printf("Size before alignment is %d\n", size);
/* Align size to 8-bytes boundary (trailing padding) */
- size = TYPEALIGN(size, 8);
+ size += 8 - (size%8);
+ printf("Size after alignment is %d\n", size);
}
return size;
@@ -2192,6 +2191,12 @@
ptr = ret;
+ printf("sizeof(struct rt_raster_serialized_t):%d\n",
+ sizeof(struct rt_raster_serialized_t));
+ printf("sizeof(struct rt_raster_t):%d\n",
+ sizeof(struct rt_raster_t));
+ printf("serialized size:%d\n", size);
+
/* Set size */
raster->size = size;
Modified: spike/wktraster/rt_core/testwkb.c
===================================================================
--- spike/wktraster/rt_core/testwkb.c 2009-02-02 18:26:53 UTC (rev 3617)
+++ spike/wktraster/rt_core/testwkb.c 2009-02-02 19:22:43 UTC (rev 3618)
@@ -61,9 +61,23 @@
/* would depend on machine endian...
CHECK( ! strcmp(hexwkb, out) );
*/
- rt_raster_destroy(ctx, raster);
free(out);
+ {
+ void *serialized;
+ uint32_t serializedSize;
+ rt_raster rast2;
+
+ serialized = rt_raster_serialize(ctx, raster);
+ rast2 = rt_raster_deserialize(ctx, serialized);
+
+ rt_raster_destroy(ctx, rast2);
+ free(serialized);
+
+ }
+
+ rt_raster_destroy(ctx, raster);
+
/* ------------------------------------------------------ */
/* No bands, 7x8 - big endian */
/* ------------------------------------------------------ */
@@ -224,9 +238,23 @@
CHECK( ! strcmp(hexwkb, out) );
*/
- rt_raster_destroy(ctx, raster);
free(out);
+ {
+ void *serialized;
+ uint32_t serializedSize;
+ rt_raster rast2;
+
+ serialized = rt_raster_serialize(ctx, raster);
+ rast2 = rt_raster_deserialize(ctx, serialized);
+
+ rt_raster_destroy(ctx, rast2);
+ free(serialized);
+
+ }
+
+ rt_raster_destroy(ctx, raster);
+
/* ------------------------------------------------------ */
/* 3x2, little endian, band0(16BSI) */
/* ------------------------------------------------------ */
More information about the postgis-commits
mailing list