[postgis-users] Polygon and Multipolygon distinguished by fieldtype constraint - call for a generic AnyPoly type

Suhr, Ralf Ralf.Suhr at itc-halle.de
Thu Jul 2 04:17:01 PDT 2009


You need two things:

1) change the geom constraint

ALTER TABLE YOUR_TABLE DROP CONSTRAINT enforce_geotype_geom;
ALTER TABLE YOUR_TABLE ADD CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) = 'POLYGON'::text OR geometrytype(geom) = 'MULTIPOLYGON'::text OR geom IS NULL);

2) Create a trigger with ST_Multi(NEW.geom) for your table

Be aware, that some functions don't working directly with Multigeometrys.

Ralf

-----Ursprüngliche Nachricht-----
Von: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] Im Auftrag von Ben Harper
Gesendet: Donnerstag, 2. Juli 2009 12:47
An: postgis-users at postgis.refractions.net
Betreff: [postgis-users] Polygon and Multipolygon distinguished by fieldtype constraint - call for a generic AnyPoly type


I am looking for a way of creating a geometry field that has a constrained type identical to the Shapefile spec. Basically, Polygons and MultiPolygons are equals. Linestrings and Multilinestrings are equals. Is there a way to accomplish this with PostGIS? If I make the field Polygon, then I can't insert Multipolygons, and vice versa.

Thanks,
Ben
_______________________________________________
postgis-users mailing list postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list