From 26e1a2f4616066f0579790e457858c1f4e107da9 Mon Sep 17 00:00:00 2001 From: John Krauss Date: Mon, 3 Apr 2017 21:51:32 +0000 Subject: [PATCH] Add tags to obs_getavailablegeometries Fixes #260 * Adds `geom_type`, `geom_extra`, and `geom_tags` to `OBS_GetAvailableGeometries`. This brings it up to spec with existing docs. * Adds `timespan_type`, `timespan_extra`, and `timespan_tags` to `OBS_GetAvailableTimespans` for consistency. --- doc/discovery_functions.md | 5 ++++- src/pg/sql/42_observatory_exploration.sql | 16 ++++++++++++++-- .../expected/42_observatory_exploration_test.out | 3 +++ .../test/sql/42_observatory_exploration_test.sql | 5 +++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/doc/discovery_functions.md b/doc/discovery_functions.md index dab630b..356ddd3 100644 --- a/doc/discovery_functions.md +++ b/doc/discovery_functions.md @@ -327,9 +327,12 @@ timespan_id | Text | The ID of the timespan timespan_name | Text | A human readable name for the timespan timespan_description | Text | Ignored timespan_weight | Numeric | Ignored +timespan_aggregate | Text | Ignored timespan_license | Text | Ignored timespan_source | Text | Ignored -timespan_aggregate | Text | Ignored +timespan_type | Text | Ignored +timespan_extra | JSONB | Ignored +timespan_tags | JSONB | Ignored valid_numer | Boolean | True if the `numer_id` argument is a valid numerator for this timespan, False otherwise valid_denom | Boolean | True if the `timespan` argument is a valid timespan for this timespan, False otherwise valid_geom | Boolean | True if the `geom_id` argument is a valid geometry for this timespan, False otherwise diff --git a/src/pg/sql/42_observatory_exploration.sql b/src/pg/sql/42_observatory_exploration.sql index 3120c6a..4920167 100644 --- a/src/pg/sql/42_observatory_exploration.sql +++ b/src/pg/sql/42_observatory_exploration.sql @@ -252,6 +252,9 @@ CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableGeometries( geom_aggregate TEXT, geom_license TEXT, geom_source TEXT, + geom_type TEXT, + geom_extra JSONB, + geom_tags JSONB, valid_numer BOOLEAN, valid_denom BOOLEAN, valid_timespan BOOLEAN, @@ -286,6 +289,9 @@ BEGIN NULL::TEXT geom_aggregate, NULL::TEXT license, NULL::TEXT source, + geom_type::TEXT, + geom_extra::JSONB, + geom_tags::JSONB, $1 = ANY(numers) valid_numer, $2 = ANY(denoms) valid_denom, $3 = ANY(timespans) valid_timespan @@ -319,6 +325,9 @@ CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetAvailableTimespans( timespan_aggregate TEXT, timespan_license TEXT, timespan_source TEXT, + timespan_type TEXT, + timespan_extra JSONB, + timespan_tags JSONB, valid_numer BOOLEAN, valid_denom BOOLEAN, valid_geom BOOLEAN @@ -343,8 +352,11 @@ BEGIN timespan_description::TEXT, timespan_weight::NUMERIC, NULL::TEXT timespan_aggregate, - NULL::TEXT license, - NULL::TEXT source, + NULL::TEXT timespan_license, + NULL::TEXT timespan_source, + NULL::TEXT timespan_type, + NULL::JSONB timespan_extra, + NULL::JSONB timespan_tags, $1 = ANY(numers) valid_numer, $2 = ANY(denoms) valid_denom, $3 = ANY(geoms) valid_geom_id diff --git a/src/pg/test/expected/42_observatory_exploration_test.out b/src/pg/test/expected/42_observatory_exploration_test.out index 7b18c5a..31bdf95 100644 --- a/src/pg/test/expected/42_observatory_exploration_test.out +++ b/src/pg/test/expected/42_observatory_exploration_test.out @@ -120,6 +120,9 @@ t _obs_getavailablegeometries_bg_not_1996 t (1 row) +_obs_getavailablegeometries_has_boundary_tag +t +(1 row) _obs_getavailabletimespans_2010_2014_in_all t (1 row) diff --git a/src/pg/test/sql/42_observatory_exploration_test.sql b/src/pg/test/sql/42_observatory_exploration_test.sql index f3ca14b..1f08e00 100644 --- a/src/pg/test/sql/42_observatory_exploration_test.sql +++ b/src/pg/test/sql/42_observatory_exploration_test.sql @@ -289,6 +289,11 @@ FROM cdb_observatory.OBS_GetAvailableGeometries( ) WHERE valid_timespan = True) AS _obs_getavailablegeometries_bg_not_1996; +SELECT 'subsection/tags.boundary' IN (SELECT (Jsonb_Each(geom_tags)).key +FROM cdb_observatory.OBS_GetAvailableGeometries( + ST_SetSRID(ST_MakePoint(-73.9, 40.7), 4326) +)) AS _obs_getavailablegeometries_has_boundary_tag; + -- -- OBS_GetAvailableTimespans tests --