ThinkGeo.com    |     Documentation    |     Premium Support

V14.3.0 - ESRI FileGeoDatabase - Exception when Shape is Zero

ThinkGeo Team,

An exception occurs if Shape Length and/or Area is zero. To get around it I’ve implemented try/catch.

Discovered a second exception which is also noted below.

Same code & data runs under V12.1.0 without issue.

Thanks,
Dennis

Code leading to the exception:
if (TheFeature.IsGeometryValid() == false)

2025-03-13 14:04:15,444 ERROR OriStarFileDatabaseViewer - OriStarFileDatabaseViewer->DatabaseTableFeatureData.LoadDatabaseTableFeatureDataCollection:
Feature IsGeometryValid=False
TableName=AIRPORT_GRASS, Id=440

2025-03-13 14:05:02,764 ERROR OriStarFileDatabaseViewer - OriStarFileDatabaseViewer->DatabaseTableFeatureData.LoadDatabaseTableFeatureDataCollection:
Unable to IsGeometryValid
TableName=AIRPORT_GRASS, Id=454
Source=ThinkGeo.Core
TargetSite=ThinkGeo.Core.BaseShape GetShapeCore()
StackTrace=   at ThinkGeo.Core.Feature.GetShapeCore()
   at ThinkGeo.Core.ShapeConverter.FRw=(Byte[] wkb)
   at ThinkGeo.Core.Feature.IsGeometryValid()
   at OriStarFileDatabaseViewer.DatabaseTableFeatureData.LoadDatabaseTableFeatureDataCollection(clsDatabaseTableItem& oDatabaseTableItem) in C:\OriStarMappingIncThinkGeoUI-V14.3.0Secondary\OriStarFileDatabaseViewer\cfDatabaseTableFeatureData.cs:line 337
Message=Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at ThinkGeo.Core.Feature.GetShapeCore()
   at ThinkGeo.Core.ShapeConverter.FRw=(Byte[] wkb)
   at ThinkGeo.Core.Feature.IsGeometryValid()
   at OriStarFileDatabaseViewer.DatabaseTableFeatureData.LoadDatabaseTableFeatureDataCollection(clsDatabaseTableItem& oDatabaseTableItem) in C:\OriStarMappingIncThinkGeoUI-V14.3.0Secondary\OriStarFileDatabaseViewer\cfDatabaseTableFeatureData.cs:line 337



2025-03-13 15:18:19,853 ERROR OriStarFileDatabaseViewer - OriStarFileDatabaseViewer->DatabaseTableFeatureData.LoadDatabaseTableFeatureDataCollection:
Unable to IsGeometryValid
TableName=AIRPORT_GRASS, Id=1258
Source=ThinkGeo.Core
TargetSite=Void CheckShapeIsValid(ThinkGeo.Core.BaseShape, System.String)
StackTrace=   at ThinkGeo.Core.ValidatorHelper.CheckShapeIsValid(BaseShape shape, String parameterName)
   at ThinkGeo.Core.ShapeConverter.FRw=(Byte[] wkb)
   at ThinkGeo.Core.Feature.IsGeometryValid()
   at OriStarFileDatabaseViewer.DatabaseTableFeatureData.LoadDatabaseTableFeatureDataCollection(clsDatabaseTableItem& oDatabaseTableItem) in C:\OriStarMappingIncThinkGeoUI-V14.3.0Secondary\OriStarFileDatabaseViewer\cfDatabaseTableFeatureData.cs:line 337
Message=The shape you provided does not pass our simple validation.This ring is not closed.  To close a ring the last point must be the same as the first point.  All rings must have at least four points. (Parameter 'wkb')
System.ArgumentException: The shape you provided does not pass our simple validation.This ring is not closed.  To close a ring the last point must be the same as the first point.  All rings must have at least four points. (Parameter 'wkb')
   at ThinkGeo.Core.ValidatorHelper.CheckShapeIsValid(BaseShape shape, String parameterName)
   at ThinkGeo.Core.ShapeConverter.FRw=(Byte[] wkb)
   at ThinkGeo.Core.Feature.IsGeometryValid()
   at OriStarFileDatabaseViewer.DatabaseTableFeatureData.LoadDatabaseTableFeatureDataCollection(clsDatabaseTableItem& oDatabaseTableItem) in C:\OriStarMappingIncThinkGeoUI-V14.3.0Secondary\OriStarFileDatabaseViewer\cfDatabaseTableFeatureData.cs:line 337

Hi Dennis,

After reviewing the case with more test data, I think it makes more sense to treat an empty feature (a polygon with 0 rings, a ring with 0 vertices, etc) as a valid feature. We updated the code in the latest beta099 so it will not throw the exceptions anymore. Please pull and have a try.

Thanks,
Ben