<div dir="ltr"><div><div>How about using a trigger that does:<br></div>If st_geometrytype(new.geom)='ST_Polygon' <br>then new.geom=st_multi(geom)<br></div>end if;<br><div><br></div><div>That is the way esri shapefiles do it, they do not distinguish between simple polygons or multipolygons.<br>
<br></div><div>HTH<br><br></div><div>WBL<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 29, 2013 at 7:02 AM, Stephen V. Mather <span dir="ltr"><<a href="mailto:svm@clevelandmetroparks.com" target="_blank">svm@clevelandmetroparks.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi William,<br>
       Thanks for your Mac binaries.  I've used them for years.<br>
       You can definitely mix geometry types.  PostGIS in Action has a great section on homogenous vs. heterogeneous vs. inheritance as the model for structuring geo-data, with an overview of the advantages and disadvantages.  If memory serves me, the primary disadvantage of heterogeneous data is how it is handled by software accessing the database.  We've had some great success with views that aggregate to heterogeneous geometry combinations with GeoServer, since GeoTools/the SLDs don't care (for good or for bad) what the underlying data type are for display, and then we can create a single layer that is multilines and polygons, and thus have a single legend representing a single layer with a variety of different hydro features, linear and areal.  Pretty nifty affect, really (although can be achieved with layer groups in GeoServer as well, I think).  Desktop applications, such as QGIS and others can be a bit more fussy about unconstrained data (or at least data that are mixe<br>

 d).<br>
<br>
As to how it shows up in the geometry_columns view... I can't say I've looked... (finally upgrading our production 1.3.x instance to 2.0.1 this week).<br>
<br>
Best,<br>
Steve<br>
<br>
  Stephen V. Mather<br>
GIS Manager<br>
<a href="tel:%28216%29%20635-3243" value="+12166353243">(216) 635-3243</a> (Work)<br>
<a href="http://clevelandmetroparks.com" target="_blank">clevelandmetroparks.com</a><br>
<br>
<br>
________________________________________<br>
From: <a href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a> [<a href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a>] on behalf of William Kyngesburye [<a href="mailto:woklist@kyngchaos.com">woklist@kyngchaos.com</a>]<br>

Sent: Monday, January 28, 2013 6:59 PM<br>
To: PostGIS Users Discussion<br>
Subject: [postgis-users] mixed geometry types<br>
<div class="HOEnZb"><div class="h5"><br>
Is it OK to change a constraint to allow multiple geometry types in a table?  I'm getting tired or worrying whether I can use a linestring and explode multilinestrings to match, or I need to use a multilinestring and force all imported lines to multi.  Similar for polygon/multipolygon.<br>

<br>
A typical constraint I get when importing a new table with GDAL is:<br>
<br>
geometrytype(wkb_geometry) = 'LINESTRING'::text OR wkb_geometry IS NULL<br>
<br>
I assume I can just change that to:<br>
<br>
geometrytype(wkb_geometry) = 'MULTILINESTRING'::text OR geometrytype(wkb_geometry) = 'LINESTRING'::text OR wkb_geometry IS NULL<br>
<br>
How does PostGIS 2 determine what geometry type a table is for the geometry_columns view?  the first item in the constraint?<br>
<br>
-----<br>
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com><br>
<a href="http://www.kyngchaos.com/" target="_blank">http://www.kyngchaos.com/</a><br>
<br>
"Time is an illusion - lunchtime doubly so."<br>
<br>
- Ford Prefect<br>
<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>"Quality comes from focus and clarity of purpose" -- Mark Shuttleworth<br>
</div>