Changeset: 3481d4191ff8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3481d4191ff8
Modified Files:
        sql/backends/monet5/UDF/ssdb.c
Branch: ssdb
Log Message:

Fixed the condition to detect image boundaries.

This solves the problem that given 20 images, only 10 images are regrid


diffs (88 lines):

diff --git a/sql/backends/monet5/UDF/ssdb.c b/sql/backends/monet5/UDF/ssdb.c
--- a/sql/backends/monet5/UDF/ssdb.c
+++ b/sql/backends/monet5/UDF/ssdb.c
@@ -988,7 +988,10 @@ SSDBregrid(Client cntxt, MalBlkPtr mb, M
        BAT *tin_imageid = NULL, *tin_x = NULL, *tin_y = NULL, *tin_val = NULL;
        BAT *tout_imageid = NULL, *tout_x = NULL, *tout_y = NULL, *tout_avgval 
= NULL;
 
-       BUN idx = 0, nr_points = 0, size=0,out_elements = 0, step = 0,j=0, 
nr_x_tiles=0,nr_y_tiles=0;
+       BUN idx = 0, nr_points = 0, size=0, out_elements = 0, step = 0, j=0, 
nr_x_tiles=0, nr_y_tiles=0;
+       BUN row1_0 = 0, row1_1 = 0, row1_2 = 0, row1_3 = 0, /* offsets */
+           row2_0 = 0, row2_1 = 0, row2_2 = 0, row2_3 = 0,
+           row3_0 = 0, row3_1 = 0, row3_2 = 0, row3_3 = 0;
        int *tin_imageid_t = NULL, *tin_x_t = NULL, *tin_y_t = NULL, *tin_val_t 
= NULL;
        int *tout_imageid_t = NULL, *tout_x_t = NULL, *tout_y_t = NULL;
        dbl *tout_avgval_t = NULL;
@@ -1036,48 +1039,53 @@ SSDBregrid(Client cntxt, MalBlkPtr mb, M
 
        nr_points = BATcount(tin_imageid);
        /* Create BATs for all columns of the output table 'tout' */
-        tout_imageid = BATnew(TYPE_void, TYPE_int, nr_points);
+       tout_imageid = BATnew(TYPE_void, TYPE_int, nr_points);
        tout_x = BATnew(TYPE_void, TYPE_int, nr_points);
        tout_y = BATnew(TYPE_void, TYPE_int, nr_points);
        tout_avgval = BATnew(TYPE_void, TYPE_dbl, nr_points);
-        /* pointers directly to the BATs' tails */
-        tout_imageid_t = (int*)Tloc(tout_imageid, BUNfirst(tout_imageid));
+       //* pointers directly to the BATs' tails */
+       tout_imageid_t = (int*)Tloc(tout_imageid, BUNfirst(tout_imageid));
        tout_x_t = (int*)Tloc(tout_x, BUNfirst(tout_x));
        tout_y_t = (int*)Tloc(tout_y, BUNfirst(tout_y));
        tout_avgval_t = (dbl*)Tloc(tout_avgval, BUNfirst(tout_avgval));
 
        size = tin_x_t[nr_points-1]+1;  /*imgsize*/
        step = size * 3;
+       row1_0 = size;     row1_1 = size + 1;     row1_2 = size + 2;     row1_3 
= size + 3;
+       row2_0 = size * 2; row2_1 = size * 2 + 1; row2_2 = size * 2 + 1; row2_3 
= size * 2 + 3;
+       row3_0 = size * 3; row3_1 = size * 3 + 1; row3_2 = size * 3 + 1; row3_3 
= size * 3 + 3;
 
        for(idx=0; idx < nr_points; idx=idx+step)
        {
                dbl sum; 
                if(nr_y_tiles<(size/4+1))
                {
-                       if(idx>0 && (idx+size)%100==0)
+                       if((idx+size)%100==0)
                                idx=idx+size;
 
-                       for(j=idx; j < idx+size; j=j+3)
+                       for(j=idx; j < idx+size && nr_x_tiles<(size/4+1); 
j=j+3, nr_x_tiles++)
                        {
-                               if(j>0 && (j+1)%10==0)
+                               if((j+1)%10==0)
                                        j=j+1;
 
-                               if(nr_x_tiles<(size/4+1))
-                               {
-                                       tout_imageid_t[out_elements] = 
tin_imageid_t[j];
-                                       tout_x_t[out_elements] = tin_x_t[j];
-                                       tout_y_t[out_elements] = tin_y_t[j];
-                                       sum = tin_val_t[j] + tin_val_t[j+1] + 
tin_val_t[j+2] + tin_val_t[j+3] + tin_val_t[j+size] + tin_val_t[j+size+1] + 
tin_val_t[j+size+2] + tin_val_t[j+size+3] + tin_val_t[j+2*size] + 
tin_val_t[j+2*size+1] + tin_val_t[j+2*size+2] + tin_val_t[j+2*size+3] + 
tin_val_t[j+3*size] + tin_val_t[j+3*size+1] + tin_val_t[j+3*size+2] + 
tin_val_t[j+3*size+3];
-                                       tout_avgval_t[out_elements] = sum/16.0; 
 /*each tile contains 4*4=16 values*/
-                                       out_elements++;
-                                       nr_x_tiles++;
-                               }
+                               tout_imageid_t[out_elements] = tin_imageid_t[j];
+                               tout_x_t[out_elements] = tin_x_t[j];
+                               tout_y_t[out_elements] = tin_y_t[j];
+                               sum = tin_val_t[j] + tin_val_t[j+1] + 
tin_val_t[j+2] + tin_val_t[j+3] +
+                                         tin_val_t[j+row1_0] + 
tin_val_t[j+row1_1] + tin_val_t[j+row1_2] + tin_val_t[j+row1_3] +
+                                         tin_val_t[j+row2_0] + 
tin_val_t[j+row2_1] + tin_val_t[j+row2_2] + tin_val_t[j+row2_3] +
+                                         tin_val_t[j+row3_0] + 
tin_val_t[j+row3_1] + tin_val_t[j+row3_2] + tin_val_t[j+row3_3];
+                               tout_avgval_t[out_elements] = sum/16.0;  /*each 
tile contains 4*4=16 values*/
+                               out_elements++;
                        }
                        nr_x_tiles=0;
+                       nr_y_tiles++;
                }
-               nr_y_tiles++;
-               if((idx<(nr_points-idx-step)) && 
tin_imageid_t[idx]!=tin_imageid_t[idx+step+size])
-                        nr_y_tiles=0;
+               /* check for image boundary, only works for the 10:3 regrid 
ratio */
+               if(tin_imageid_t[idx]!=tin_imageid_t[idx+size]) {
+                       nr_y_tiles=0;
+                       idx -= 2*size;
+               }
        }
 
 
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to