YasinOmer / ziggis

Automatically exported from code.google.com/p/ziggis
1 stars 2 forks source link

Many data types in PostGis cause ZigGis (and ArcMap) crash #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
There are many data types from Postgre that cause a ZigGis (and ArcMap)
fatal crash when we try to identify feature or symbolize feature by attribute.
Until we don't solve this bug, the user can create a view casting the letal
datatypes with legal (in the GDB view) datatypes.

Original issue reported on code.google.com by pco...@gmail.com on 19 Dec 2006 at 3:03

GoogleCodeExporter commented 8 years ago
Could you give a list of data types causing problems?
Thanks
Bruce Rindahl

Original comment by bruce.ri...@gmail.com on 20 Dec 2006 at 9:31

GoogleCodeExporter commented 8 years ago
Until now I discovered the following 2 datatypes are tedious for ArcMap

PostGis NUMERIC values, that I assume should be translated as 
esriFieldTypeDouble in
AO, are not showed neither in Identify and in Table View of ArcMap

PostGis INT8 values, that I assume should be translated as esriFieldTypeInteger 
in
AO, cause ArcMap to crash.

The code that is reading the attribute for the feature seems working:

m_featClass = postGisFeatureClass;
                m_values = new object[Fields.FieldCount];

                // Load the record.
                object o;
                string name;
                string idFld = PostGisConstants.idField.ToLower();
                string geomFld =
postGisFeatureClass.postGisLayer.geometryField.ToLower();
                for (int i = 0; i < dataRecord.FieldCount; i++)
                {
                    // Do some book keeping.
                    o = dataRecord[i];
                    name = dataRecord.GetName(i).ToLower();

                    if (o == DBNull.Value) continue;

                    // *--- Handle special fields ---*

                    // Load the Id.
                    if (name == idFld)
                        m_oid = (int)o;

                    // Load the geometry.
                    else if (name == geomFld)
                    {
                        WkbParser parser = new WkbParser();
                        m_geom = parser.parseWkb((byte[])o);
                        o = Shape;
                    }

                    // *-----------------------------*

                    m_values[i] = o;
                }

But when the attributes are read ArcMap goes in troubles...

m_values is an object array, maybe I will try to make some explicit cast to see 
if
the issue is solved.

Original comment by pco...@gmail.com on 2 Jan 2007 at 9:40

GoogleCodeExporter commented 8 years ago
This was solved with the following explicit cast in the get_Value at 
PostGisFeature:

public object get_Value(int Index)
        {
            //log.enterFunc("get_Value");
            //if (log.IsDebugEnabled) log.Debug(Index);

            object retVal = null;
            try
            {
                Helper.checkWithinBounds(Index, postGisFeatureClass.Fields.FieldCount);
                retVal = values[Index];
                //explicit cast for esriFieldTypeDouble and esriFieldTypeInteger (if
not doing so ArcMap won't show or will crash)
                if (postGisFeatureClass.Fields.get_Field(Index).Type ==
esriFieldType.esriFieldTypeDouble)
                {
                    retVal = (object)double.Parse(retVal.ToString());
                }
                if (postGisFeatureClass.Fields.get_Field(Index).Type ==
esriFieldType.esriFieldTypeInteger)
                {
                    retVal = (object)int.Parse(retVal.ToString());
                }
            }
            finally
            {
                //log.leaveFunc();
            }
            return retVal;
        }

Original comment by pco...@gmail.com on 2 Jan 2007 at 3:34