[fdo-internals] RE: [fdo-users] AutoCAD Map3D and Oracle FDO Issues

Mike Toews mwtoews at sfu.ca
Fri Jun 12 17:15:39 EDT 2009


Hi Orest,

Orest Halustchak wrote:
> Hi Mike,
>
> I'd like to clarify what issues are happening here.
>
> 1. Both Oracle and PostGIS are mentioned. Is the problem the same with both of these or are we talking about different problems?
>   
I've only been dealing with PostGIS for the past year. My experience 
with Oracle was too brief, and was before any attempts to integrate with 
FDO.

Here is an example PostGIS schema, explanation of behaviour, and workaround:

CREATE TABLE myfeaturetable
(
  gid serial NOT NULL,
  geometry geometry, -- select 
addgeometrycolumn('','myfeaturetable','geometry',26910,'MULTIPOLYGON',2)
  CONSTRAINT myfeaturetable_pkey PRIMARY KEY (gid),
  CONSTRAINT enforce_dims_geometry CHECK (ndims(geometry) = 2),
  CONSTRAINT enforce_geotype_geometry CHECK (geometrytype(geometry) = 
'MULTIPOLYGON'::text OR geometry IS NULL),
  CONSTRAINT enforce_srid_geometry CHECK (srid(geometry) = 26910)
)
WITH (OIDS=FALSE);

INSERT INTO geometry_columns(f_table_catalog, f_table_schema, 
f_table_name, f_geometry_column, coord_dimension, srid, "type")
VALUES ('', 'public', 'myfeaturetable', 'geometry', 2, 26910, 
'MULTIPOLYGON');


Connecting this geometry feature to Map3D 2008/2010, and inserting a 
simple 1-piece closed polyline triggered the enforce_geotype_geometry 
check error, and it wasn't inserted. Here are the error messages from 
AutoCAD Map3D 2010 using the second method described below in question #4:
<Error code="200" type="5" dispensation="1" sId="2" 
occurrence="1">Feature was not saved in the target feature source.
<Parameters>
  <Parameter classId="0" position="0">
  <Message>2=The execution of SQL statement failed with PostgreSQL error 
code: PGRES_FATAL_ERROR, ERROR: new row for relation "myfeaturetable" 
violates check constraint "enforce_geotype_geometry" .</Message>
  <SQL />
  </Parameter>
  <Parameter classId="0" position="0">
  <Message>1=Failed to execute Fdo command.</Message>
  <SQL />
  </Parameter>
  <Parameter classId="0" position="0">
  <Message>Failed to insert feature.</Message>
  <SQL />
  </Parameter>
  <Parameter classId="0" position="0">
  <Message>FdoPostGIS:myfeaturetable (), Rev# <0></Message>
  <SQL />
  </Parameter>
</Parameters>
<Entry code="1" type="15" sId="3" occurrence="1">Failed to save some 
features.</Entry>
<Entry code="1" type="15" sId="4" occurrence="1">Failed to save edit 
set.</Entry>

