From: Sandro Santilli Date: Wed, 28 Mar 2012 11:36:52 +0000 (+0000) Subject: Fix GetGopoGeomElementArray code (#1730) X-Git-Tag: 2.0.0rc1~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2f7b6b6020a854ba7beb51dc616eb9b72d09c0c;p=postgis Fix GetGopoGeomElementArray code (#1730) Includes regression testing for both GetGopoGeomElements and GetGopoGeomElementArray git-svn-id: http://svn.osgeo.org/postgis/trunk@9568 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/test/Makefile b/topology/test/Makefile index b679a7e7c..bc143f385 100644 --- a/topology/test/Makefile +++ b/topology/test/Makefile @@ -60,6 +60,7 @@ TESTS = regress/legacy_validate.sql regress/legacy_predicate.sql \ regress/getedgebypoint.sql \ regress/getfacebypoint.sql \ regress/getringedges.sql \ + regress/gettopogeomelements.sql \ regress/layertrigger.sql check: topo_predicates.sql load_topology.sql load_topology-4326.sql diff --git a/topology/test/regress/gettopogeomelements.sql b/topology/test/regress/gettopogeomelements.sql new file mode 100644 index 000000000..e03648d90 --- /dev/null +++ b/topology/test/regress/gettopogeomelements.sql @@ -0,0 +1,22 @@ +set client_min_messages to WARNING; + +\i load_topology.sql +\i load_features.sql + +SELECT lid, tid, GetTopoGeomElements('city_data', lid, tid) +FROM ( + SELECT DISTINCT layer_id as lid, topogeo_id as tid + FROM city_data.relation +) as f +order by 1, 2, 3; + +SELECT lid, tid, 'ARY', GetTopoGeomElementArray('city_data', lid, tid) +FROM ( + SELECT DISTINCT layer_id as lid, topogeo_id as tid + FROM city_data.relation +) as f +order by 1, 2; + +-- clean up +SELECT topology.DropTopology('city_data'); +DROP SCHEMA features CASCADE; diff --git a/topology/test/regress/gettopogeomelements_expected b/topology/test/regress/gettopogeomelements_expected new file mode 100644 index 000000000..4ec0a68f0 --- /dev/null +++ b/topology/test/regress/gettopogeomelements_expected @@ -0,0 +1,43 @@ +BEGIN +t +9 +22 +26 +COMMIT +BEGIN +1 +2 +3 +COMMIT +1|1|{3,3} +1|1|{6,3} +1|2|{4,3} +1|2|{7,3} +1|3|{5,3} +1|3|{8,3} +1|4|{2,3} +1|5|{1,3} +2|1|{14,1} +2|2|{13,1} +2|3|{6,1} +2|4|{4,1} +3|1|{9,2} +3|1|{10,2} +3|2|{4,2} +3|2|{5,2} +3|3|{25,2} +3|4|{3,2} +1|1|ARY|{{3,3},{6,3}} +1|2|ARY|{{4,3},{7,3}} +1|3|ARY|{{5,3},{8,3}} +1|4|ARY|{{2,3}} +1|5|ARY|{{1,3}} +2|1|ARY|{{14,1}} +2|2|ARY|{{13,1}} +2|3|ARY|{{6,1}} +2|4|ARY|{{4,1}} +3|1|ARY|{{9,2},{10,2}} +3|2|ARY|{{4,2},{5,2}} +3|3|ARY|{{25,2}} +3|4|ARY|{{3,2}} +Topology 'city_data' dropped diff --git a/topology/topology.sql.in.c b/topology/topology.sql.in.c index 25f9a06b3..3f217b0be 100644 --- a/topology/topology.sql.in.c +++ b/topology/topology.sql.in.c @@ -1025,11 +1025,15 @@ BEGIN query = 'SELECT * FROM topology.GetTopoGeomElements(' || quote_literal(toponame) || ',' - || quote_literal(layerid) || ',' + || quote_literal(layer_id) || ',' || quote_literal(tgid) || ') as obj ORDER BY obj'; - RAISE NOTICE 'Query: %', query; +#ifdef POSTGIS_TOPOLOGY_DEBUG + RAISE DEBUG 'Query: %', query; +#endif + + -- TODO: why not using array_agg here ? i = 1; FOR rec IN EXECUTE query