Changeset 5558
- Timestamp:
- 04/15/10 11:06:29 (2 years ago)
- Location:
- spike/wktraster
- Files:
-
- 5 modified
-
configure.ac (modified) (2 diffs)
-
rt_pg/rt_pg.c (modified) (8 diffs)
-
rt_pg/rtpostgis.sql.in.c (modified) (2 diffs)
-
scripts/rtreader.py (modified) (2 diffs)
-
test/core/testapi.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
spike/wktraster/configure.ac
r5475 r5558 396 396 AC_SUBST([POSTGIS_RASTER_PGSQL_VERSION]) 397 397 398 dnl ======================================================================== =398 dnl ======================================================================== 399 399 dnl DEVELOPMENT OPTION: Determine GDAL Support 400 400 dnl … … 409 409 dnl LIBGDAL_CFLAGS="-I$with_gdal/port -I$with_gdal/ogr -I$with_gdal/alg -I$with_gdal/gcore -I$with_gdal/frmts " 410 410 dnl LIBGDAL_LDFLAGS="-L${with_gdal}/.libs -lgdal -L${with_gdal}/ -lgdal" 411 dnl ======================================================================== =411 dnl ======================================================================== 412 412 ENABLE_DEVELOPMENT_CFLAGS="" 413 413 enable_development_msg="" -
spike/wktraster/rt_pg/rt_pg.c
r5554 r5558 457 457 rt_pgraster *pgraster; 458 458 rt_raster raster; 459 rt_context ctx = get_rt_context(fcinfo);459 rt_context ctx; 460 460 FuncCallContext *funcctx; 461 461 int call_cntr; … … 471 471 * Check input parameters 472 472 */ 473 /* 473 474 if ( PG_NARGS() < 1 || PG_NARGS() > 2 ) 474 475 { 475 e report(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 480 481 /** 481 482 * Stuff donde only in the first call of the function 482 483 */ 484 485 elog(NOTICE, "LAST MESSAGE BEFORE CRASH"); 483 486 if (SRF_IS_FIRSTCALL()) 484 487 { 485 488 MemoryContext oldcontext; 489 490 491 #ifdef POSTGIS_RASTER_PG_DEBUG 492 elog(NOTICE, "*********** RASTER_dumpAsWKTPolygons FIRST CALL **************"); 493 #endif 486 494 487 495 /* Create a function context for cross-call persistence */ … … 506 514 if ( ! raster ) 507 515 { 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"))); 510 519 PG_RETURN_NULL(); 511 520 } … … 517 526 518 527 /* Polygonize raster */ 528 #ifdef POSTGIS_RASTER_PG_DEBUG 529 elog(NOTICE, "*********** POLYGONIZE BAND %d **************", nband); 530 #endif 531 519 532 geomval = rt_raster_dump_as_wktpolygons(ctx, raster, nband); 520 533 /** … … 529 542 funcctx->max_calls = 530 543 sizeof(geomval) / sizeof(rt_wktgeomval); 544 545 #ifdef POSTGIS_RASTER_PG_DEBUG 546 elog(NOTICE, "*********** MAX CALLS: %d **************", 547 funcctx->max_calls); 548 #endif 531 549 532 550 /** … … 536 554 if ( ! geomval_ind) 537 555 { 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"))); 540 559 PG_RETURN_NULL(); 541 560 } … … 563 582 } 564 583 584 565 585 /* Stuff done on every call of the function */ 566 586 funcctx = SRF_PERCALL_SETUP(); … … 568 588 max_calls = funcctx->max_calls; 569 589 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 571 597 572 598 /* If there is more left to send... */ -
spike/wktraster/rt_pg/rtpostgis.sql.in.c
r5554 r5558 90 90 LANGUAGE 'C' IMMUTABLE; 91 91 92 CREATEFUNCTION DumpAsWKTPolygons(raster, int DEFAULT 1)92 CREATEFUNCTION DumpAsWKTPolygons(raster, integer) 93 93 RETURNS SETOF wktgeomval 94 94 AS 'MODULE_PATHNAME','RASTER_dumpAsWKTPolygons' … … 346 346 347 347 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 348 CREATEFUNCTION 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 353 CREATEFUNCTION 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 358 CREATEFUNCTION 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'; 360 364 361 365 ------------------------------------------------------------------------------ -
spike/wktraster/scripts/rtreader.py
r4144 r5558 104 104 if self._conn is None: 105 105 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)) 108 108 109 109 def _query_single_row(self, sql): … … 114 114 cur = self._conn.cursor() 115 115 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)) 118 119 119 120 row = cur.fetchone() -
spike/wktraster/test/core/testapi.c
r5555 r5558 55 55 { 56 56 /* Create raster */ 57 58 /* First test raster */ 59 /* 60 uint16_t width = 2; 61 uint16_t height = 2; 62 */ 63 64 /* Second test raster */ 57 65 uint16_t width = 9; 58 66 uint16_t height = 9; 59 67 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 62 74 rt_raster raster = rt_raster_new(ctx, width, height); 75 63 76 rt_band band = addBand(ctx, raster, PT_32BSI); 64 77 65 /* Fill raster */78 /* Fill raster. Option 1: simple raster */ 66 79 /* 67 80 rt_band_set_pixel(ctx, band, 0, 0, 1); … … 72 85 73 86 74 87 /* Fill raster. Option 2: 9x9, 1 band */ 75 88 rt_band_set_pixel(ctx, band, 3, 1, 1.0); 76 89 rt_band_set_pixel(ctx, band, 4, 1, 1.0); … … 101 114 rt_band_set_pixel(ctx, band, 4, 7, 1.0); 102 115 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 105 147 rt_raster_add_band(ctx, raster, band); 106 148 … … 1028 1070 rt_wktgeomval gv = rt_raster_dump_as_wktpolygons(ctx, rt, 1); 1029 1071 1030 CHECK_EQUALS(gv[0].val, 1); 1072 1073 CHECK_EQUALS_DOUBLE(gv[0].val, 1.0); 1031 1074 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))")); 1032 1075 1033 CHECK_EQUALS (gv[1].val, 2);1076 CHECK_EQUALS_DOUBLE(gv[1].val, 2.0); 1034 1077 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))")); 1035 1078
