Shape(IFeature) and Shape(IGeometry)

Nov 15, 2011 at 7:05 PM

I have discovered a bug in the constructors for Shape from IFeature or IGeometry.  I know how to fix it.  I looked over in FeatureSet.OnInitializeVertices to see how it was handled over there.  Basic problem is that the constructors were assuming that there was a one-to-one correspondance of parts to basic geometries on the IFeature/IGeometry.  In fact, a basic geometry can contain holes along with the shell.  This is handled correctly in OnInitializeVertices.  The central player in all of this is the ShapeRange.  I believe we could do some code reduction if we had a way of constructing a ShapeRange from an IFeature/IGeometry.  Then, we could encapsulate the code that is used in OnInitializeVertices and use the correct code when constructing Shapes from IFeature/IGeometry.  Finally, my question is this:  Would it be OK to add constructors to ShapeRange that would probably have the following signatures:

public ShapeRange(IFeature feature, double[] vertices)

public ShapeRange(IGeometry geometry, double[] vertices)

I ask because we might be wanting to keep the ShapeRange from knowing about IFeature and IGeometry.  If that is the case, I could either put a static method somewhere to create a ShapeRange from a Feature( I guess on the Feature class), or possibly through an extension.  Any thoughts on the best way to go?

Also, the vertices array in the constructors above are not absolutely necessary; we could create the vertices array in the constructor, then get it off one of the parts if needed externally, but I just didn't like the way that feels, although it would result in even more code reduction.



Nov 15, 2011 at 9:06 PM

Never mind. I just added static methods in Shape.cs (where the constructor fixes had to be made) to create ShapeRange from IFeature or IGeometry.  I won't change FeatureSet.OnInitializeVertices.  I don't particularly like it because you would likely never discover those methods in intellisense, but it keeps me from having to change too many files.