Created
February 10, 2014 11:20
-
-
Save javikalsan/8914210 to your computer and use it in GitHub Desktop.
Trigger for postgis to calculate geometry area on hectares
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT AddGeometryColumn('geoms', 'the_geom', 25830, 'MULTIPOLYGON', 2 ); | |
Trigger sup. ha | |
BEGIN | |
IF (TG_OP = 'INSERT') THEN | |
NEW.supha := area(NEW.the_geom)/10000; | |
ELSIF (TG_OP = 'UPDATE') THEN | |
IF NOT (NEW.the_geom ~= OLD.the_geom) THEN | |
NEW.supha := area(NEW.the_geom)/10000; | |
END IF; | |
END IF; | |
RETURN NEW; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment