diff --git a/packages/geo/VrtRaster.cpp b/packages/geo/VrtRaster.cpp index 8ee52a37a..0280fe409 100644 --- a/packages/geo/VrtRaster.cpp +++ b/packages/geo/VrtRaster.cpp @@ -105,8 +105,8 @@ int VrtRaster::luaCreate( lua_State* L ) /* Get Parameters */ const char* raster_name = getLuaString(L, 1); const char* dem_sampling = getLuaString(L, 2, true, NEARESTNEIGHBOUR_ALGO); - const int sampling_radius = getLuaInteger(L, 3, true, 1); - const int zonal_stats = getLuaBoolean(L, 4, true, 1); + const int sampling_radius = getLuaInteger(L, 3, true, 0); + const int zonal_stats = getLuaBoolean(L, 4, true, false); /* Get Factory */ factory_t _create = NULL; diff --git a/plugins/icesat2/endpoints/atl06.lua b/plugins/icesat2/endpoints/atl06.lua index c0acf5c90..d6d645f4d 100644 --- a/plugins/icesat2/endpoints/atl06.lua +++ b/plugins/icesat2/endpoints/atl06.lua @@ -68,9 +68,17 @@ if samples then local elevation_rec_type = parms["compact"] and "atl06rec-compact.elevation" or "atl06rec.elevation" sampler_disp = core.dispatcher(rspq, 1) -- 1 thread required until VrtRaster is thread safe for key,raster in pairs(samples) do - local vrt = geo.vrt(raster["source"], raster["radius"], raster["algorithm"]) - local sampler = icesat2.sampler(vrt, key, rspq, elevation_rec_type, "extent_id", "lon", "lat") - sampler_disp:attach(sampler, atl06_rec_type) + local vrt = geo.vrt(raster["asset"], raster["algorithm"], raster["radius"], raster["zonal_stats"]) + if vrt then + local sampler = icesat2.sampler(vrt, key, rspq, elevation_rec_type, "extent_id", "lon", "lat") + if sampler then + sampler_disp:attach(sampler, atl06_rec_type) + else + userlog:sendlog(core.CRITICAL, string.format("request <%s> failed to create sampler %s for %s", rspq, key, resource)) + end + else + userlog:sendlog(core.CRITICAL, string.format("request <%s> failed to create raster %s for %s", rspq, key, resource)) + end end sampler_disp:run() end diff --git a/plugins/icesat2/plugin/RasterSampler.cpp b/plugins/icesat2/plugin/RasterSampler.cpp index f4d68ab53..0a6463692 100644 --- a/plugins/icesat2/plugin/RasterSampler.cpp +++ b/plugins/icesat2/plugin/RasterSampler.cpp @@ -72,7 +72,7 @@ const RecordObject::fieldDef_t RasterSampler::zsSampleRecDef[] = { {"mad", RecordObject::DOUBLE, offsetof(VrtRaster::sample_t, stats.mad), 1, NULL, NATIVE_FLAGS} }; -const char* RasterSampler::zsExtentRecType = "zssrec"; +const char* RasterSampler::zsExtentRecType = "zsrec"; const RecordObject::fieldDef_t RasterSampler::zsExtentRecDef[] = { {"extent_id", RecordObject::UINT64, offsetof(zs_extent_t, extent_id), 1, NULL, NATIVE_FLAGS}, {"key", RecordObject::STRING, offsetof(zs_extent_t, raster_key), RASTER_KEY_MAX_LEN, NULL, NATIVE_FLAGS}, diff --git a/plugins/icesat2/plugin/RqstParms.cpp b/plugins/icesat2/plugin/RqstParms.cpp index 7782cdc89..fec4ec4f0 100644 --- a/plugins/icesat2/plugin/RqstParms.cpp +++ b/plugins/icesat2/plugin/RqstParms.cpp @@ -72,9 +72,10 @@ const char* RqstParms::DISTANCE_IN_SEGMENTS = "dist_in_seg"; const char* RqstParms::ATL03_GEO_FIELDS = "atl03_geo_fields"; const char* RqstParms::ATL03_PH_FIELDS = "atl03_ph_fields"; const char* RqstParms::RASTERS_TO_SAMPLE = "samples"; -const char* RqstParms::RASTERS_SOURCE = "source"; +const char* RqstParms::RASTERS_ASSET = "asset"; const char* RqstParms::RASTERS_RADIUS = "radius"; const char* RqstParms::RASTERS_ALGORITHM = "algorithm"; +const char* RqstParms::RASTERS_ZONAL_STATS = "zonal_stats"; const char* RqstParms::RQST_TIMEOUT = "rqst-timeout"; const char* RqstParms::NODE_TIMEOUT = "node-timeout"; const char* RqstParms::READ_TIMEOUT = "read-timeout"; @@ -965,7 +966,6 @@ void RqstParms::get_lua_rasters (lua_State* L, int index, rasters_t** rasters_li *provided = true; /* Iterate over rasters in list */ - lua_pushvalue(L, index); // -1 => table lua_pushnil(L); // -1 => nil; -2 => table while (lua_next(L, -2)) // -1 => value; -2 => key; -3 => table { @@ -977,21 +977,26 @@ void RqstParms::get_lua_rasters (lua_State* L, int index, rasters_t** rasters_li rss_t rss; bool field_provided; - lua_getfield(L, index, RqstParms::RASTERS_SOURCE); - rss.source = LuaObject::getLuaString(L, -1); - mlog(DEBUG, "Sampling %s for %s", rss.source.getString(), key); + lua_getfield(L, -2, RqstParms::RASTERS_ASSET); + rss.asset = LuaObject::getLuaString(L, -1); + mlog(DEBUG, "Sampling %s for %s", rss.asset.getString(), key); lua_pop(L, 1); - lua_getfield(L, index, RqstParms::RASTERS_RADIUS); + lua_getfield(L, -2, RqstParms::RASTERS_RADIUS); rss.radius = LuaObject::getLuaFloat(L, -1, true, 0.0, &field_provided); if(field_provided) mlog(DEBUG, "Setting %s to %lf for %s", RqstParms::RASTERS_RADIUS, rss.radius, key); lua_pop(L, 1); - lua_getfield(L, index, RqstParms::RASTERS_ALGORITHM); + lua_getfield(L, -2, RqstParms::RASTERS_ALGORITHM); rss.sampling_algorithm = LuaObject::getLuaString(L, -1, true, VrtRaster::NEARESTNEIGHBOUR_ALGO, &field_provided); if(field_provided) mlog(DEBUG, "Setting %s to %s for %s", RqstParms::RASTERS_ALGORITHM, rss.sampling_algorithm.getString(), key); lua_pop(L, 1); + lua_getfield(L, -2, RqstParms::RASTERS_ZONAL_STATS); + rss.zonal_stats = LuaObject::getLuaBoolean(L, -1, true, false, &field_provided); + if(field_provided) mlog(DEBUG, "Setting %s to %s for %s", RqstParms::RASTERS_ZONAL_STATS, rss.zonal_stats ? "true" : "false", key); + lua_pop(L, 1); + /* Add raster entry to list */ (*rasters_list)->add(key, rss); } @@ -1001,7 +1006,6 @@ void RqstParms::get_lua_rasters (lua_State* L, int index, rasters_t** rasters_li } lua_pop(L, 2); // -1 => key; -2 => table } // -1 => table - lua_pop(L, 1); // stack restored to how it was } else if(!lua_isnil(L, index)) { diff --git a/plugins/icesat2/plugin/RqstParms.h b/plugins/icesat2/plugin/RqstParms.h index f8d453fff..af2f80326 100644 --- a/plugins/icesat2/plugin/RqstParms.h +++ b/plugins/icesat2/plugin/RqstParms.h @@ -84,9 +84,10 @@ class RqstParms: public LuaObject static const char* ATL03_GEO_FIELDS; static const char* ATL03_PH_FIELDS; static const char* RASTERS_TO_SAMPLE; - static const char* RASTERS_SOURCE; + static const char* RASTERS_ASSET; static const char* RASTERS_RADIUS; static const char* RASTERS_ALGORITHM; + static const char* RASTERS_ZONAL_STATS; static const char* RQST_TIMEOUT; static const char* NODE_TIMEOUT; static const char* READ_TIMEOUT; @@ -220,9 +221,10 @@ class RqstParms: public LuaObject /* Raster Sampling Settings */ typedef struct { - SafeString source; + SafeString asset; double radius; SafeString sampling_algorithm; + bool zonal_stats; } rss_t; /* Rasters to Sample */ diff --git a/scripts/endpoints/version.lua b/scripts/endpoints/version.lua index 7c923f407..ce410d44c 100644 --- a/scripts/endpoints/version.lua +++ b/scripts/endpoints/version.lua @@ -29,11 +29,6 @@ local json = require("json") local version, commit, environment, launch, duration, packages = sys.version() local rsps = {server={version=version, commit=commit, environment=environment, launch=launch, duration=duration, packages=packages}} -print(version) -print(commit) -print(environment) -print(launch) -print(duration) for _,package in ipairs(packages) do local package_exists = global.check(package)