void object::test<1> () { numcalls = 0; initGEOS(notice, notice); GEOS_interruptRegisterCallback(countCalls); ensure_equals(numcalls, 0); GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)"); ensure("GEOSGeomFromWKT failed", nullptr != geom1); GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8); ensure("GEOSBufferWithStyle failed", nullptr != geom2); ensure("interrupt callback never called", numcalls > 0); GEOSGeom_destroy(geom1); GEOSGeom_destroy(geom2); GEOS_interruptRegisterCallback(nullptr); /* unregister */ finishGEOS(); }
void object::test<2> () { numcalls = 0; initGEOS(notice, notice); GEOS_interruptRegisterCallback(countCalls); ensure_equals(numcalls, 0); GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1, 2 2, 4 4)"); GEOSGeometry* geom2 = GEOSGeomFromWKT("LINESTRING(0 0, 1 1.01, 4 4.001)"); ensure("GEOSGeomFromWKT failed", nullptr != geom1); GEOSGeometry* geom3 = GEOSSnap(geom1, geom2, 0.1); ensure("GEOSSnap failed", nullptr != geom3); ensure("interrupt callback never called", numcalls > 0); GEOSGeom_destroy(geom1); GEOSGeom_destroy(geom2); GEOSGeom_destroy(geom3); GEOS_interruptRegisterCallback(nullptr); /* unregister */ finishGEOS(); }
void _PG_init(void) { coreIntHandler = pqsignal(SIGINT, handleInterrupt); #ifdef WIN32 #if POSTGIS_GEOS_VERSION >= 34 GEOS_interruptRegisterCallback(interruptCallback); #endif lwgeom_register_interrupt_callback(interruptCallback); #endif #if 0 /* Define custom GUC variables. */ DefineCustomIntVariable( "postgis.debug.level", /* name */ "Sets the debugging level of PostGIS.", /* short_desc */ "This is an experimental configuration.", /* long_desc */ &postgis_debug_level, /* valueAddr */ 0, 8, /* min-max */ 0, /* bootValue */ PGC_SUSET, /* GucContext context */ GUC_UNIT_MS, /* int flags */ #if POSTGIS_PGSQL_VERSION >= 91 NULL, /* GucStringCheckHook check_hook */ #endif NULL, /* GucStringAssignHook assign_hook */ NULL /* GucShowHook show_hook */ ); #endif #if 0 /* Define custom GUC variables. */ DefineCustomStringVariable( "postgis.greeting.string", /* name */ "Sets the greeting string used on postgis module load.", /* short_desc */ "This is an experimental configuration.", /* long_desc */ &greeting, /* valueAddr */ "Welcome to PostGIS " POSTGIS_VERSION, /* bootValue */ PGC_SUSET, /* GucContext context */ GUC_UNIT_MS, /* int flags */ #if POSTGIS_PGSQL_VERSION >= 91 NULL, /* GucStringCheckHook check_hook */ #endif NULL, /* GucStringAssignHook assign_hook */ NULL /* GucShowHook show_hook */ ); #endif /* install PostgreSQL handlers */ pg_install_lwgeom_handlers(); /* initialize geometry backend */ lwgeom_init_backend(); }
void object::test<4> () { initGEOS(notice, notice); GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)"); ensure("GEOSGeomFromWKT failed", nullptr != geom1); GEOS_interruptRegisterCallback(interruptNow); GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8); ensure("GEOSBuffer wasn't interrupted", nullptr == geom2); GEOS_interruptRegisterCallback(nullptr); /* unregister */ // TODO: check the actual exception ? (sent to notice() callback) GEOSGeom_destroy(geom1); finishGEOS(); }
void object::test<5> () { numcalls = 0; initGEOS(notice, notice); GEOSGeometry* geom1 = GEOSGeomFromWKT("LINESTRING(0 0, 1 0)"); ensure("GEOSGeomFromWKT failed", nullptr != geom1); GEOS_interruptRegisterCallback(interruptNow); nextcb = GEOS_interruptRegisterCallback(countCalls); GEOSGeometry* geom2 = GEOSBuffer(geom1, 1, 8); ensure("GEOSBuffer wasn't interrupted", nullptr == geom2); ensure_equals(numcalls, 1); GEOS_interruptRegisterCallback(nullptr); /* unregister */ nextcb = nullptr; GEOSGeom_destroy(geom1); finishGEOS(); }