lundi 23 février 2015

How to reproduce FME Change Detector results in PostGIS?


we would like to use the function change detector from FME in PostGIS.


image from FME Transformers Guide


We had a try with the following SQL-Statements but the function doesn´t work. There are no results in the end. The single querys for added/deleted/unchanged are working but the problem with the function we´ve got are the two loaded layers. So does anybody now if there is a possibility to create an change detector function in PostGis? The result should create, depending on the data, one to three new layers (added/deleted/unchanged).



drop table if exists tab_cd_2;
create table tab_cd_2(
gid serial PRIMARY KEY,
nume varchar,
nume1 varchar,
nume2 varchar,
geom geometry(polygon, 32633));


CREATE OR REPLACE FUNCTION cd_3() RETURNS trigger AS

$$ begin

for NEW.nume in select count(landkreise_projected_added.name_3)
From public.landkreise_projected_added
Where not exists (select geom from landkreise_projected_added
where landkreise_projected_added.geom = landkreise_projected_deleted.geom)
loop

select count(landkreise_projected_added.name_3)
into tab_cd_2.nume1
FROM public.landkreise_projected_added
WHERE NOT EXISTS (SELECT geom FROM landkreise_projected_deleted
WHERE landkreise_projected_deleted.geom = landkreise_projected_added.geom);

begin
select count(landkreise_projected_added.name_3)
into tab_cd_2.nume2
FROM public.landkreise_projected_added
WHERE landkreise_projected_added.geom = landkreise_projected_deleted.geom;
end;

end loop;
RETURN tab_cd_2;
END;
$$ LANGUAGE 'plpgsql';

-- Trigger
DROP TRIGGER IF EXISTS fill_sp ON tab_cd_2;
CREATE TRIGGER fill_cd_3
BEFORE INSERT OR UPDATE ON tab_cd_2
FOR EACH row EXECUTE PROCEDURE cd_3();


Thanks for your help!





Aucun commentaire:

Enregistrer un commentaire