I quickly discovered that Map3D was sending a geometry with type 
'POLYGON'. I've seen the same behaviour in Map3D 2008 and 2010 with 
MULTIPOLYGON and MULTILINE geometry types (I'll also assume MULTIPOINT 
features, but I don't use these).

So my workaround solution in detail is a trigger function. This is used 
on several tables with MULTI-geometries as a BEFORE UPDATE OR INSERT 
trigger.

CREATE OR REPLACE FUNCTION make_multifeature_fn()
  RETURNS trigger AS
$BODY$BEGIN
  IF ST_GeometryType(NEW.geometry) IN('POLYGON','LINESTRING','POINT') THEN
    NEW.geometry := ST_Multi(NEW.geometry);
  END IF;
  RETURN NEW;
END;$BODY$ LANGUAGE 'plpgsql' IMMUTABLE COST 100;

CREATE TRIGGER myfeaturetable_multipolygon_tg
  BEFORE INSERT OR UPDATE
  ON myfeaturetable
  FOR EACH ROW
  EXECUTE PROCEDURE make_multifeature_fn();

Things have been smooth sailing since, and is seamless from the AutoCAD 
side.

> 2. So, you have a geometry that is defined as just Multi-Polygon. If Oracle, how did you define it as just multi-polygon? What does your schema look like.
>   
I don't have access to Oracle at the moment, so I can't comment.
> 3. In PostGIS, you used MULTIGEOMETRY when you added the geometry column?
>   
Yes, using the built-in 'SELECT AddGeometryColumn()' function, which 
adds the data constraints and the metadata to geometry_columns.
> 4. In Map3D's display manager, when you ask to create a new feature, which geometry type options does it show?
>   
After connecting and right-clicking the data manager, here is the menu 
and submenu:

Create:
- Create new Polygon myfeaturetable
- Create new MultiPolygon myfeaturetable

The other method to insert is described to me by a CAD technician across 
the desk from me:

   1. Draw a Polyline, and ensure that it is closed
   2. Right-click the layer and choose 'Create new feature from geometry'
   3. Click the closed polyline(s) then enter
   4. After this, a table is displayed where any other metadata can be
      filled out for the features
   5. Check-in features

With this method, it is ambiguous if the closed polyline is singlepart 
or multipart.
> 5. You mentioned arcs. Is this a separate issue that you are having? As Dan mentioned, Oracle doesn't support arcs in geometry that is lat/long.
>   
I'm only dealing with simple straight-line features. Some are stored in 
EPSG:4326 (lat/long), and other are stored as projected UTM coordinates.

Let me know if any more details are needed. Thanks for looking into this.

-Mike
> Thanks,
> Orest.
>
> -----Original Message-----
> From: fdo-users-bounces at lists.osgeo.org [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Mike Toews
> Sent: Friday, June 12, 2009 2:21 PM
> To: FDO Users Mail List; FDO Internals Mail List
> Subject: Re: [fdo-users] AutoCAD Map3D and Oracle FDO Issues
>
> This issue requires a database-end workaround, which varies depending on 
> DB software.
>
> That said, who is at fault? Is it an issue with AutoCAD Map3D or FDO? If 
> it is an AutoCAD issue, should FDO be responsible for inserting/updating 
> the same geometry type as the feature source? Is AutoCAD intentionally 
> mixing single and mixed geometries, and is this allowed among some or 
> all providers? I never bothered submitting at ticket on this issue since 
> I wasn't sure what exactly the issue was and who to blame.
>
> -Mike
>
> Martin Morrison wrote:
>   
>> It's not an AutoCAD/FDO function, it's an Oracle database function.  Read up on the triggers in the Oracle docs.
>>
>> Martin
>>
>> -----Original Message-----
>> From: fdo-users-bounces at lists.osgeo.org [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Tony
>> Sent: Friday, June 12, 2009 1:59 AM
>> To: fdo-users at lists.osgeo.org
>> Subject: Re: [fdo-users] AutoCAD Map3D and Oracle FDO Issues
>>
>>
>> Mike 
>> thanks in millions for answer. could you tell me how to implement the
>> trigger from autocad insert. 
>> i am new to autocad . 
>>
>> thanks
>> tony
>>
>>
>> Mike Toews wrote:
>>   
>>     
>>> Tony,
>>>
>>> I think I had a similar problem, although I'm using Map3D 2008/2010 with 
>>> a PostgreSQL/PostGIS database. The issue was Map3D was creating and 
>>> sending a [single] POLYGON object to a MULTIPOLYGON column, which it 
>>> shouldn't, since the column has check constraints to ensure they are all 
>>> MULTIPOLYGON geometries. I fixed it by writing a simple BEFORE INSERT OR 
>>> UPDATE trigger to check and correct if the polygon is a multi object.
>>>
>>> I'm no pro with Oracle spatial, but the guts of my PL/pgSQL (with 
>>> PostGIS) trigger function look somthing like this:
>>>
>>>   IF ST_GeometryType(NEW.geometry) IN('POLYGON','LINESTRING') THEN
>>>     NEW.geometry := ST_Multi(NEW.geometry);
>>>   END IF;
>>>
>>> I think most of this is portable to your situation, except that 
>>> ST_GeometryType() returns different values. I'm not sure if there is a 
>>> generic ST_Multi() function, but there are similar casts that you can use.
>>>
>>> Hope this helps,
>>>
>>> -Mike
>>>
>>> Tony wrote:
>>>     
>>>       
>>>> i am using fdo (autodesk) as well as used king fdo for getting the CAD
>>>> data
>>>> write to oracle.   
>>>> here is the whole story : i have a polygon shape file i have used FDO2FDO
>>>> to
>>>> create  oracle table , I want to edit some of geometries in AutoCADmap 3D
>>>> as
>>>> well as i want to add new polygons there. 
>>>>
>>>> the issue:  i have createa a closed polygon in autocadmap that have Arc
>>>> and
>>>> line and i was trying to write this to the above created table.  i am
>>>> getting error saying  that geometry type does not match, 
>>>> after reading the logs i found out that though my Oracle table has
>>>> mpolygon
>>>> geometry type i can not write  and polygon with Arc(true arc) in it. 
>>>>
>>>> any idea how to solve this issue. i have wote to autodesk and still
>>>> wating
>>>> to get the answer. i wrote to  king fdo no reply yet ... 
>>>>
>>>> please let me know how to solve this 
>>>>
>>>>
>>>>   
>>>>       
>>>>         
>>> _______________________________________________
>>> fdo-users mailing list
>>> fdo-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/fdo-users
>>>
>>>
>>>     
>>>       
>>   
>>     
>
> _______________________________________________
> fdo-users mailing list
> fdo-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-users
> _______________________________________________
> fdo-internals mailing list
> fdo-internals at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-internals
>   



More information about the fdo-internals mailing list