Schema
Owner
postgres
Descriptions
args: tg1, tg2 - Returns true if two topogeometries are composed of the same topology primitives.
Options
Option | Value |
---|---|
Returns |
boolean |
Language |
|
Parameters |
tg1 topology.topogeometry tg2 topology.topogeometry |
Definition
CREATE OR REPLACE FUNCTION topology.equals (
tg1 topology.topogeometry,
tg2 topology.topogeometry
)
RETURNS boolean AS
$span$
DECLARE
rec RECORD;
toponame varchar;
query text;
BEGIN
IF tg1.topology_id != tg2.topology_id THEN
-- TODO: revert to ::geometry instead ?
RAISE EXCEPTION 'Cannot compare TopoGeometries from different topologies';
END IF;
-- Not the same type, not equal
IF tg1.type != tg2.type THEN
RETURN FALSE;
END IF;
-- Geometry collection are not currently supported
IF tg2.type = 4 THEN
RAISE EXCEPTION 'GeometryCollection are not supported by equals()';
END IF;
-- Get topology name
SELECT name FROM topology.topology into toponame
WHERE id = tg1.topology_id;
-- Two geometries are equal if they are composed by
-- the same TopoElements
FOR rec IN EXECUTE 'SELECT * FROM '
|| ' topology.GetTopoGeomElements('
|| quote_literal(toponame) || ', '
|| tg1.layer_id || ',' || tg1.id || ') '
|| ' EXCEPT SELECT * FROM '
|| ' topology.GetTopogeomElements('
|| quote_literal(toponame) || ', '
|| tg2.layer_id || ',' || tg2.id || ');'
LOOP
RETURN FALSE;
END LOOP;
FOR rec IN EXECUTE 'SELECT * FROM '
|| ' topology.GetTopoGeomElements('
|| quote_literal(toponame) || ', '
|| tg2.layer_id || ',' || tg2.id || ')'
|| ' EXCEPT SELECT * FROM '
|| ' topology.GetTopogeomElements('
|| quote_literal(toponame) || ', '
|| tg1.layer_id || ',' || tg1.id || '); '
LOOP
RETURN FALSE;
END LOOP;
RETURN TRUE;
END
$span$
LANGUAGE 'plpgsql'
STABLE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER
COST 100;
COMMENT ON FUNCTION topology.equals(tg1 topology.topogeometry, tg2 topology.topogeometry)
IS 'args: tg1, tg2 - Returns true if two topogeometries are composed of the same topology primitives.';
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 07/12/2018 13:23 |