use data_geoid_colname for data, geom_geoid_colname for geom

This commit is contained in:
John Krauss 2016-05-11 15:47:29 -04:00
parent 56f4d2f256
commit aab24d00dd

View File

@ -213,7 +213,8 @@ DECLARE
query text; query text;
i int; i int;
geoid text; geoid text;
geoid_colname text; data_geoid_colname text;
geom_geoid_colname text;
area NUMERIC; area NUMERIC;
BEGIN BEGIN
@ -228,16 +229,25 @@ BEGIN
AND ct.column_id = c2c.source_id AND ct.column_id = c2c.source_id
AND ct.table_id = t.id AND ct.table_id = t.id
AND t.tablename = %L' AND t.tablename = %L'
, geom_table_name) , (data_table_info)[1]->>'tablename')
INTO geoid_colname; INTO data_geoid_colname;
RAISE NOTICE 'geom_table_name: %', geom_table_name; EXECUTE
RAISE NOTICE 'colname: %', geoid_colname; 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'
, geom_table_name)
INTO geom_geoid_colname;
EXECUTE EXECUTE
format('SELECT %I format('SELECT %I
FROM observatory.%I FROM observatory.%I
WHERE ST_Within($1, the_geom)', WHERE ST_Within($1, the_geom)',
geoid_colname, geom_geoid_colname,
geom_table_name) geom_table_name)
USING geom USING geom
INTO geoid; INTO geoid;
@ -249,7 +259,7 @@ BEGIN
FROM observatory.%I FROM observatory.%I
WHERE %I = %L', WHERE %I = %L',
geom_table_name, geom_table_name,
geoid_colname, geom_geoid_colname,
geoid) geoid)
INTO area; INTO area;
@ -288,7 +298,7 @@ BEGIN
', ',
((data_table_info)[1])->>'tablename', ((data_table_info)[1])->>'tablename',
((data_table_info)[1])->>'tablename', ((data_table_info)[1])->>'tablename',
geoid_colname, data_geoid_colname,
geoid geoid
); );