updating geometry types to (geometry/point, 4326) where appropriate
This commit is contained in:
parent
36698cce22
commit
397d8f28ec
@ -4,7 +4,7 @@
|
|||||||
-- table where there is multiple sources for a column from multiple
|
-- table where there is multiple sources for a column from multiple
|
||||||
-- geometries.
|
-- geometries.
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GeomTable(
|
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GeomTable(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
geometry_id text,
|
geometry_id text,
|
||||||
time_span text DEFAULT NULL
|
time_span text DEFAULT NULL
|
||||||
)
|
)
|
||||||
@ -84,7 +84,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
--Test point cause Stuart always seems to make random points in the water
|
--Test point cause Stuart always seems to make random points in the water
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory._TestPoint()
|
CREATE OR REPLACE FUNCTION cdb_observatory._TestPoint()
|
||||||
RETURNS geometry
|
RETURNS geometry(Point, 4326)
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
-- new york city
|
-- new york city
|
||||||
@ -95,7 +95,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
--Test polygon cause Stuart always seems to make random points in the water
|
--Test polygon cause Stuart always seems to make random points in the water
|
||||||
-- TODO: remove as it's not used anywhere?
|
-- TODO: remove as it's not used anywhere?
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory._TestArea()
|
CREATE OR REPLACE FUNCTION cdb_observatory._TestArea()
|
||||||
RETURNS geometry
|
RETURNS geometry(Geometry, 4326)
|
||||||
AS $$
|
AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
-- Buffer NYC point by 500 meters
|
-- Buffer NYC point by 500 meters
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
-- Creates a table of demographic snapshot
|
-- Creates a table of demographic snapshot
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetDemographicSnapshot(geom geometry,
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetDemographicSnapshot(geom geometry(Geometry, 4326),
|
||||||
time_span text DEFAULT NULL,
|
time_span text DEFAULT NULL,
|
||||||
boundary_id text DEFAULT NULL)
|
boundary_id text DEFAULT NULL)
|
||||||
RETURNS SETOF JSON
|
RETURNS SETOF JSON
|
||||||
@ -140,7 +140,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
-- Base augmentation fucntion.
|
-- Base augmentation fucntion.
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_Get(
|
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_Get(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
column_ids text[],
|
column_ids text[],
|
||||||
time_span text,
|
time_span text,
|
||||||
geometry_level text
|
geometry_level text
|
||||||
@ -163,26 +163,24 @@ BEGIN
|
|||||||
RETURN QUERY SELECT '{}'::text[], '{}'::NUMERIC[];
|
RETURN QUERY SELECT '{}'::text[], '{}'::NUMERIC[];
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
execute'
|
EXECUTE
|
||||||
select array_agg( _obs_getcolumndata) from cdb_observatory._OBS_GetColumnData($1,
|
'SELECT array_agg(_obs_getcolumndata)
|
||||||
$2,
|
FROM cdb_observatory._OBS_GetColumnData($1, $2, $3);'
|
||||||
$3);'
|
INTO data_table_info
|
||||||
INTO data_table_info
|
USING geometry_level, column_ids, time_span;
|
||||||
using geometry_level, column_ids, time_span;
|
|
||||||
|
|
||||||
IF ST_GeometryType(geom) = 'ST_Point'
|
IF ST_GeometryType(geom) = 'ST_Point'
|
||||||
THEN
|
THEN
|
||||||
RAISE NOTICE 'geom_table_name %, data_table_info %', geom_table_name, data_table_info::json[];
|
RAISE NOTICE 'geom_table_name %, data_table_info %', geom_table_name, data_table_info::json[];
|
||||||
results := cdb_observatory._OBS_GetPoints(geom,
|
results := cdb_observatory._OBS_GetPoints(geom,
|
||||||
geom_table_name,
|
geom_table_name,
|
||||||
data_table_info);
|
data_table_info);
|
||||||
|
|
||||||
ELSIF ST_GeometryType(geom) IN ('ST_Polygon', 'ST_MultiPolygon')
|
ELSIF ST_GeometryType(geom) IN ('ST_Polygon', 'ST_MultiPolygon')
|
||||||
THEN
|
THEN
|
||||||
-- RAISE EXCEPTION 'polygons not supported for now';
|
|
||||||
results := cdb_observatory._OBS_GetPolygons(geom,
|
results := cdb_observatory._OBS_GetPolygons(geom,
|
||||||
geom_table_name,
|
geom_table_name,
|
||||||
data_table_info);
|
data_table_info);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
RETURN QUERY
|
RETURN QUERY
|
||||||
@ -199,7 +197,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
-- If the variable of interest is just a rate return it as such,
|
-- If the variable of interest is just a rate return it as such,
|
||||||
-- otherwise normalize it to the census block area and return that
|
-- otherwise normalize it to the census block area and return that
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetPoints(
|
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetPoints(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
geom_table_name text,
|
geom_table_name text,
|
||||||
data_table_info json[]
|
data_table_info json[]
|
||||||
)
|
)
|
||||||
@ -208,17 +206,17 @@ AS $$
|
|||||||
DECLARE
|
DECLARE
|
||||||
result NUMERIC[];
|
result NUMERIC[];
|
||||||
json_result json[];
|
json_result json[];
|
||||||
query text;
|
query text;
|
||||||
i int;
|
i int;
|
||||||
geoid text;
|
geoid text;
|
||||||
area NUMERIC;
|
area NUMERIC;
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
-- TODO: does 'geoid' need to be generalized to geom_ref??
|
-- TODO: does 'geoid' need to be generalized to geom_ref??
|
||||||
EXECUTE
|
EXECUTE
|
||||||
format('SELECT geoid
|
format('SELECT geoid
|
||||||
FROM observatory.%I
|
FROM observatory.%I
|
||||||
WHERE ST_WITHIN($1, the_geom)',
|
WHERE ST_Within($1, the_geom)',
|
||||||
geom_table_name)
|
geom_table_name)
|
||||||
USING geom
|
USING geom
|
||||||
INTO geoid;
|
INTO geoid;
|
||||||
@ -283,7 +281,7 @@ BEGIN
|
|||||||
meta->>'name' As name,
|
meta->>'name' As name,
|
||||||
meta->>'tablename' As tablename,
|
meta->>'tablename' As tablename,
|
||||||
meta->>'aggregate' As aggregate,
|
meta->>'aggregate' As aggregate,
|
||||||
meta->>'type' As type,
|
meta->>'type' As type,
|
||||||
meta->>'description' As description
|
meta->>'description' As description
|
||||||
FROM (SELECT unnest($1) As values, unnest($2) As meta) b
|
FROM (SELECT unnest($1) As values, unnest($2) As meta) b
|
||||||
) t
|
) t
|
||||||
@ -297,7 +295,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetMeasure(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetMeasure(
|
||||||
geom GEOMETRY,
|
geom geometry(Geometry, 4326),
|
||||||
measure_id TEXT,
|
measure_id TEXT,
|
||||||
normalize TEXT DEFAULT 'area', -- TODO none/null
|
normalize TEXT DEFAULT 'area', -- TODO none/null
|
||||||
boundary_id TEXT DEFAULT NULL,
|
boundary_id TEXT DEFAULT NULL,
|
||||||
@ -352,7 +350,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetCategory(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetCategory(
|
||||||
geom GEOMETRY,
|
geom geometry(Geometry, 4326),
|
||||||
category_id TEXT,
|
category_id TEXT,
|
||||||
boundary_id TEXT DEFAULT NULL,
|
boundary_id TEXT DEFAULT NULL,
|
||||||
time_span TEXT DEFAULT NULL
|
time_span TEXT DEFAULT NULL
|
||||||
@ -386,7 +384,7 @@ END;
|
|||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetUSCensusMeasure(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetUSCensusMeasure(
|
||||||
geom GEOMETRY,
|
geom geometry(Geometry, 4326),
|
||||||
name TEXT,
|
name TEXT,
|
||||||
normalize TEXT DEFAULT 'area',
|
normalize TEXT DEFAULT 'area',
|
||||||
boundary_id TEXT DEFAULT NULL,
|
boundary_id TEXT DEFAULT NULL,
|
||||||
@ -419,7 +417,7 @@ END;
|
|||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetUSCensusCategory(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetUSCensusCategory(
|
||||||
geom GEOMETRY,
|
geom geometry(Geometry, 4326),
|
||||||
name TEXT,
|
name TEXT,
|
||||||
boundary_id TEXT DEFAULT NULL,
|
boundary_id TEXT DEFAULT NULL,
|
||||||
time_span TEXT DEFAULT NULL
|
time_span TEXT DEFAULT NULL
|
||||||
@ -453,7 +451,7 @@ END;
|
|||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetPopulation(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetPopulation(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
normalize TEXT DEFAULT 'area',
|
normalize TEXT DEFAULT 'area',
|
||||||
boundary_id TEXT DEFAULT NULL,
|
boundary_id TEXT DEFAULT NULL,
|
||||||
time_span TEXT DEFAULT NULL
|
time_span TEXT DEFAULT NULL
|
||||||
@ -478,7 +476,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetPolygons(
|
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetPolygons(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
geom_table_name text,
|
geom_table_name text,
|
||||||
data_table_info json[]
|
data_table_info json[]
|
||||||
)
|
)
|
||||||
@ -558,7 +556,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetSegmentSnapshot(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetSegmentSnapshot(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
boundary_id text DEFAULT NULL
|
boundary_id text DEFAULT NULL
|
||||||
)
|
)
|
||||||
RETURNS JSON
|
RETURNS JSON
|
||||||
@ -666,7 +664,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
--Get categorical variables from point
|
--Get categorical variables from point
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetCategories(
|
CREATE OR REPLACE FUNCTION cdb_observatory._OBS_GetCategories(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
dimension_names text[],
|
dimension_names text[],
|
||||||
boundary_id text DEFAULT NULL,
|
boundary_id text DEFAULT NULL,
|
||||||
time_span text DEFAULT NULL
|
time_span text DEFAULT NULL
|
||||||
|
@ -82,7 +82,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
-- TODO add test response
|
-- TODO add test response
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION OBS_GetAvailableBoundaries(
|
CREATE OR REPLACE FUNCTION OBS_GetAvailableBoundaries(
|
||||||
geom geometry,
|
geom geometry(Geometry, 4326),
|
||||||
timespan text DEFAULT null)
|
timespan text DEFAULT null)
|
||||||
RETURNS TABLE(boundary_id text, description text, time_span text, tablename text) as $$
|
RETURNS TABLE(boundary_id text, description text, time_span text, tablename text) as $$
|
||||||
DECLARE
|
DECLARE
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetBoundary(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetBoundary(
|
||||||
geom geometry(Geometry, 4326),
|
geom geometry(Point, 4326),
|
||||||
boundary_id text,
|
boundary_id text,
|
||||||
time_span text DEFAULT NULL)
|
time_span text DEFAULT NULL)
|
||||||
RETURNS geometry(Geometry, 4326)
|
RETURNS geometry(Geometry, 4326)
|
||||||
@ -104,7 +104,7 @@ $$ LANGUAGE plpgsql;
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetBoundaryId(
|
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetBoundaryId(
|
||||||
geom geometry(Geometry, 4326),
|
geom geometry(Point, 4326),
|
||||||
boundary_id text,
|
boundary_id text,
|
||||||
time_span text DEFAULT NULL
|
time_span text DEFAULT NULL
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user