Merge branch 'fix-hardcoded-getcategory-geom' into release-v-1.0.2-preview

This commit is contained in:
John Krauss 2016-07-12 16:08:05 -04:00
commit 6ce0e5a8d9

View File

@ -470,11 +470,11 @@ BEGIN
ELSE
-- favor the category with the most area
EXECUTE format(
'SELECT %I category, SUM(overlap_fraction) category_share
'SELECT data.%I category, SUM(overlap_fraction) category_share
FROM observatory.%I data, (
SELECT ST_Area(
ST_Intersection(%L, a.%I)
) / ST_Area(%L) AS overlap_fraction, %I geomref
) / ST_Area(%L) AS overlap_fraction, a.%I geomref
FROM observatory.%I as a
WHERE %L && a.%I) _overlaps
WHERE data.%I = _overlaps.geomref