From 9e2f2b7c2df11c5aa65edbcaecb20924376775e3 Mon Sep 17 00:00:00 2001 From: Javier Goizueta Date: Fri, 26 Feb 2016 11:55:20 +0100 Subject: [PATCH] Fix the tests for adjacent union function --- .../expected/05_cdb_union_adjacent_test.out | 23 ++++++++++++++++--- .../0.0.1/sql/05_cdb_union_adjacent_test.sql | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pg/test/0.0.1/expected/05_cdb_union_adjacent_test.out b/pg/test/0.0.1/expected/05_cdb_union_adjacent_test.out index 21f7ffd..334c16c 100644 --- a/pg/test/0.0.1/expected/05_cdb_union_adjacent_test.out +++ b/pg/test/0.0.1/expected/05_cdb_union_adjacent_test.out @@ -1,5 +1,22 @@ -st_astext +\i test/fixtures/touching_polygons.sql +-- test table (polygons, some of which touch and some which dont) +CREATE TABLE touching_polygons(cartodb_id integer, the_geom geometry); +INSERT INTO touching_polygons VALUES +(1, ST_GeomFromText('POLYGON ((0 0, 1 0,1 1, 0 1, 0 0 ))')), +(2, ST_GeomFromText('POLYGON ((1 0, 2 0, 2 1, 1 1, 1 0))')), +(1, ST_GeomFromText('POLYGON ((0 1, 1 1,1 2, 0 2, 0 1 ))')), +(4, ST_GeomFromText('POLYGON ((3 0, 4 0, 4 1, 3 1, 3 0))')), +(5, ST_GeomFromText('POLYGON ((3 1, 4 1, 4 2, 3 2, 3 1))')); +WITH joined_polygons AS ( + SELECT cdb_crankshaft.cdb_union_adjacent(the_geom) the_geom FROM touching_polygons +), +unnested_polygons as ( + select unnest(joined_polygons.the_geom) the_geom from joined_polygons +) +select ST_ASTEXT(unnested_polygons.the_geom) from unnested_polygons; + st_astext ------------------------------------------------ -POLYGON((1 0,0 0,0 1,0 2,1 2,1 1,2 1,2 0,1 0)) -POLYGON((4 1,4 0,3 0,3 1,3 2,4 2,4 1)) + POLYGON((1 0,0 0,0 1,0 2,1 2,1 1,2 1,2 0,1 0)) + POLYGON((4 1,4 0,3 0,3 1,3 2,4 2,4 1)) (2 rows) + diff --git a/pg/test/0.0.1/sql/05_cdb_union_adjacent_test.sql b/pg/test/0.0.1/sql/05_cdb_union_adjacent_test.sql index e1adec4..dd51cb6 100644 --- a/pg/test/0.0.1/sql/05_cdb_union_adjacent_test.sql +++ b/pg/test/0.0.1/sql/05_cdb_union_adjacent_test.sql @@ -1,7 +1,7 @@ \i test/fixtures/touching_polygons.sql WITH joined_polygons AS ( - SELECT cdb_union_adjacent(the_geom) the_geom FROM touching_polygons + SELECT cdb_crankshaft.cdb_union_adjacent(the_geom) the_geom FROM touching_polygons ), unnested_polygons as ( select unnest(joined_polygons.the_geom) the_geom from joined_polygons