query_webservice_cache
tools.query_webservice_cache(ctx, input)Execute SQL queries against the cached FEWS webservice database (DuckDB).
This tool queries the webservice cache containing: - series_headers: Available time series combinations - locations: FEWS location data - parameters: FEWS parameter data
Note: This queries the DuckDB cache, not the SQLite config database.
SPATIAL ANALYSIS - CRITICAL COORDINATE SYSTEM INFORMATION:
WARNING: The geom column is stored in EPSG:4326 (WGS84) coordinates (degrees). For accurate spatial analysis with distance calculations, buffers, and spatial joins, you MUST transform coordinates to EPSG:28992 (Dutch RD system) which uses meters.
CORRECT spatial analysis pattern:
-- Transform to Dutch coordinate system for accurate distance calculations
SELECT
locationId,
shortName,
ST_Distance(
ST_Transform(geom, 'EPSG:4326', 'EPSG:28992'), -- Transform to EPSG:28992 (meters)
ST_Transform(ST_Point(5.6667, 52.0333), 'EPSG:4326', 'EPSG:28992') -- Transform point to EPSG:28992
) as distance_meters
FROM locations
WHERE ST_DWithin(
ST_Transform(geom, 'EPSG:4326', 'EPSG:28992'), -- Transform to EPSG:28992
ST_Transform(ST_Point(5.6667, 52.0333), 'EPSG:4326', 'EPSG:28992'), -- Transform point to EPSG:28992
1000 -- 1000 meters buffer
)INCORRECT (will give results in degrees, not meters):
SELECT ST_Distance(geom, ST_Point(5.6667, 52.0333)) FROM locations -- WRONG!Coordinate Systems: - EPSG:4326 (WGS84): Stored geometry - degrees (lat/lon) - EPSG:28992 (Dutch RD): Use for spatial analysis - meters
Spatial Functions: All ST_* functions work, but use ST_Transform(geom, ‘EPSG:4326’, ‘EPSG:28992’) for analysis. To return geometry data: use ST_AsText(geom) for WGS84 or ST_AsText(ST_Transform(geom, ‘EPSG:4326’, ‘EPSG:28992’)) for RD.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ctx | RunContext[Deps] | RunContext with database connection | required |
| input | SQLQueryInput | SQLQueryInput containing the query to execute | required |
Returns
| Name | Type | Description |
|---|---|---|
| SQLQueryOutput | SQLQueryOutput | Results of the query with column names |