[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] mixed geometry types
From:       Willy-Bas Loos <willybas () gmail ! com>
Date:       2013-01-30 8:52:51
Message-ID: CAHnozTgSJF2TSAAPB5u-BfRbJk7bj05Xbw-w9Nn=Es2zgNm+Dg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@lists.osgeo.org [
> postgis-users-bounces@lists.osgeo.org] on behalf of William Kyngesburye [
> woklist@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@lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users@lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>



-- 
"Quality comes from focus and clarity of purpose" -- Mark Shuttleworth

[Attachment #5 (text/html)]

<div dir="ltr"><div><div>How about using a trigger that does:<br></div>If \
st_geometrytype(new.geom)=&#39;ST_Polygon&#39; <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">&lt;<a href="mailto:svm@clevelandmetroparks.com" \
target="_blank">svm@clevelandmetroparks.com</a>&gt;</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&#39;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&#39;ve had some great success with views that \
aggregate to heterogeneous geometry combinations with GeoServer, since GeoTools/the \
SLDs don&#39;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&#39;t say I&#39;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&#39;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) = &#39;LINESTRING&#39;::text OR wkb_geometry IS NULL<br>
<br>
I assume I can just change that to:<br>
<br>
geometrytype(wkb_geometry) = &#39;MULTILINESTRING&#39;::text OR \
geometrytype(wkb_geometry) = &#39;LINESTRING&#39;::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 &lt;kyngchaos*at*kyngchaos*dot*com&gt;<br>
<a href="http://www.kyngchaos.com/" target="_blank">http://www.kyngchaos.com/</a><br>
<br>
&quot;Time is an illusion - lunchtime doubly so.&quot;<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>&quot;Quality comes \
from focus and clarity of purpose&quot; -- Mark Shuttleworth<br> </div>



_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic