From 4902f6a9d487f9f9754c54353fec83741e7a8f4a Mon Sep 17 00:00:00 2001 From: abelvm Date: Tue, 20 Sep 2016 13:37:50 +0200 Subject: [PATCH] add NN(s) support --- src/pg/sql/08_interpolation.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pg/sql/08_interpolation.sql b/src/pg/sql/08_interpolation.sql index 608583d..d13d8e7 100644 --- a/src/pg/sql/08_interpolation.sql +++ b/src/pg/sql/08_interpolation.sql @@ -1,6 +1,8 @@ --- 0: nearest neighbor (s) +-- 0: nearest neighbor(s) -- 1: barymetric -- 2: IDW +-- 3: krigin + CREATE OR REPLACE FUNCTION CDB_SpatialInterpolation( IN query text, @@ -60,8 +62,9 @@ BEGIN p1 := 1; END IF; - WITH a as (SELECT unnest(geomin) as g, unnest(colin) as v) - SELECT avg(a.v) INTO output FROM a ORDER BY point<->a.g LIMIT p1::integer; + WITH a as (SELECT unnest(geomin) as g, unnest(colin) as v), + b as (SELECT a.v as v FROM a ORDER BY point<->a.g LIMIT p1::integer) + SELECT avg(b.v) INTO output FROM b; RETURN output; -- barymetric