[postgis-users] mixed geometry types

Willy-Bas Loos willybas at gmail.com
Wed Jan 30 00:52:51 PST 2013


How about using a trigger that does:
If st_geometrytype(new.geom)='ST_Polygon'
then new.geom=st_multi(geom)
end if;

That is the way esri shapefiles do it, they do not distinguish between
simple polygons or multipolygons.

HTH

WBL


On Tue, Jan 29, 2013 at 7:02 AM, Stephen V. Mather <
svm at clevelandmetroparks.com> wrote:

> Hi William,
>        Thanks for your Mac binaries.  I've used them for years.
>        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
>  d).
>
> 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).
>
> Best,
> Steve
>
>   Stephen V. Mather
> GIS Manager
> (216) 635-3243 (Work)
> clevelandmetroparks.com
>
>
> ________________________________________
> From: postgis-users-bounces at lists.osgeo.org [
> postgis-users-bounces at lists.osgeo.org] on behalf of William Kyngesburye [
> woklist at kyngchaos.com]
> Sent: Monday, January 28, 2013 6:59 PM
> To: PostGIS Users Discussion
> Subject: [postgis-users] mixed geometry types
>
> 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.
>
> A typical constraint I get when importing a new table with GDAL is:
>
> geometrytype(wkb_geometry) = 'LINESTRING'::text OR wkb_geometry IS NULL
>
> I assume I can just change that to:
>
> geometrytype(wkb_geometry) = 'MULTILINESTRING'::text OR
> geometrytype(wkb_geometry) = 'LINESTRING'::text OR wkb_geometry IS NULL
>
> How does PostGIS 2 determine what geometry type a table is for the
> geometry_columns view?  the first item in the constraint?
>
> -----
> William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
> http://www.kyngchaos.com/
>
> "Time is an illusion - lunchtime doubly so."
>
> - Ford Prefect
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>



-- 
"Quality comes from focus and clarity of purpose" -- Mark Shuttleworth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130130/1cc6b2d4/attachment-0001.html>


More information about the postgis-users mailing list