Hi,<div><br></div><div>By calling <span style="font-family:arial,sans-serif;font-size:12.727272033691406px">AddGeometryColumn('public', profiles_line_wgs84', 'geom', 4326, 'LINESTRING', 2), Postgis 2.0 created a geometry column of type </span><font face="arial, sans-serif">geometry(LineString,4326) that restrict that column to LINESTRINGs only.</font></div>
<div><span style="font-family:arial,sans-serif">The constraint defined later does not change this restriction.</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div>To enable <font face="arial, sans-serif">the older constraint mechanism (and define the geom column type as 'geometry'), call </font><span style="font-family:arial,sans-serif">addGeometryColumn with 'false' as final parameter (</span><font face="arial, sans-serif"><a href="http://postgis.refractions.net/docs/AddGeometryColumn.html">http://postgis.refractions.net/docs/AddGeometryColumn.html</a></font><span style="font-family:arial,sans-serif">).:</span></div>
<div><span style="font-family:arial,sans-serif"><div>SELECT AddGeometryColumn('public', 'profiles_line_wgs84', 'geom', 4326, 'LINESTRING', 2, false);</div><div><br></div><div>By the way, do you really need to store heterogenous geometries ? It may prevent you from using some functions that will not handle both types.</div>
<div>A trigger on the geom column could convert LINESTRINGs to MULTI by calling st_multi. ;)</div><div><br></div><div>Nicolas</div></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif"><br>
</span></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 15 December 2012 12:48, Gery . <span dir="ltr"><<a href="mailto:gamejihou@hotmail.com" target="_blank">gamejihou@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">
<font style="font-size:10pt" color="#366092" face="Arial">Hello,<br><br><font style="font-size:10pt">I recen<font style="font-size:10pt">tly up<font style="font-size:10pt">graded <font style="font-size:10pt">both my postgresql (from 8.4.4 to 9.2</font></font></font></font></font>.2) and postgis (from 1.5.3 to 2.<font style="font-size:10pt">0.2 r1<font style="font-size:10pt">0789). With the <font style="font-size:10pt">previous versions I run th<font style="font-size:10pt"><font style="font-size:10pt">ese</font> commands without problems:<br>
<br><font style="font-size:10pt">[code]<br></font></font></font></font></font>CREATE TABLE profiles_line_wgs84(<br>GID SERIAL,<br>ID SMALLINT,<br>FID SMALLINT,<br>SURVEY VARCHAR(100),<br>PROFILE VARCHAR(100),<br>TYPE VARCHAR(100),<br>
SOURCE VARCHAR(100),<br>NR_TRACES VARCHAR(100),<br>TRACE_SPACE_M VARCHAR(100),<br>LENGTH_M FLOAT,<br>COMMENTS TEXT<br>);<br>SELECT AddGeometryColumn('public', profiles_line_wgs84', 'geom', 4326, 'LINESTRING', 2);<br>
CREATE INDEX profiles_line_wgs84_geom ON profiles_line_wgs84 USING GIST ( geom );<br><br>ALTER TABLE profiles_line_wgs84 DROP CONSTRAINT enforce_geotype_geom;<br>ALTER TABLE profiles_line_wgs84 ADD CONSTRAINT enforce_geotype_geom CHECK ((geometrytype(geom) = ANY (ARRAY['MULTILINESTRING'::text, 'LINESTRING'::text])) OR geom IS NULL);<br>
<font style="font-size:10pt" color="#1F497D" face="Arial"><font style="font-size:10pt">[/code]<br></font><br><font style="font-size:10pt">now <font style="font-size:10pt">wi<font style="font-size:10pt">th postgis 2.0.2</font></font></font> I get these err<font style="font-size:10pt">ors:<br>
<br>[code<font style="font-size:10pt">]<br>CREATE TABLE<br>                             addgeometrycolumn                             <br>---------------------------------------------------------------------------<br> public.seismic_profiles_line_wgs84.geom SRID:4326 TYPE:LINESTRING DIMS:2 <br>
(1 row)<br><br>CREATE INDEX<br>psql:13_seismic_profiles_mergecsvshp2line.sql:119: ERROR:  constraint "enforce_geotype_geom" of relation "profiles_line_wgs84" does not exist<br>psql:13_seismic_profiles_mergecsvshp2line.sql:128: ERROR:  Geometry type (MultiLineString) does not match column type (LineString)</font><br>
</font>[/code]<br><br><font style="font-size:10pt"><font style="font-size:10pt">it see<font style="font-size:10pt">ms  to me that t<font style="font-size:10pt">he constraint statement is ok, or<font style="font-size:10pt"> is it something missing? any idea is appreciated,<br>
<br><font style="font-size:10pt">Thanks in advance<font style="font-size:10pt">,<br><br><font style="font-size:10pt">Best regards,<br><br></font></font></font></font></font></font></font></font></font><font style="font-size:10pt"><font style="font-size:10pt"><font style="font-size:10pt"><font style="font-size:10pt"></font></font></font></font>__________________________________________________________________________________________<br>
Piensa en el medio ambie<font face="Arial">nte - mantenlo en la pantalla. NO lo imprimas si NO es necesario.</font><font style="font-size:10pt" color="#1F497D" face="Arial"><br></font><font style="font-size:10pt" color="#1F497D" face="Arial">Think green - keep it on the screen. Do NOT print if it is NOT necessary.</font><font style="font-size:10pt" color="#1F497D" face="Arial"><br>
</font><font style="font-size:10pt" color="#1F497D" face="Arial"><span lang="de"><span>Denken Sie an</span> <span>die Umwelt</span></span></font><font style="font-size:10pt" color="#1F497D" face="Arial"><span lang="de"><span></span> <span>-</span> <span>bewahren Sie es</span> <span>auf dem Bildschirm.</span> <span>Drucken Sie NICHT</span><span>, wenn</span> <span>es NICHT notwendig ist</span><span>.</span></span></font><br>
                                          </div></div>
<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></blockquote></div><br></div>