Merge branch 'develop' into docs-768-obs-docs-structure

This commit is contained in:
Andy Eschbacher
2016-05-13 09:36:46 -04:00
10 changed files with 13775 additions and 10708 deletions

View File

@@ -72,9 +72,9 @@ BEGIN
-- return the first boundary in intersections
EXECUTE format(
'SELECT t.the_geom
FROM observatory.%s As t
WHERE ST_Intersects($1, t.the_geom)
'SELECT the_geom
FROM observatory.%I
WHERE ST_Intersects($1, the_geom)
LIMIT 1', target_table)
INTO boundary
USING geom;
@@ -113,6 +113,7 @@ AS $$
DECLARE
output_id text;
target_table text;
geoid_colname text;
BEGIN
-- If not point, raise error
@@ -139,21 +140,33 @@ BEGIN
LIMIT 1;
END IF;
-- if no tables are found, raise error
-- if no tables are found, raise notice and return null
IF target_table IS NULL
THEN
RAISE NOTICE 'Warning: No boundaries found for ''%''', boundary_id;
RETURN NULL::text;
END IF;
RAISE NOTICE 'target_table: %', target_table;
EXECUTE
format('SELECT ct.colname
FROM observatory.obs_column_to_column c2c,
observatory.obs_column_table ct,
observatory.obs_table t
WHERE c2c.reltype = ''geom_ref''
AND ct.column_id = c2c.source_id
AND ct.table_id = t.id
AND t.tablename = %L'
, target_table)
INTO geoid_colname;
RAISE NOTICE 'target_table: %, geoid_colname: %', target_table, geoid_colname;
-- return name of geometry id column
EXECUTE format(
'SELECT t.geoid
FROM observatory.%s As t
WHERE ST_Intersects($1, t.the_geom)
LIMIT 1', target_table)
'SELECT %I
FROM observatory.%I
WHERE ST_Intersects($1, the_geom)
LIMIT 1', geoid_colname, target_table)
INTO output_id
USING geom;
@@ -210,9 +223,9 @@ BEGIN
-- retrieve boundary
EXECUTE
format(
'SELECT t.%s
FROM observatory.%I As t
WHERE t.%s = $1
'SELECT %I
FROM observatory.%I
WHERE %I = $1
LIMIT 1', geom_colname, target_table, geoid_colname)
INTO boundary
USING geometry_id;
@@ -268,9 +281,9 @@ BEGIN
-- return first boundary in intersections
RETURN QUERY
EXECUTE format(
'SELECT t.%s, t.%s
FROM observatory.%s As t
WHERE ST_%s($1, t.the_geom)
'SELECT %I, %I
FROM observatory.%I
WHERE ST_%s($1, the_geom)
', geom_colname, geoid_colname, target_table, overlap_type)
USING geom;
@@ -410,9 +423,9 @@ BEGIN
-- return first boundary in intersections
RETURN QUERY
EXECUTE format(
'SELECT ST_PointOnSurface(t.%s) As %s, t.%s
FROM observatory.%s As t
WHERE ST_%s($1, t.the_geom)
'SELECT ST_PointOnSurface(%I) As %s, %I
FROM observatory.%I
WHERE ST_%s($1, the_geom)
', geom_colname, geom_colname, geoid_colname, target_table, overlap_type)
USING geom;