.Net Is Feature Class Z and M Enabled?

1032
2
11-09-2011 08:42 AM
RichardFairhurst
MVP Honored Contributor
I need to be able to determine the same information that is made visible when a user opens the property window of a Feature Class.  The property windows knows whether to add Z and/or M properties to the tabs and pages if those options are enabled.  This works on a Feature Class with no features, so it has to be something that can be tracked from the feature class and its spatial reference.

I have used the IGeodataset interface to get access to the Feature Class spatial reference, but I do not know how to use that information to determine if Z and M options have been enabled.  The HasZPrecision and HasMPrecision seem to only return false for my data if both Z and M options are disabled.  If either is enabled, I seem to get true for both, even if one is disabled.  This may be due to the way the data was created intially, but I am not sure.  Nonetheless the properties for the feature classes I have tested correctly show only the properties for the option that is actually enabled.

Any ideas how to figure this out without having a feature of the feature class to query?  Basically how does the Feature Class property window know which checkbox was checked on the General tab concerning Z and M when there are no features in the Feature Class to query.  Thanks.
0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
The spatial reference of a feature class is not related to whether or not it has M or Z values.  M and Z values are part of the geometry definition for the class.  To determine if a feature class is M or Z enabled, you need to get the geometry definition (IGeometryDef) from its Shape field and check the HasM and HasZ properties.

Dim shapeFieldIndex As Int32 = featureClass.Fields.FindField(featureClass.ShapeFieldName)
Dim shapeField As IField = featureClass.Fields.Field(shapeFieldIndex)
Dim geometryDef As IGeometryDef = shapeField.GeometryDef
Dim isMAware As Boolean = geometryDef.HasM
Dim isZAware As Boolean = geometryDef.HasZ
0 Kudos
RichardFairhurst
MVP Honored Contributor
Thanks Neil.  Exactly what I was looking for.  I was unaware of those interfaces and properties.

All help searches I did hate specifying a single letter like Z or M as a search criteria (it either removed the letter from the criteria returned or any text with a Z or an M in it anywhere seems to come back).  HasZ would have worked, but it didn't occur to me that is what it would be named (quite a logical name though now that I know about it).  Thanks again.
0 Kudos