Changeset 5558

Show
Ignore:
Timestamp:
04/15/10 11:06:29 (2 years ago)
Author:
jorgearevalo
Message:

Small bug fixed in testcore: CHECK_EQUALS_DOUBLE instead of CHECK_EQUALS.
Added extra debug info in rtreader.py and rt_pg.c (to help fixing

RASTER_dumpAsWKTPolygons function)

Location:
spike/wktraster
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • spike/wktraster/configure.ac

    r5475 r5558  
    396396AC_SUBST([POSTGIS_RASTER_PGSQL_VERSION]) 
    397397 
    398 dnl ========================================================================= 
     398dnl ======================================================================== 
    399399dnl DEVELOPMENT OPTION: Determine GDAL Support 
    400400dnl 
     
    409409dnl LIBGDAL_CFLAGS="-I$with_gdal/port -I$with_gdal/ogr -I$with_gdal/alg -I$with_gdal/gcore -I$with_gdal/frmts " 
    410410dnl LIBGDAL_LDFLAGS="-L${with_gdal}/.libs -lgdal -L${with_gdal}/ -lgdal" 
    411 dnl ========================================================================= 
     411dnl ======================================================================== 
    412412ENABLE_DEVELOPMENT_CFLAGS="" 
    413413enable_development_msg="" 
  • spike/wktraster/rt_pg/rt_pg.c

    r5554 r5558  
    457457    rt_pgraster *pgraster; 
    458458    rt_raster raster; 
    459     rt_context ctx = get_rt_context(fcinfo); 
     459    rt_context ctx; 
    460460    FuncCallContext *funcctx; 
    461461    int call_cntr; 
     
    471471     * Check input parameters 
    472472     */ 
     473    /* 
    473474    if ( PG_NARGS() < 1 || PG_NARGS() > 2 ) 
    474475    { 
    475         ereport(errcode(ERRCODE_TOO_MANY_ARGUMENTS),  
    476                 (errmsg("RASTER_dumpAsWKTPolygons requires 1 or 2 args"))); 
    477         PG_RETURN_NULL(); 
    478     } 
    479  
     476        elog(ERROR, "RASTER_dumpAsWKTPolygons requires 1 or 2 args"); 
     477        PG_RETURN_NULL(); 
     478    } 
     479    */ 
     480     
    480481    /** 
    481482     * Stuff donde only in the first call of the function 
    482483     */ 
     484 
     485    elog(NOTICE, "LAST MESSAGE BEFORE CRASH"); 
    483486    if (SRF_IS_FIRSTCALL()) 
    484487    { 
    485488        MemoryContext oldcontext; 
     489 
     490                       
     491#ifdef POSTGIS_RASTER_PG_DEBUG 
     492        elog(NOTICE, "*********** RASTER_dumpAsWKTPolygons FIRST CALL **************"); 
     493#endif 
    486494 
    487495        /* Create a function context for cross-call persistence */ 
     
    506514        if ( ! raster )  
    507515        { 
    508             ereport(errcode(ERRCODE_OUT_OF_MEMORY),  
    509                     (errmsg("Could not deserialize raster"))); 
     516            ereport(ERROR, 
     517                    (errcode(ERRCODE_OUT_OF_MEMORY),  
     518                    errmsg("Could not deserialize raster"))); 
    510519            PG_RETURN_NULL(); 
    511520        } 
     
    517526 
    518527        /* Polygonize raster */ 
     528#ifdef POSTGIS_RASTER_PG_DEBUG 
     529        elog(NOTICE, "*********** POLYGONIZE BAND %d **************", nband);  
     530#endif         
     531 
    519532        geomval = rt_raster_dump_as_wktpolygons(ctx, raster, nband); 
    520533        /** 
     
    529542        funcctx->max_calls =  
    530543            sizeof(geomval) / sizeof(rt_wktgeomval); 
     544         
     545#ifdef POSTGIS_RASTER_PG_DEBUG 
     546        elog(NOTICE, "*********** MAX CALLS: %d **************", 
     547                        funcctx->max_calls); 
     548#endif 
    531549 
    532550        /**  
     
    536554        if ( ! geomval_ind) 
    537555        { 
    538             ereport(errcode(ERRCODE_OUT_OF_MEMORY),  
    539                     (errmsg("Out of memory"))); 
     556            ereport(ERROR, 
     557                    (errcode(ERRCODE_OUT_OF_MEMORY),  
     558                    errmsg("Out of memory"))); 
    540559            PG_RETURN_NULL(); 
    541560        } 
     
    563582    } 
    564583 
     584 
    565585    /* Stuff done on every call of the function */ 
    566586    funcctx = SRF_PERCALL_SETUP(); 
     
    568588    max_calls = funcctx->max_calls; 
    569589    attinmeta = funcctx->attinmeta; 
    570     geomval_ind = funcctx->user_fctx; 
     590    geomval_ind = funcctx->user_fctx;         
     591     
     592     
     593#ifdef POSTGIS_RASTER_PG_DEBUG 
     594    elog(NOTICE, "*********** PASS NUMBER %d **************", call_cntr); 
     595#endif 
     596  
    571597 
    572598    /* If there is more left to send... */ 
  • spike/wktraster/rt_pg/rtpostgis.sql.in.c

    r5554 r5558  
    9090    LANGUAGE 'C' IMMUTABLE; 
    9191 
    92 CREATEFUNCTION DumpAsWKTPolygons(raster, int DEFAULT 1) 
     92CREATEFUNCTION DumpAsWKTPolygons(raster, integer) 
    9393    RETURNS SETOF wktgeomval 
    9494    AS 'MODULE_PATHNAME','RASTER_dumpAsWKTPolygons' 
     
    346346 
    347347     
    348 CREATEFUNCTION st_dumpaspolygons(raster)  
    349     RETURNS SETOF geomval 
    350     AS 'select st_geomfromtext(wktgeomval.wktgeom, wktgeomval.srid), wktgeomval.val 
    351         from dumpaswktpolygons($1, 1) as wktgeomval' 
    352     LANGUAGE 'SQL' _IMMUTABLE_STRICT; 
    353  
    354 CREATEFUNCTION st_dumpaspolygons(raster, int)  
    355     RETURNS SETOF geomval 
    356     AS 'select st_geomfromtext(wktgeomval.wktgeom, wktgeomval.srid), wktgeomval.val 
    357         from dumpaswktpolygons($1, $2) as wktgeomval' 
    358     LANGUAGE 'SQL' _IMMUTABLE_STRICT; 
    359  
     348CREATEFUNCTION st_DumpAsPolygons(raster) RETURNS SETOF geomval AS $$ 
     349        SELECT ST_GeomFromText(wktgeomval.wktGeom), wktgeomval.val, 
     350        wktgeomval.srid FROM DumpAsWKTPolygons($1, 1) AS wktgeomval; 
     351    $$ LANGUAGE 'SQL' _IMMUTABLE_STRICT; 
     352 
     353CREATEFUNCTION st_DumpAsPolygons(raster, integer) RETURNS SETOF geomval AS $$ 
     354        SELECT ST_GeomFromText(wktgeomval.wktGeom), wktgeomval.val, 
     355        wktgeomval.srid FROM DumpAsWKTPolygons($1, $2) AS wktgeomval; 
     356    $$ LANGUAGE 'SQL' _IMMUTABLE_STRICT; 
     357 
     358CREATEFUNCTION ST_Dummy() RETURNS integer AS $$ 
     359    BEGIN 
     360        RAISE NOTICE 'This is a dummy function that does nothing'; 
     361        RETURN 0; 
     362    END 
     363$$ LANGUAGE 'plpgsql'; 
    360364 
    361365------------------------------------------------------------------------------ 
  • spike/wktraster/scripts/rtreader.py

    r4144 r5558  
    104104            if self._conn is None: 
    105105                self._conn = psycopg2.connect(self._connstr) 
    106         except: 
    107             raise RasterError("Falied to connect to %s" % self._connstr) 
     106        except Exception, e: 
     107            raise RasterError("Falied to connect to %s: %s" % (self._connstr, e)) 
    108108 
    109109    def _query_single_row(self, sql): 
     
    114114            cur = self._conn.cursor() 
    115115            cur.execute(sql) 
    116         except: 
    117             raise RasterError("Falied to execute query: %s" % sql) 
     116        except Exception, e: 
     117            raise RasterError("Failed to execute query %s: %s" % (sql, 
     118                        e)) 
    118119 
    119120        row = cur.fetchone() 
  • spike/wktraster/test/core/testapi.c

    r5555 r5558  
    5555{ 
    5656    /* Create raster */ 
     57 
     58    /* First test raster */ 
     59    /* 
     60    uint16_t width = 2; 
     61    uint16_t height = 2; 
     62    */ 
     63     
     64    /* Second test raster */ 
    5765    uint16_t width = 9; 
    5866    uint16_t height = 9; 
    5967     
    60     //uint16_t width = 2; 
    61     //uint16_t height = 2; 
     68    /* Third test raster */ 
     69    /* 
     70    uint16_t width = 5; 
     71    uint16_t height = 5; 
     72    */ 
     73 
    6274    rt_raster raster = rt_raster_new(ctx, width, height); 
     75     
    6376    rt_band band = addBand(ctx, raster, PT_32BSI); 
    6477 
    65     /* Fill raster */ 
     78    /* Fill raster. Option 1: simple raster */ 
    6679    /* 
    6780    rt_band_set_pixel(ctx, band, 0, 0, 1); 
     
    7285     
    7386 
    74      
     87    /* Fill raster. Option 2: 9x9, 1 band */     
    7588    rt_band_set_pixel(ctx, band, 3, 1, 1.0); 
    7689    rt_band_set_pixel(ctx, band, 4, 1, 1.0); 
     
    101114    rt_band_set_pixel(ctx, band, 4, 7, 1.0); 
    102115    rt_band_set_pixel(ctx, band, 5, 7, 2.0); 
    103      
    104      
     116 
     117 
     118    /* Fill raster. Option 3: 5x5, 1 band */ 
     119    /* 
     120    rt_band_set_pixel(ctx, band, 0, 0, 253); 
     121    rt_band_set_pixel(ctx, band, 1, 0, 254); 
     122    rt_band_set_pixel(ctx, band, 2, 0, 253); 
     123    rt_band_set_pixel(ctx, band, 3, 0, 254); 
     124    rt_band_set_pixel(ctx, band, 4, 0, 254); 
     125    rt_band_set_pixel(ctx, band, 0, 1, 253); 
     126    rt_band_set_pixel(ctx, band, 1, 1, 254); 
     127    rt_band_set_pixel(ctx, band, 2, 1, 254); 
     128    rt_band_set_pixel(ctx, band, 3, 1, 253); 
     129    rt_band_set_pixel(ctx, band, 4, 1, 249); 
     130    rt_band_set_pixel(ctx, band, 0, 2, 250); 
     131    rt_band_set_pixel(ctx, band, 1, 2, 254); 
     132    rt_band_set_pixel(ctx, band, 2, 2, 254); 
     133    rt_band_set_pixel(ctx, band, 3, 2, 252); 
     134    rt_band_set_pixel(ctx, band, 4, 2, 249); 
     135    rt_band_set_pixel(ctx, band, 0, 3, 251); 
     136    rt_band_set_pixel(ctx, band, 1, 3, 253); 
     137    rt_band_set_pixel(ctx, band, 2, 3, 254); 
     138    rt_band_set_pixel(ctx, band, 3, 3, 254); 
     139    rt_band_set_pixel(ctx, band, 4, 3, 253); 
     140    rt_band_set_pixel(ctx, band, 0, 4, 252); 
     141    rt_band_set_pixel(ctx, band, 1, 4, 250); 
     142    rt_band_set_pixel(ctx, band, 2, 4, 254); 
     143    rt_band_set_pixel(ctx, band, 3, 4, 254); 
     144    rt_band_set_pixel(ctx, band, 4, 4, 254); 
     145    */ 
     146      
    105147    rt_raster_add_band(ctx, raster, band);  
    106148     
     
    10281070        rt_wktgeomval gv = rt_raster_dump_as_wktpolygons(ctx, rt, 1); 
    10291071 
    1030         CHECK_EQUALS(gv[0].val, 1); 
     1072 
     1073        CHECK_EQUALS_DOUBLE(gv[0].val, 1.0); 
    10311074        CHECK(!strcmp(gv[0].wktGeom,"POLYGON ((3 1,3 2,2 2,2 3,1 3,1 6,2 6,2 7,3 7,3 8,5 8,5 6,3 6,3 3,4 3,5 3,5 1,3 1))")); 
    10321075 
    1033         CHECK_EQUALS(gv[1].val, 2); 
     1076        CHECK_EQUALS_DOUBLE(gv[1].val, 2.0); 
    10341077        CHECK(!strcmp(gv[1].wktGeom,"POLYGON ((5 1,5 3,6 3,6 6,5 6,5 8,6 8,6 7,7 7,7 6,8 6,8 3,7 3,7 2,6 2,6 1,5 1))"));       
    10351078