remove commented code

This commit is contained in:
John Krauss 2016-12-28 19:34:37 +00:00
parent 6e475cf210
commit 5bdcb59df3

View File

@ -433,151 +433,6 @@ END;
$$ LANGUAGE plpgsql IMMUTABLE; $$ LANGUAGE plpgsql IMMUTABLE;
--CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetMeasureData(
-- geom geometry(Geometry, 4326),
-- geom_type TEXT,
-- normalize TEXT,
-- numer_aggregate TEXT,
-- numer_colname TEXT,
-- numer_geomref_colname TEXT,
-- numer_tablename TEXT,
-- denom_colname TEXT,
-- denom_geomref_colname TEXT,
-- denom_tablename TEXT,
-- geom_colname TEXT,
-- geom_geomref_colname TEXT,
-- geom_tablename TEXT
--)
--RETURNS NUMERIC
--AS $$
--DECLARE
-- sql TEXT;
-- map_type TEXT;
-- result NUMERIC;
--BEGIN
--
-- IF normalize ILIKE 'area' AND numer_aggregate ILIKE 'sum' THEN
-- map_type := 'areaNormalized';
-- ELSIF normalize ILIKE 'denominator' THEN
-- map_type := 'denominated';
-- ELSE
-- -- defaults: area normalization for point if it's possible and none for
-- -- polygon or non-summable point
-- IF geom_type = 'point' AND numer_aggregate ILIKE 'sum' THEN
-- map_type := 'areaNormalized';
-- ELSE
-- map_type := 'predenominated';
-- END IF;
-- END IF;
--
-- IF geom_type = 'point' THEN
-- IF map_type = 'areaNormalized' THEN
-- sql = format('WITH _geom AS (SELECT ST_Area(geom.%I::Geography) / 1000000 area, geom.%I geom_ref
-- FROM observatory.%I geom
-- WHERE ST_Within($1, geom.%I)
-- LIMIT 1)
-- SELECT numer.%I / (SELECT area FROM _geom)
-- FROM observatory.%I numer
-- WHERE numer.%I = (SELECT geom_ref FROM _geom)',
-- geom_colname, geom_geomref_colname, geom_tablename,
-- geom_colname, numer_colname, numer_tablename,
-- numer_geomref_colname);
-- ELSIF map_type = 'denominated' THEN
-- sql = format('SELECT numer.%I / NULLIF((SELECT denom.%I FROM observatory.%I denom WHERE denom.%I = numer.%I LIMIT 1), 0)
-- FROM observatory.%I numer
-- WHERE numer.%I =
-- (SELECT geom.%I
-- FROM observatory.%I geom
-- WHERE ST_Within($1, geom.%I) LIMIT 1)',
-- numer_colname, denom_colname, denom_tablename,
-- denom_geomref_colname, numer_geomref_colname,
-- numer_tablename, numer_geomref_colname,
-- geom_geomref_colname, geom_tablename, geom_colname);
-- ELSIF map_type = 'predenominated' THEN
-- sql = format('SELECT numer.%I
-- FROM observatory.%I numer
-- WHERE numer.%I =
-- (SELECT geom.%I
-- FROM observatory.%I geom
-- WHERE ST_Within($1, geom.%I) LIMIT 1)',
-- numer_colname, numer_tablename, numer_geomref_colname,
-- geom_geomref_colname, geom_tablename, geom_colname);
-- END IF;
-- ELSIF geom_type = 'polygon' THEN
-- IF map_type = 'areaNormalized' THEN
-- sql = format('WITH _subdivided AS (
-- SELECT ST_Subdivide($1) AS geom
-- ), _geom AS (SELECT SUM(ST_Area(ST_Intersection(s.geom, geom.%I)))
-- / ST_Area(cdb_observatory.FIRST(geom.%I)) overlap, geom.%I geom_ref
-- FROM observatory.%I geom, _subdivided s
-- WHERE ST_Intersects(s.geom, geom.%I)
-- GROUP BY geom.%I)
-- SELECT SUM(numer.%I * (SELECT _geom.overlap FROM _geom WHERE _geom.geom_ref = numer.%I)) /
-- (ST_Area($1::Geography) / 1000000)
-- FROM observatory.%I numer
-- WHERE numer.%I = ANY ((SELECT ARRAY_AGG(geom_ref) FROM _geom)::TEXT[])',
-- geom_colname, geom_colname, geom_geomref_colname, geom_tablename,
-- geom_colname, geom_geomref_colname, numer_colname,
-- numer_geomref_colname, numer_tablename, numer_geomref_colname);
-- ELSIF map_type = 'denominated' THEN
-- sql = format('WITH _subdivided AS (
-- SELECT ST_Subdivide($1) AS geom
-- ), _geom AS (SELECT SUM(ST_Area(ST_Intersection(s.geom, geom.%I)))
-- / ST_Area(cdb_observatory.FIRST(geom.%I)) overlap, geom.%I geom_ref
-- FROM observatory.%I geom, _subdivided s
-- WHERE ST_Intersects(s.geom, geom.%I)
-- GROUP BY geom.%I),
-- _denom AS (SELECT denom.%I, denom.%I geom_ref
-- FROM observatory.%I denom
-- WHERE denom.%I = ANY ((SELECT ARRAY_AGG(geom_ref) FROM _geom)::TEXT[]))
-- SELECT SUM(numer.%I * (SELECT _geom.overlap FROM _geom WHERE _geom.geom_ref = numer.%I)) /
-- NullIf(SUM((SELECT _denom.%I * (SELECT _geom.overlap
-- FROM _geom
-- WHERE _geom.geom_ref = _denom.geom_ref)
-- FROM _denom WHERE _denom.geom_ref = numer.%I)), 0)
-- FROM observatory.%I numer
-- WHERE numer.%I = ANY ((SELECT ARRAY_AGG(geom_ref) FROM _geom)::TEXT[])',
-- geom_colname, geom_colname, geom_geomref_colname,
-- geom_tablename, geom_colname, geom_geomref_colname,
-- denom_colname, denom_geomref_colname, denom_tablename,
-- denom_geomref_colname, numer_colname, numer_geomref_colname,
-- denom_colname, numer_geomref_colname,
-- numer_tablename, numer_geomref_colname);
-- ELSIF map_type = 'predenominated' THEN
-- IF numer_aggregate NOT ILIKE 'sum' THEN
-- RAISE EXCEPTION 'Cannot calculate "%" (%) for custom area as it cannot be summed, use ST_PointOnSurface instead',
-- numer_name, measure_id;
-- ELSE
-- sql = format('WITH _subdivided AS (
-- SELECT ST_Subdivide($1) AS geom
-- ), _geom AS (SELECT SUM(ST_Area(ST_Intersection(s.geom, geom.%I)))
-- / ST_Area(cdb_observatory.FIRST(geom.%I)) overlap,
-- geom.%I geom_ref
-- FROM observatory.%I geom, _subdivided s
-- WHERE ST_Intersects(s.geom, geom.%I)
-- GROUP BY geom.%I
-- )
-- SELECT SUM(numer.%I * (SELECT _geom.overlap FROM _geom WHERE _geom.geom_ref = numer.%I))
-- FROM observatory.%I numer
-- WHERE numer.%I = ANY ((SELECT ARRAY_AGG(geom_ref) FROM _geom)::TEXT[])',
-- geom_colname, geom_colname, geom_geomref_colname,
-- geom_tablename, geom_colname, geom_geomref_colname,
-- numer_colname, numer_geomref_colname, numer_tablename,
-- numer_geomref_colname);
-- END IF;
-- END IF;
-- END IF;
--
-- EXECUTE SELECT cdb_observatory.OBS_GetMeasureDataMulti(
-- array[($1, 1)::geomval, $2
-- )
--
-- INTO result USING geom, params;
-- RETURN result;
--
--END;
--$$ LANGUAGE plpgsql IMMUTABLE;
CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetMeasure( CREATE OR REPLACE FUNCTION cdb_observatory.OBS_GetMeasure(
geom geometry(Geometry, 4326), geom geometry(Geometry, 4326),
measure_id TEXT, measure_id TEXT,