From 4782d39849da034d272f7b4666cc27c9a4a1c41c Mon Sep 17 00:00:00 2001 From: Stuart Lynn Date: Fri, 3 Jun 2016 10:36:21 -0400 Subject: [PATCH 01/13] stubbing out gravity model --- doc/07_gravity.md | 40 +++++++++++ src/pg/sql/07_gravity.sql | 84 ++++++++++++++++++++++++ src/pg/test/expected/07_gravity_test.out | 0 src/pg/test/sql/07_gravity_test.sql | 1 + 4 files changed, 125 insertions(+) create mode 100644 doc/07_gravity.md create mode 100644 src/pg/sql/07_gravity.sql create mode 100644 src/pg/test/expected/07_gravity_test.out create mode 100644 src/pg/test/sql/07_gravity_test.sql diff --git a/doc/07_gravity.md b/doc/07_gravity.md new file mode 100644 index 0000000..0ce2532 --- /dev/null +++ b/doc/07_gravity.md @@ -0,0 +1,40 @@ +## Gravity Model + +### CDB_Gravity() + +The Gravity Model is derived from newtons law of gravity and is used to estimate the degree of interaction between two places + +#### Arguments + +| Name | Type | Description | +|------|------|-------------| +| t_id | bigint[] | | +| t_geom | geometry[] | | +| t_weight | numeric[] | | +| s_id | bigint[] | | +| s_geom | geometry[] | | +| s_pop | numeric[] | | +| target | bigint | | +| radius | integer | | +| minval | numeric | | + + +#### Returns + +| Column Name | Type | Description | +|-------------|------|-------------| +| the_geom | Numeric | | +| source_id | bigint | | +| target_id | bigint | | +| dist | Numeric | | +| n | Numeric | | +| hpop | NUMERIC | | + + +#### Example Usage + +```sql +SELECT CDB_GRAVITY (); +``` + + diff --git a/src/pg/sql/07_gravity.sql b/src/pg/sql/07_gravity.sql new file mode 100644 index 0000000..7c4e220 --- /dev/null +++ b/src/pg/sql/07_gravity.sql @@ -0,0 +1,84 @@ +CREATE OR REPLACE FUNCTION CDB_Gravity( + IN t_id bigint[], + IN t_geom geometry[], + IN t_weight numeric[], + IN s_id bigint[], + IN s_geom geometry[], + IN s_pop numeric[], + IN target bigint, + IN radius integer, + IN minval numeric DEFAULT -10e307 + ) +RETURNS TABLE( + the_geom geometry, + source_id bigint, + target_id bigint, + dist numeric, + h numeric, + hpop numeric) AS $$ +DECLARE + t_type text; + s_type text; + t_center geometry[]; + s_center geometry[]; +BEGIN + t_type := GeometryType(t_geom[1]); + s_type := GeometryType(s_geom[1]); + IF t_type = 'POINT' THEN + t_center := t_geom; + ELSE + WITH tmp as (SELECT unnest(t_geom) as g) SELECT array_agg(ST_Centroid(g)) INTO t_center FROM tmp; + END IF; + IF s_type = 'POINT' THEN + s_center := s_geom; + ELSE + WITH tmp as (SELECT unnest(s_geom) as g) SELECT array_agg(ST_Centroid(g)) INTO s_center FROM tmp; + END IF; + RETURN QUERY + with target0 as( + SELECT unnest(t_center) as tc, unnest(t_weight) as tw, unnest(t_id) as td + ), + source0 as( + SELECT unnest(s_center) as sc, unnest(s_id) as sd, unnest (s_geom) as sg, unnest(s_pop) as sp + ), + prev0 as( + SELECT + source0.sg, + source0.sd as sourc_id, + coalesce(source0.sp,0) as sp, + target.td as targ_id, + coalesce(target.tw,0) as tw, + GREATEST(1.0,ST_Distance(geography(target.tc), geography(source0.sc)))::numeric as distance + FROM source0 + CROSS JOIN LATERAL + ( + SELECT + * + FROM target0 + WHERE tw > minval + AND ST_DWithin(geography(source0.sc), geography(tc), radius) + ) AS target + ), + deno as( + SELECT + sourc_id, + sum(tw/distance) as h_deno + FROM + prev0 + GROUP BY sourc_id + ) + SELECT + p.sg as the_geom, + p.sourc_id as source_id, + p.targ_id as target_id, + case when p.distance > 1 then p.distance else 0.0 end as dist, + 100*(p.tw/p.distance)/d.h_deno as h, + p.sp*(p.tw/p.distance)/d.h_deno as hpop + FROM + prev0 p, + deno d + WHERE + p.targ_id = target AND + p.sourc_id = d.sourc_id; +END; +$$ language plpgsql; diff --git a/src/pg/test/expected/07_gravity_test.out b/src/pg/test/expected/07_gravity_test.out new file mode 100644 index 0000000..e69de29 diff --git a/src/pg/test/sql/07_gravity_test.sql b/src/pg/test/sql/07_gravity_test.sql new file mode 100644 index 0000000..22d22dd --- /dev/null +++ b/src/pg/test/sql/07_gravity_test.sql @@ -0,0 +1 @@ +select * form CDB_Gravity() From 73d38bbbaac66c8dacd9f90cc6acca6a92a4a171 Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 3 Jun 2016 17:32:39 +0200 Subject: [PATCH 02/13] filling the gaps --- doc/07_gravity.md | 68 ++++++++++++++++-------- src/pg/test/expected/07_gravity_test.out | 11 ++++ src/pg/test/sql/07_gravity_test.sql | 22 +++++++- 3 files changed, 78 insertions(+), 23 deletions(-) diff --git a/doc/07_gravity.md b/doc/07_gravity.md index 0ce2532..9c8d5e4 100644 --- a/doc/07_gravity.md +++ b/doc/07_gravity.md @@ -1,40 +1,64 @@ -## Gravity Model +## Gravity Model -### CDB_Gravity() +### CDB_Gravity(t_id bigint[], t_geom geometry[], t_weight numeric[], s_id bigint[], s_geom geometry[], s_pop numeric[], target bigint, radius integer, minval numeric DEFAULT -10e307) -The Gravity Model is derived from newtons law of gravity and is used to estimate the degree of interaction between two places +Gravity Models are derived from Newton's Law of Gravity and are used to predict the interaction between a group of populated areas (sources) and a specific target among a group of potential targets, in terms of an attraction factor (weight) -#### Arguments +**CDB_Gravity** is based on the model defined in *Huff's Law of Shopper attraction (1963)* -| Name | Type | Description | +#### Arguments + +| Name | Type | Description | |------|------|-------------| -| t_id | bigint[] | | -| t_geom | geometry[] | | -| t_weight | numeric[] | | -| s_id | bigint[] | | -| s_geom | geometry[] | | -| s_pop | numeric[] | | -| target | bigint | | -| radius | integer | | -| minval | numeric | | +| t_id | bigint[] | Array of targets ID | +| t_geom | geometry[] | Array of targets' geometries | +| t_weight | numeric[] | Array of targets's weights | +| s_id | bigint[] | Array of sources ID | +| s_geom | geometry[] | Array of sources' geometries | +| s_pop | numeric[] | Array of sources's population | +| target | bigint | ID of the target under study | +| radius | integer | Radius in meters around the target under study that will be taken into account| +| minval (optional) | numeric | Lowest accepted value of weight, defaults to numeric min_value | -#### Returns +#### Returns | Column Name | Type | Description | |-------------|------|-------------| -| the_geom | Numeric | | -| source_id | bigint | | -| target_id | bigint | | -| dist | Numeric | | -| n | Numeric | | -| hpop | NUMERIC | | +| the_geom | geometry | Geometries of the sources within the radius | +| source_id | bigint | ID of the source | +| target_id | bigint | Target ID from input | +| dist | numeric | Distance in meters source to target (if not points, distance between centroids) | +| h | numeric | Probability of patronage | +| hpop | numeric | Patronaging population | #### Example Usage ```sql -SELECT CDB_GRAVITY (); +with t as ( +SELECT + array_agg(cartodb_id::bigint) as id, + array_agg(the_geom) as g, + array_agg(coalesce(gla,0)::numeric) as w +FROM + abel.centros_comerciales_de_madrid +WHERE not no_cc +), +s as ( +SELECT + array_agg(cartodb_id::bigint) as id, + array_agg(center) as g, + array_agg(coalesce(t1_1, 0)::numeric) as p +FROM + sscc_madrid +) +select + g.the_geom, + trunc(g.h,2) as h, + round(g.hpop) as hpop, + trunc(g.dist/1000,2) as dist_km +FROM t, s, CDB_Gravity1(t.id, t.g, t.w, s.id, s.g, s.p, newmall_ID, 100000, 5000) g ``` diff --git a/src/pg/test/expected/07_gravity_test.out b/src/pg/test/expected/07_gravity_test.out index e69de29..c101b24 100644 --- a/src/pg/test/expected/07_gravity_test.out +++ b/src/pg/test/expected/07_gravity_test.out @@ -0,0 +1,11 @@ + the_geom | h | hpop | dist +--------------------------------------------+-------------------------+--------------------------+---------------- + 01010000001361C3D32B650140DD24068195B34440 | 1.51078258369747945249 | 12.08626066957983561994 | 4964.714459152 + 01010000002497FF907EFB0040713D0AD7A3B04440 | 98.29730954183620807430 | 688.08116679285345652007 | 99.955141922 + 0101000000A167B3EA733501401D5A643BDFAF4440 | 63.70532894711274639196 | 382.23197368267647835174 | 2488.330566505 + 010100000062A1D634EF380140BE9F1A2FDDB44440 | 35.35415870080995954879 | 176.77079350404979774397 | 4359.370460594 + 010100000052B81E85EB510140355EBA490CB24440 | 33.12290506987740864904 | 132.49162027950963459615 | 3703.664449828 + 0101000000C286A757CA320140736891ED7CAF4440 | 65.45251754279248087849 | 196.35755262837744263547 | 2512.092358644 + 01010000007DD0B359F5390140C976BE9F1AAF4440 | 62.83927792471345639225 | 125.67855584942691278449 | 2926.25725244 + 0101000000D237691A140D01407E6FD39FFDB44440 | 53.54905726651871279586 | 53.54905726651871279586 | 3744.515577777 +(8 rows) diff --git a/src/pg/test/sql/07_gravity_test.sql b/src/pg/test/sql/07_gravity_test.sql index 22d22dd..a86bb23 100644 --- a/src/pg/test/sql/07_gravity_test.sql +++ b/src/pg/test/sql/07_gravity_test.sql @@ -1 +1,21 @@ -select * form CDB_Gravity() +WITH t AS ( + SELECT + ARRAY[1,2,3] AS id, + ARRAY[7.0,8.0,3.0] AS w, + ARRAY[ST_GeomFromText('POINT(2.1744 41.4036)'),ST_GeomFromText('POINT(2.1228 41.3809)'),ST_GeomFromText('POINT(2.1511 41.3742)')] AS g +), +s AS ( + SELECT + ARRAY[10,20,30,40,50,60,70,80] AS id, + ARRAY[800, 700, 600, 500, 400, 300, 200, 100] AS p, + ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS g +) +SELECT + g.the_geom, + g.h, + g.hpop, + g.dist +FROM + t, + s, + CDB_Gravity(t.id, t.g, t.w, s.id, s.g, s.p, 2, 100000, 3) g; From 5183f5ff92628f289d75477a7da2cb9f75260710 Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 3 Jun 2016 18:22:26 +0200 Subject: [PATCH 03/13] added function overload with subqueries input --- doc/07_gravity.md | 20 +++++++++++++++++--- src/pg/sql/07_gravity.sql | 31 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/doc/07_gravity.md b/doc/07_gravity.md index 9c8d5e4..e4e439e 100644 --- a/doc/07_gravity.md +++ b/doc/07_gravity.md @@ -1,11 +1,11 @@ ## Gravity Model -### CDB_Gravity(t_id bigint[], t_geom geometry[], t_weight numeric[], s_id bigint[], s_geom geometry[], s_pop numeric[], target bigint, radius integer, minval numeric DEFAULT -10e307) - Gravity Models are derived from Newton's Law of Gravity and are used to predict the interaction between a group of populated areas (sources) and a specific target among a group of potential targets, in terms of an attraction factor (weight) **CDB_Gravity** is based on the model defined in *Huff's Law of Shopper attraction (1963)* +### CDB_Gravity(t_id bigint[], t_geom geometry[], t_weight numeric[], s_id bigint[], s_geom geometry[], s_pop numeric[], target bigint, radius integer, minval numeric DEFAULT -10e307) + #### Arguments | Name | Type | Description | @@ -20,8 +20,22 @@ Gravity Models are derived from Newton's Law of Gravity and are used to predict | radius | integer | Radius in meters around the target under study that will be taken into account| | minval (optional) | numeric | Lowest accepted value of weight, defaults to numeric min_value | +### CDB_Gravity( target_query text, weight_column text, source_query text, pop_column text, target bigint, radius integer, minval numeric DEFAULT -10e307) -#### Returns +#### Arguments + +| Name | Type | Description | +|------|------|-------------| +| target_query | text | Query that defines targets | +| weight_column | text | Column name of weights | +| source_query | text | Query that defines sources | +| pop_column | text | Column name of population | +| target | bigint | cartodb_id of the target under study | +| radius | integer | Radius in meters around the target under study that will be taken into account| +| minval (optional) | numeric | Lowest accepted value of weight, defaults to numeric min_value | + + +### Returns | Column Name | Type | Description | |-------------|------|-------------| diff --git a/src/pg/sql/07_gravity.sql b/src/pg/sql/07_gravity.sql index 7c4e220..47e5b8e 100644 --- a/src/pg/sql/07_gravity.sql +++ b/src/pg/sql/07_gravity.sql @@ -1,3 +1,34 @@ +CREATE OR REPLACE FUNCTION CDB_Gravity( + IN target_query text, + IN weight_column text, + IN source_query text, + IN pop_column text, + IN target bigint, + IN radius integer, + IN minval numeric DEFAULT -10e307 + ) +RETURNS TABLE( + the_geom geometry, + source_id bigint, + target_id bigint, + dist numeric, + h numeric, + hpop numeric) AS $$ +DECLARE + t_id bigint[]; + t_geom geometry[]; + t_weight numeric[]; + s_id bigint[]; + s_geom geometry[]; + s_pop numeric[]; +BEGIN + EXECUTE 'WITH foo as('+target_query+') SELECT array_agg(cartodb_id), array_agg(the_geom), array_agg(' || weight_column || ') FROM foo' INTO t_id, t_geom, t_weight; + EXECUTE 'WITH foo as('+source_query+') SELECT array_agg(cartodb_id), array_agg(the_geom), array_agg(' || pop_column || ') FROM foo' INTO s_id, s_geom, s_pop; + RETURN QUERY + SELECT g.* FROM t, s, CDB_Gravity(t_id, t_geom, t_weight, s_id, s_geom, s_pop, target, radius, minval) g; +END; +$$ language plpgsql; + CREATE OR REPLACE FUNCTION CDB_Gravity( IN t_id bigint[], IN t_geom geometry[], From 9db4b7f5192c3f946bc6c6dab4a956e3e9a39d16 Mon Sep 17 00:00:00 2001 From: abelvm Date: Tue, 14 Jun 2016 17:55:45 +0200 Subject: [PATCH 04/13] first commit --- doc/08_interpolation.md | 51 +++++++ src/pg/sql/08_interpolation.sql | 127 ++++++++++++++++++ .../test/expected/08_interpolation_test.out | 4 + src/pg/test/sql/08_interpolation_test.sql | 6 + 4 files changed, 188 insertions(+) create mode 100644 doc/08_interpolation.md create mode 100644 src/pg/sql/08_interpolation.sql create mode 100644 src/pg/test/expected/08_interpolation_test.out create mode 100644 src/pg/test/sql/08_interpolation_test.sql diff --git a/doc/08_interpolation.md b/doc/08_interpolation.md new file mode 100644 index 0000000..22fc1bc --- /dev/null +++ b/doc/08_interpolation.md @@ -0,0 +1,51 @@ +## Spacial interpolation + +Function to interpolate a numeric attribute of a point in a scatter dataset of points, using one of three methos: + +* [Nearest neighbor](https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation) +* [Barycentric](https://en.wikipedia.org/wiki/Barycentric_coordinate_system) +* [IDW](https://en.wikipedia.org/wiki/Inverse_distance_weighting) + +### CDB_SpatialInterpolation (query text, point geometry, method integer DEFAULT 1, p1 integer DEFAULT 0, ps integer DEFAULT 0) + +#### Arguments + +| Name | Type | Description | +|------|------|-------------| +| query | text | query that returns at least `the_geom` and a numeric value as `attrib` | +| point | geometry | The target point to calc the value | +| method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW| +| p1 | integer | IDW: limit the number of neighbors, 0->no limit| +| p2 | integer | IDW: order of distance decay, 0-> order 1| + +### CDB_SpatialInterpolation (geom geometry[], values numeric[], point geometry, method integer DEFAULT 1, p1 integer DEFAULT 0, ps integer DEFAULT 0) + +#### Arguments + +| Name | Type | Description | +|------|------|-------------| +| geom | geometry[] | Array of points's geometries | +| values | numeric[] | Array of points' values for the param under study| +| point | geometry | The target point to calc the value | +| method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW| +| p1 | integer | IDW: limit the number of neighbors, 0->no limit| +| p2 | integer | IDW: order of distance decay, 0-> order 1| + +### Returns + +| Column Name | Type | Description | +|-------------|------|-------------| +| value | numeric | Interpolated value at the given point, `-888.888` if the given point is out of the boundaries of the source points set | + + +#### Example Usage + +```sql +with a as ( + select + array_agg(the_geom) as geomin, + array_agg(temp::numeric) as colin + from table_4804232032 +) +SELECT CDB_SpatialInterpolation(geomin, colin, CDB_latlng(41.38, 2.15),1) FROM a; +``` diff --git a/src/pg/sql/08_interpolation.sql b/src/pg/sql/08_interpolation.sql new file mode 100644 index 0000000..04f1584 --- /dev/null +++ b/src/pg/sql/08_interpolation.sql @@ -0,0 +1,127 @@ +-- 0: nearest neighbor +-- 1: barymetric +-- 2: IDW + +CREATE OR REPLACE FUNCTION CDB_SpatialInterpolation( + IN query text, + IN point geometry, + IN method integer DEFAULT 1, + IN p1 numeric DEFAULT 0, + IN p2 numeric DEFAULT 0 + ) +RETURNS numeric AS +$$ +DECLARE + gs geometry[]; + vs numeric[]; +BEGIN + EXECUTE 'WITH a AS('||query||') SELECT array_agg(the_geom), array_agg(attrib) FROM a' INTO gs, vs; + RETURN QUERY SELECT CDB_SpatialInterpolation(gs, vs, point, method, p1,p2) FROM a; +END; +$$ +language plpgsql IMMUTABLE; + +CREATE OR REPLACE FUNCTION CDB_SpatialInterpolation( + IN geomin geometry[], + IN colin numeric[], + IN point geometry, + IN method integer DEFAULT 1, + IN p1 numeric DEFAULT 0, + IN p2 numeric DEFAULT 0 + ) +RETURNS numeric AS +$$ +DECLARE + gs geometry[]; + vs numeric[]; + gs2 geometry[]; + vs2 numeric[]; + g geometry; + vertex geometry[]; + sg numeric; + sa numeric; + sb numeric; + sc numeric; + va numeric; + vb numeric; + vc numeric; + output numeric; +BEGIN + output := -999.999; + -- nearest + IF method = 0 THEN + + WITH a as (SELECT unnest(geomin) as g, unnest(colin) as v) + SELECT a.v INTO output FROM a ORDER BY point<->a.g LIMIT 1; + RETURN output; + + -- barymetric + ELSIF method = 1 THEN + WITH a as (SELECT unnest(geomin) AS e), + b as (SELECT ST_DelaunayTriangles(ST_Collect(a.e),0.001, 0) AS t FROM a), + c as (SELECT (ST_Dump(t)).geom as v FROM b), + d as (SELECT v FROM c WHERE ST_Within(point, v)) + SELECT v INTO g FROM d; + IF g is null THEN + -- out of the realm of the input data + RETURN -888.888; + END IF; + -- vertex of the selected cell + WITH a AS (SELECT (ST_DumpPoints(g)).geom AS v) + SELECT array_agg(v) INTO vertex FROM a; + + -- retrieve the value of each vertex + WITH a AS(SELECT unnest(vertex) as geo, unnest(colin) as c) + SELECT c INTO va FROM a WHERE ST_Equals(geo, vertex[1]); + WITH a AS(SELECT unnest(vertex) as geo, unnest(colin) as c) + SELECT c INTO vb FROM a WHERE ST_Equals(geo, vertex[2]); + WITH a AS(SELECT unnest(vertex) as geo, unnest(colin) as c) + SELECT c INTO vc FROM a WHERE ST_Equals(geo, vertex[3]); + + SELECT ST_area(g), ST_area(ST_MakePolygon(ST_MakeLine(ARRAY[point, vertex[2], vertex[3], point]))), ST_area(ST_MakePolygon(ST_MakeLine(ARRAY[point, vertex[1], vertex[3], point]))), ST_area(ST_MakePolygon(ST_MakeLine(ARRAY[point,vertex[1],vertex[2], point]))) INTO sg, sa, sb, sc; + + output := (coalesce(sa,0) * coalesce(va,0) + coalesce(sb,0) * coalesce(vb,0) + coalesce(sc,0) * coalesce(vc,0)) / coalesce(sg); + RETURN output; + + -- IDW + -- p1: limit the number of neighbors, 0->no limit + -- p2: order of distance decay, 0-> order 1 + ELSIF method = 2 THEN + + IF p2 = 0 THEN + p2 := 1; + END IF; + + WITH a as (SELECT unnest(geomin) as g, unnest(colin) as v), + b as (SELECT a.g, a.v FROM a ORDER BY point<->a.g) + SELECT array_agg(b.g), array_agg(b.v) INTO gs, vs FROM b; + IF p1::integer>0 THEN + gs2:=gs; + vs2:=vs; + FOR i IN 1..p1 + LOOP + gs2 := gs2 || gs[i]; + vs2 := vs2 || vs[i]; + END LOOP; + ELSE + gs2:=gs; + vs2:=vs; + END IF; + + WITH a as (SELECT unnest(gs2) as g, unnest(vs2) as v), + b as ( + SELECT + (1/ST_distance(point, a.g)^p2::integer) as k, + (a.v/ST_distance(point, a.g)^p2::integer) as f + FROM a + ) + SELECT sum(b.f)/sum(b.k) INTO output FROM b; + RETURN output; + + END IF; + + RETURN -777.777; + +END; +$$ +language plpgsql IMMUTABLE; diff --git a/src/pg/test/expected/08_interpolation_test.out b/src/pg/test/expected/08_interpolation_test.out new file mode 100644 index 0000000..42d24cb --- /dev/null +++ b/src/pg/test/expected/08_interpolation_test.out @@ -0,0 +1,4 @@ + cdb_spatialinterpolation +-------------------------- + 780.79470198683925288365 +(1 row) diff --git a/src/pg/test/sql/08_interpolation_test.sql b/src/pg/test/sql/08_interpolation_test.sql new file mode 100644 index 0000000..c8db89d --- /dev/null +++ b/src/pg/test/sql/08_interpolation_test.sql @@ -0,0 +1,6 @@ +WITH a AS ( + SELECT + ARRAY[800, 700, 600, 500, 400, 300, 200, 100] AS vals, + ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS g +) +SELECT CDB_SpatialInterpolation(g, vals, ST_GeomFromText('POINT(2.154 41.37)'),1) FROM a; From 5a2319db72c2a04aa3a7ef1a2cf6fa3263ecfd86 Mon Sep 17 00:00:00 2001 From: abelvm Date: Tue, 14 Jun 2016 18:01:03 +0200 Subject: [PATCH 05/13] remove garbage --- doc/07_gravity.md | 78 --------------- src/pg/sql/07_gravity.sql | 115 ----------------------- src/pg/test/expected/07_gravity_test.out | 11 --- src/pg/test/sql/07_gravity_test.sql | 21 ----- 4 files changed, 225 deletions(-) delete mode 100644 doc/07_gravity.md delete mode 100644 src/pg/sql/07_gravity.sql delete mode 100644 src/pg/test/expected/07_gravity_test.out delete mode 100644 src/pg/test/sql/07_gravity_test.sql diff --git a/doc/07_gravity.md b/doc/07_gravity.md deleted file mode 100644 index e4e439e..0000000 --- a/doc/07_gravity.md +++ /dev/null @@ -1,78 +0,0 @@ -## Gravity Model - -Gravity Models are derived from Newton's Law of Gravity and are used to predict the interaction between a group of populated areas (sources) and a specific target among a group of potential targets, in terms of an attraction factor (weight) - -**CDB_Gravity** is based on the model defined in *Huff's Law of Shopper attraction (1963)* - -### CDB_Gravity(t_id bigint[], t_geom geometry[], t_weight numeric[], s_id bigint[], s_geom geometry[], s_pop numeric[], target bigint, radius integer, minval numeric DEFAULT -10e307) - -#### Arguments - -| Name | Type | Description | -|------|------|-------------| -| t_id | bigint[] | Array of targets ID | -| t_geom | geometry[] | Array of targets' geometries | -| t_weight | numeric[] | Array of targets's weights | -| s_id | bigint[] | Array of sources ID | -| s_geom | geometry[] | Array of sources' geometries | -| s_pop | numeric[] | Array of sources's population | -| target | bigint | ID of the target under study | -| radius | integer | Radius in meters around the target under study that will be taken into account| -| minval (optional) | numeric | Lowest accepted value of weight, defaults to numeric min_value | - -### CDB_Gravity( target_query text, weight_column text, source_query text, pop_column text, target bigint, radius integer, minval numeric DEFAULT -10e307) - -#### Arguments - -| Name | Type | Description | -|------|------|-------------| -| target_query | text | Query that defines targets | -| weight_column | text | Column name of weights | -| source_query | text | Query that defines sources | -| pop_column | text | Column name of population | -| target | bigint | cartodb_id of the target under study | -| radius | integer | Radius in meters around the target under study that will be taken into account| -| minval (optional) | numeric | Lowest accepted value of weight, defaults to numeric min_value | - - -### Returns - -| Column Name | Type | Description | -|-------------|------|-------------| -| the_geom | geometry | Geometries of the sources within the radius | -| source_id | bigint | ID of the source | -| target_id | bigint | Target ID from input | -| dist | numeric | Distance in meters source to target (if not points, distance between centroids) | -| h | numeric | Probability of patronage | -| hpop | numeric | Patronaging population | - - -#### Example Usage - -```sql -with t as ( -SELECT - array_agg(cartodb_id::bigint) as id, - array_agg(the_geom) as g, - array_agg(coalesce(gla,0)::numeric) as w -FROM - abel.centros_comerciales_de_madrid -WHERE not no_cc -), -s as ( -SELECT - array_agg(cartodb_id::bigint) as id, - array_agg(center) as g, - array_agg(coalesce(t1_1, 0)::numeric) as p -FROM - sscc_madrid -) -select - g.the_geom, - trunc(g.h,2) as h, - round(g.hpop) as hpop, - trunc(g.dist/1000,2) as dist_km -FROM t, s, CDB_Gravity1(t.id, t.g, t.w, s.id, s.g, s.p, newmall_ID, 100000, 5000) g -``` - - diff --git a/src/pg/sql/07_gravity.sql b/src/pg/sql/07_gravity.sql deleted file mode 100644 index 47e5b8e..0000000 --- a/src/pg/sql/07_gravity.sql +++ /dev/null @@ -1,115 +0,0 @@ -CREATE OR REPLACE FUNCTION CDB_Gravity( - IN target_query text, - IN weight_column text, - IN source_query text, - IN pop_column text, - IN target bigint, - IN radius integer, - IN minval numeric DEFAULT -10e307 - ) -RETURNS TABLE( - the_geom geometry, - source_id bigint, - target_id bigint, - dist numeric, - h numeric, - hpop numeric) AS $$ -DECLARE - t_id bigint[]; - t_geom geometry[]; - t_weight numeric[]; - s_id bigint[]; - s_geom geometry[]; - s_pop numeric[]; -BEGIN - EXECUTE 'WITH foo as('+target_query+') SELECT array_agg(cartodb_id), array_agg(the_geom), array_agg(' || weight_column || ') FROM foo' INTO t_id, t_geom, t_weight; - EXECUTE 'WITH foo as('+source_query+') SELECT array_agg(cartodb_id), array_agg(the_geom), array_agg(' || pop_column || ') FROM foo' INTO s_id, s_geom, s_pop; - RETURN QUERY - SELECT g.* FROM t, s, CDB_Gravity(t_id, t_geom, t_weight, s_id, s_geom, s_pop, target, radius, minval) g; -END; -$$ language plpgsql; - -CREATE OR REPLACE FUNCTION CDB_Gravity( - IN t_id bigint[], - IN t_geom geometry[], - IN t_weight numeric[], - IN s_id bigint[], - IN s_geom geometry[], - IN s_pop numeric[], - IN target bigint, - IN radius integer, - IN minval numeric DEFAULT -10e307 - ) -RETURNS TABLE( - the_geom geometry, - source_id bigint, - target_id bigint, - dist numeric, - h numeric, - hpop numeric) AS $$ -DECLARE - t_type text; - s_type text; - t_center geometry[]; - s_center geometry[]; -BEGIN - t_type := GeometryType(t_geom[1]); - s_type := GeometryType(s_geom[1]); - IF t_type = 'POINT' THEN - t_center := t_geom; - ELSE - WITH tmp as (SELECT unnest(t_geom) as g) SELECT array_agg(ST_Centroid(g)) INTO t_center FROM tmp; - END IF; - IF s_type = 'POINT' THEN - s_center := s_geom; - ELSE - WITH tmp as (SELECT unnest(s_geom) as g) SELECT array_agg(ST_Centroid(g)) INTO s_center FROM tmp; - END IF; - RETURN QUERY - with target0 as( - SELECT unnest(t_center) as tc, unnest(t_weight) as tw, unnest(t_id) as td - ), - source0 as( - SELECT unnest(s_center) as sc, unnest(s_id) as sd, unnest (s_geom) as sg, unnest(s_pop) as sp - ), - prev0 as( - SELECT - source0.sg, - source0.sd as sourc_id, - coalesce(source0.sp,0) as sp, - target.td as targ_id, - coalesce(target.tw,0) as tw, - GREATEST(1.0,ST_Distance(geography(target.tc), geography(source0.sc)))::numeric as distance - FROM source0 - CROSS JOIN LATERAL - ( - SELECT - * - FROM target0 - WHERE tw > minval - AND ST_DWithin(geography(source0.sc), geography(tc), radius) - ) AS target - ), - deno as( - SELECT - sourc_id, - sum(tw/distance) as h_deno - FROM - prev0 - GROUP BY sourc_id - ) - SELECT - p.sg as the_geom, - p.sourc_id as source_id, - p.targ_id as target_id, - case when p.distance > 1 then p.distance else 0.0 end as dist, - 100*(p.tw/p.distance)/d.h_deno as h, - p.sp*(p.tw/p.distance)/d.h_deno as hpop - FROM - prev0 p, - deno d - WHERE - p.targ_id = target AND - p.sourc_id = d.sourc_id; -END; -$$ language plpgsql; diff --git a/src/pg/test/expected/07_gravity_test.out b/src/pg/test/expected/07_gravity_test.out deleted file mode 100644 index c101b24..0000000 --- a/src/pg/test/expected/07_gravity_test.out +++ /dev/null @@ -1,11 +0,0 @@ - the_geom | h | hpop | dist ---------------------------------------------+-------------------------+--------------------------+---------------- - 01010000001361C3D32B650140DD24068195B34440 | 1.51078258369747945249 | 12.08626066957983561994 | 4964.714459152 - 01010000002497FF907EFB0040713D0AD7A3B04440 | 98.29730954183620807430 | 688.08116679285345652007 | 99.955141922 - 0101000000A167B3EA733501401D5A643BDFAF4440 | 63.70532894711274639196 | 382.23197368267647835174 | 2488.330566505 - 010100000062A1D634EF380140BE9F1A2FDDB44440 | 35.35415870080995954879 | 176.77079350404979774397 | 4359.370460594 - 010100000052B81E85EB510140355EBA490CB24440 | 33.12290506987740864904 | 132.49162027950963459615 | 3703.664449828 - 0101000000C286A757CA320140736891ED7CAF4440 | 65.45251754279248087849 | 196.35755262837744263547 | 2512.092358644 - 01010000007DD0B359F5390140C976BE9F1AAF4440 | 62.83927792471345639225 | 125.67855584942691278449 | 2926.25725244 - 0101000000D237691A140D01407E6FD39FFDB44440 | 53.54905726651871279586 | 53.54905726651871279586 | 3744.515577777 -(8 rows) diff --git a/src/pg/test/sql/07_gravity_test.sql b/src/pg/test/sql/07_gravity_test.sql deleted file mode 100644 index a86bb23..0000000 --- a/src/pg/test/sql/07_gravity_test.sql +++ /dev/null @@ -1,21 +0,0 @@ -WITH t AS ( - SELECT - ARRAY[1,2,3] AS id, - ARRAY[7.0,8.0,3.0] AS w, - ARRAY[ST_GeomFromText('POINT(2.1744 41.4036)'),ST_GeomFromText('POINT(2.1228 41.3809)'),ST_GeomFromText('POINT(2.1511 41.3742)')] AS g -), -s AS ( - SELECT - ARRAY[10,20,30,40,50,60,70,80] AS id, - ARRAY[800, 700, 600, 500, 400, 300, 200, 100] AS p, - ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS g -) -SELECT - g.the_geom, - g.h, - g.hpop, - g.dist -FROM - t, - s, - CDB_Gravity(t.id, t.g, t.w, s.id, s.g, s.p, 2, 100000, 3) g; From 1912d57891d539a15da5df8511f184e8e0c20771 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 21 Jun 2016 17:31:17 -0400 Subject: [PATCH 06/13] replacing dict with ordered dict --- .../crankshaft/crankshaft/clustering/moran.py | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index 39b3ff6..103670f 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -7,6 +7,7 @@ Moran's I geostatistics (global clustering & outliers presence) import pysal as ps import plpy +from collections import OrderedDict # crankshaft module import crankshaft.pysal_utils as pu @@ -21,11 +22,11 @@ def moran(subquery, attr_name, core clusters with PySAL. Andy Eschbacher """ - qvals = {"id_col": id_col, - "attr1": attr_name, - "geom_col": geom_col, - "subquery": subquery, - "num_ngbrs": num_ngbrs} + qvals = OrderedDict([("id_col", id_col), + ("attr1", attr_name), + ("geom_col", geom_col), + ("subquery", subquery), + ("num_ngbrs", num_ngbrs)]) query = pu.construct_neighbor_query(w_type, qvals) @@ -65,11 +66,11 @@ def moran_local(subquery, attr, # geometries with attributes that are null are ignored # resulting in a collection of not as near neighbors - qvals = {"id_col": id_col, - "attr1": attr, - "geom_col": geom_col, - "subquery": subquery, - "num_ngbrs": num_ngbrs} + qvals = OrderedDict([("id_col", id_col), + ("attr1", attr_name), + ("geom_col", geom_col), + ("subquery", subquery), + ("num_ngbrs", num_ngbrs)]) query = pu.construct_neighbor_query(w_type, qvals) @@ -101,12 +102,12 @@ def moran_rate(subquery, numerator, denominator, Moran's I Rate (global) Andy Eschbacher """ - qvals = {"id_col": id_col, - "attr1": numerator, - "attr2": denominator, - "geom_col": geom_col, - "subquery": subquery, - "num_ngbrs": num_ngbrs} + qvals = OrderedDict([("id_col", id_col), + ("attr1", numerator), + ("attr2", denominator) + ("geom_col", geom_col), + ("subquery", subquery), + ("num_ngbrs", num_ngbrs)]) query = pu.construct_neighbor_query(w_type, qvals) @@ -145,13 +146,14 @@ def moran_local_rate(subquery, numerator, denominator, # geometries with values that are null are ignored # resulting in a collection of not as near neighbors - query = pu.construct_neighbor_query(w_type, - {"id_col": id_col, - "numerator": numerator, - "denominator": denominator, - "geom_col": geom_col, - "subquery": subquery, - "num_ngbrs": num_ngbrs}) + qvals = OrderedDict([("id_col", id_col), + ("numerator", numerator), + ("denominator", denominator), + ("geom_col": geom_col), + ("subquery", subquery), + ("num_ngbrs", num_ngbrs)]) + + query = pu.construct_neighbor_query(w_type, qvals) try: result = plpy.execute(query) @@ -186,12 +188,12 @@ def moran_local_bv(subquery, attr1, attr2, """ plpy.notice('** Constructing query') - qvals = {"num_ngbrs": num_ngbrs, - "attr1": attr1, - "attr2": attr2, - "subquery": subquery, - "geom_col": geom_col, - "id_col": id_col} + qvals = OrderedDict([("id_col", id_col), + ("attr1", attr1), + ("attr2", attr2), + ("geom_col": geom_col), + ("subquery", subquery), + ("num_ngbrs", num_ngbrs)]) query = pu.construct_neighbor_query(w_type, qvals) From 7c4314a4113baf852e260af4995e77ca8f8a4a9e Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 21 Jun 2016 17:38:49 -0400 Subject: [PATCH 07/13] fix tuple colon --- src/py/crankshaft/crankshaft/clustering/moran.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index 103670f..08fe127 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -149,7 +149,7 @@ def moran_local_rate(subquery, numerator, denominator, qvals = OrderedDict([("id_col", id_col), ("numerator", numerator), ("denominator", denominator), - ("geom_col": geom_col), + ("geom_col", geom_col), ("subquery", subquery), ("num_ngbrs", num_ngbrs)]) @@ -191,7 +191,7 @@ def moran_local_bv(subquery, attr1, attr2, qvals = OrderedDict([("id_col", id_col), ("attr1", attr1), ("attr2", attr2), - ("geom_col": geom_col), + ("geom_col", geom_col), ("subquery", subquery), ("num_ngbrs", num_ngbrs)]) From b62d7b32efdb5c96f642a4947fee12f51dd489b9 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Tue, 21 Jun 2016 17:41:52 -0400 Subject: [PATCH 08/13] fix variable name --- src/py/crankshaft/crankshaft/clustering/moran.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index 08fe127..4bced89 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -67,7 +67,7 @@ def moran_local(subquery, attr, # resulting in a collection of not as near neighbors qvals = OrderedDict([("id_col", id_col), - ("attr1", attr_name), + ("attr1", attr), ("geom_col", geom_col), ("subquery", subquery), ("num_ngbrs", num_ngbrs)]) From 81d7af9e9aeaaedda2e12b3e454d61b0a28286f3 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Wed, 22 Jun 2016 15:21:09 -0400 Subject: [PATCH 09/13] fixes return problem --- src/pg/sql/08_interpolation.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pg/sql/08_interpolation.sql b/src/pg/sql/08_interpolation.sql index 04f1584..76fad01 100644 --- a/src/pg/sql/08_interpolation.sql +++ b/src/pg/sql/08_interpolation.sql @@ -14,9 +14,12 @@ $$ DECLARE gs geometry[]; vs numeric[]; + output numeric; BEGIN EXECUTE 'WITH a AS('||query||') SELECT array_agg(the_geom), array_agg(attrib) FROM a' INTO gs, vs; - RETURN QUERY SELECT CDB_SpatialInterpolation(gs, vs, point, method, p1,p2) FROM a; + SELECT CDB_SpatialInterpolation(gs, vs, point, method, p1,p2) INTO output FROM a; + + RETURN output; END; $$ language plpgsql IMMUTABLE; From 6f72075999b3d3887018d9574e4e25abd5214873 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Wed, 22 Jun 2016 16:50:10 -0400 Subject: [PATCH 10/13] altering test outputs for less formatting --- src/pg/test/expected/08_interpolation_test.out | 6 ++---- src/pg/test/sql/08_interpolation_test.sql | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pg/test/expected/08_interpolation_test.out b/src/pg/test/expected/08_interpolation_test.out index 42d24cb..b927f63 100644 --- a/src/pg/test/expected/08_interpolation_test.out +++ b/src/pg/test/expected/08_interpolation_test.out @@ -1,4 +1,2 @@ - cdb_spatialinterpolation --------------------------- - 780.79470198683925288365 -(1 row) +cdb_spatialinterpolation +t diff --git a/src/pg/test/sql/08_interpolation_test.sql b/src/pg/test/sql/08_interpolation_test.sql index c8db89d..43e7ee9 100644 --- a/src/pg/test/sql/08_interpolation_test.sql +++ b/src/pg/test/sql/08_interpolation_test.sql @@ -1,6 +1,9 @@ +\pset format unaligned +\set ECHO all + WITH a AS ( SELECT ARRAY[800, 700, 600, 500, 400, 300, 200, 100] AS vals, ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS g ) -SELECT CDB_SpatialInterpolation(g, vals, ST_GeomFromText('POINT(2.154 41.37)'),1) FROM a; +SELECT (cdb_crankshaft.CDB_SpatialInterpolation(g, vals, ST_GeomFromText('POINT(2.154 41.37)'), 1) - 780.79470198683925288365) / 780.79470198683925288365 < 0.001 FROM a; From 6a9045ba62551e4db3637ad99acad52d591092bd Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Wed, 22 Jun 2016 16:56:35 -0400 Subject: [PATCH 11/13] updating test outputs --- src/pg/test/expected/08_interpolation_test.out | 8 ++++++++ src/pg/test/sql/08_interpolation_test.sql | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pg/test/expected/08_interpolation_test.out b/src/pg/test/expected/08_interpolation_test.out index b927f63..49566db 100644 --- a/src/pg/test/expected/08_interpolation_test.out +++ b/src/pg/test/expected/08_interpolation_test.out @@ -1,2 +1,10 @@ +\pset format unaligned +\set ECHO all + +WITH a AS ( + SELECT + ARRAY[800, 700, 600, 500, 400, 300, 200, 100] AS vals, + ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS g +) cdb_spatialinterpolation t diff --git a/src/pg/test/sql/08_interpolation_test.sql b/src/pg/test/sql/08_interpolation_test.sql index 43e7ee9..ba8968f 100644 --- a/src/pg/test/sql/08_interpolation_test.sql +++ b/src/pg/test/sql/08_interpolation_test.sql @@ -6,4 +6,4 @@ WITH a AS ( ARRAY[800, 700, 600, 500, 400, 300, 200, 100] AS vals, ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS g ) -SELECT (cdb_crankshaft.CDB_SpatialInterpolation(g, vals, ST_GeomFromText('POINT(2.154 41.37)'), 1) - 780.79470198683925288365) / 780.79470198683925288365 < 0.001 FROM a; +SELECT (cdb_crankshaft.CDB_SpatialInterpolation(g, vals, ST_GeomFromText('POINT(2.154 41.37)'), 1) - 780.79470198683925288365) / 780.79470198683925288365 < 0.001 As cdb_spatialinterpolation FROM a; From 3f210c2a71b02b5b8b6a527b79514a9c19260ce3 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Wed, 22 Jun 2016 17:08:50 -0400 Subject: [PATCH 12/13] reducing amt of text in outputs --- src/pg/test/expected/08_interpolation_test.out | 10 ++-------- src/pg/test/sql/08_interpolation_test.sql | 3 ++- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pg/test/expected/08_interpolation_test.out b/src/pg/test/expected/08_interpolation_test.out index 49566db..bb8c73e 100644 --- a/src/pg/test/expected/08_interpolation_test.out +++ b/src/pg/test/expected/08_interpolation_test.out @@ -1,10 +1,4 @@ -\pset format unaligned -\set ECHO all - -WITH a AS ( - SELECT - ARRAY[800, 700, 600, 500, 400, 300, 200, 100] AS vals, - ARRAY[ST_GeomFromText('POINT(2.1744 41.403)'),ST_GeomFromText('POINT(2.1228 41.380)'),ST_GeomFromText('POINT(2.1511 41.374)'),ST_GeomFromText('POINT(2.1528 41.413)'),ST_GeomFromText('POINT(2.165 41.391)'),ST_GeomFromText('POINT(2.1498 41.371)'),ST_GeomFromText('POINT(2.1533 41.368)'),ST_GeomFromText('POINT(2.131386 41.41399)')] AS g -) +SET client_min_messages TO WARNING; +\set ECHO none cdb_spatialinterpolation t diff --git a/src/pg/test/sql/08_interpolation_test.sql b/src/pg/test/sql/08_interpolation_test.sql index ba8968f..bd9c729 100644 --- a/src/pg/test/sql/08_interpolation_test.sql +++ b/src/pg/test/sql/08_interpolation_test.sql @@ -1,5 +1,6 @@ +SET client_min_messages TO WARNING; +\set ECHO none \pset format unaligned -\set ECHO all WITH a AS ( SELECT From 2fa087bb62544cda84931f8c39233074572c9564 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Wed, 22 Jun 2016 17:11:51 -0400 Subject: [PATCH 13/13] adding row info :/ --- src/pg/test/expected/08_interpolation_test.out | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pg/test/expected/08_interpolation_test.out b/src/pg/test/expected/08_interpolation_test.out index bb8c73e..635ca2a 100644 --- a/src/pg/test/expected/08_interpolation_test.out +++ b/src/pg/test/expected/08_interpolation_test.out @@ -2,3 +2,4 @@ SET client_min_messages TO WARNING; \set ECHO none cdb_spatialinterpolation t +(1 row)