allow _obs_geomtable to take a timespan, and default to most recent

This commit is contained in:
John Krauss
2016-05-05 14:45:56 -04:00
parent 7aabc1be76
commit 73f8ea1b4e
2 changed files with 21 additions and 6 deletions

View File

@@ -5,7 +5,8 @@
-- geometries.
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GeomTable(
geom geometry,
geometry_id text
geometry_id text,
time_span text DEFAULT NULL
)
RETURNS TEXT
AS $$
@@ -22,10 +23,12 @@ BEGIN
WHERE type ILIKE ''geometry''
AND coltable.column_id = col.id
AND coltable.table_id = tab.id
AND col.id = $1
AND col.id = $1,
AND CASE WHEN $2 IS NOT NULL THEN timespan = $2 ELSE TRUE END
ORDER BY timespan DESC LIMIT 1
)
'
USING geometry_id, geom
USING geometry_id, geom, time_span
INTO result;
return result;