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: [email protected] 
[mailto:[email protected]] Im Auftrag von Ben Harper
Gesendet: Donnerstag, 2. Juli 2009 12:47
An: [email protected]
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 [email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to