<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>PostGIS and Map 3D 2010 autoincrement problems</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">Hi List,</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">I have tested AutoCAD Map 3D 2010, FDO PostGIS 3.4, PostGIS 8.2.13</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">with sample data "towns" from</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"></SPAN><A HREF="http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_tut01"><SPAN LANG="de-at"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgis_tut01</FONT></U></SPAN></A><SPAN LANG="de-at"></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">In the testcases the error messages are caused by the constraints (geometrytype, serial Primary Key) on the table "towns" in PostGIS.</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">These constraints will be created by default by an import of data with the tool "shp2pgsql".</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">There is no way to set the splitting rules for "gid" in AutoCAD Map to NULL because there is a "NOT NULL" constraint by the serial primary key property.</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">For all it is important that before importing the shp-files in PostGIS they have to be saved with codeset utf-8 instead of default win1252.</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">With QGIS this is no problem.</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">############ Case 1 #######################</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">if the table "towns" is created like below:</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">CREATE TABLE "towns" (gid serial PRIMARY KEY,........);</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">SELECT AddGeometryColumn('','towns','the_geom','26986','MULTIPOLYGON',2);</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">INSERT INTO "towns" ("objectid",".....</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">I tried to check in 2 Polyons merged with the function "GIS-Object manipulation" "Object merge"</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">i got these message</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">-FdoPostGIS:towns (220), Rev# <-1></FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">-object could not be updatet</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">1=FDO-Command could not be executed.</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">2=The execution of SQL statement failed with PostgreSQL error code: PGRES_FATAL_ERROR, FEHLER: new row for Relation >>towns<< violates Check-Constraint >>enforce_geotype_the_geom<<</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">some objects could not be stored</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">manipulated row could not be stored.</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">ceck in of a splitted polygon causes also an error message</FONT></SPAN>
</P>
<BR>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">############ Case 2 #######################</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">if the table "towns" is created like below:</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">CREATE TABLE "towns" (gid serial PRIMARY KEY,........);</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">SELECT AddGeometryColumn('','towns','the_geom','26986','GEOMETRY',2);</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">INSERT INTO "towns" ("objectid","....</FONT></SPAN>
</P>
<BR>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">check in of merged objects will work</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">check in fo splittet objects caused an error message</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">- FdoPostGIS:towns_serial[],Rev#<0></FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">- object could not be inserted</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">- 1=FDO-command could not be executed</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">- 2=invalid propertyname</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">some objects could not be stored</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">despite of this error message one part of the polygon which was splittet is stored in the postgis with gid = max(gid) + 1 and one part has an updated geometry (with splitting option "use existing ids")</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">in this case manually updating the value of gid is not possible</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">the provider does not evaluate the next possible unique value of gid</FONT></SPAN>
</P>
<BR>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">######## Case 3 #################</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">if the table "towns" is created like below:</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">CREATE TABLE "towns" (gid int4,.....);</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">SELECT AddGeometryColumn('','towns','the_geom','26986','GEOMETRY',2);</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">INSERT INTO "towns" ("objectid","..........</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">UPDATE "public"."towns" set gid = objectid;</FONT></SPAN>
<BR><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">ALTER TABLE "public"."towns" ADD PRIMARY KEY (gid);</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">check in of merged objects will work</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">check in of splittet polygon</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">if you choosed splitting with option use existing ids you have to update the gid for one part of the splitted polygon manually to a unique value</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">if you choosed splitting with option new ids you have to update the gid for all checked out polygons manually to a unique value</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">so before the manipulation you should look for max (gid) by sorting the table</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">For me it would be important, what type of tables in PostGIS have to be created to allow correct gis-object manipulation in AutoCAD Map 3D.</FONT></SPAN></P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">It would be also nice to have a demo data-set in a sample-table to verify the correct installation of the provider.</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">greetings</FONT></SPAN>
</P>
<P><SPAN LANG="de-at"><FONT SIZE=2 FACE="Arial">Karl</FONT></SPAN><SPAN LANG="de"></SPAN>
</P>
</BODY>
</HTML>