From 874b5318ffef31e6d2f3cc43291d8a7cf31b2802 Mon Sep 17 00:00:00 2001 From: Stuart Lynn Date: Wed, 18 May 2016 17:32:14 -0400 Subject: [PATCH] fixing bugs and adding contours to the payload --- src/pg/sql/50_contours.sql | 30 +++++++++++++----------- src/py/crankshaft/crankshaft/__init__.py | 1 + 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/pg/sql/50_contours.sql b/src/pg/sql/50_contours.sql index 067c91b..545f518 100644 --- a/src/pg/sql/50_contours.sql +++ b/src/pg/sql/50_contours.sql @@ -1,17 +1,3 @@ -CREATE OR REPLACE FUNCTION - CDB_Contours ( - subquery TEXT, - grid_size NUMERIC DEFAULT 100, - bandwidth NUMERIC DEFAULT 0.0001, - levels NUMERIC[] DEFAULT null - ) -RETURNS table (level Numeric, geom text ) -AS $$ - RETURN QUERY - select level, ST_GeomFromText(geom_text, 4326) as geom from _CDB_Contours(subquery,grid_size,bandwidth,levels); - RETURN; -$$ LANGUAGE plpgsql; - CREATE OR REPLACE FUNCTION _CDB_Contours ( @@ -26,3 +12,19 @@ AS $$ # TODO: use named parameters or a dictionary return cdb_generate_contours(subquery, grid_size, bandwidth, levels) $$ LANGUAGE plpythonu; + + +CREATE OR REPLACE FUNCTION + CDB_Contours ( + subquery TEXT, + grid_size NUMERIC DEFAULT 100, + bandwidth NUMERIC DEFAULT 0.0001, + levels NUMERIC[] DEFAULT null + ) +RETURNS table (level Numeric, geom text ) +AS $$ +BEGIN + RETURN QUERY + select l as level, ST_GeomFromText(geom_text, 4326) as geom from _CDB_Contours(subquery,grid_size,bandwidth,levels); +END; +$$ LANGUAGE plpgsql; diff --git a/src/py/crankshaft/crankshaft/__init__.py b/src/py/crankshaft/crankshaft/__init__.py index d07e330..ac0e870 100644 --- a/src/py/crankshaft/crankshaft/__init__.py +++ b/src/py/crankshaft/crankshaft/__init__.py @@ -1,2 +1,3 @@ import random_seeds import clustering +import contours