I have been chasing a problem in that I can't retrieve curves from the GDB when using the .NET wrapper.Using Reflector, I finally tracked it down to the Curves Get property not applying the calculated offset during the memcpy:
public byte[] Curves
{
get
{
int numParts = this.NumParts;
int numPoints = this.NumPoints;
Enum modopt(ShapeType) modopt(IsBoxed) shapeType = base.shapeType;
int offset = (((numPoints * 4) + numParts) * 4) + 44;
if (ShapeBuffer.HasZs(shapeType))
{
offset = ((numPoints * 8) + offset) + 16;
}
if (ShapeBuffer.HasMs(shapeType))
{
offset = ((numPoints * 8) + offset) + 16;
}
int allocatedLength = ((int) base.inUseLength) + (-4 - offset);
byte[] result = new byte[allocatedLength];
ref byte modopt(IsExplicitlyDereferenced) pinned pinResult = (ref byte modopt(IsExplicitlyDereferenced)) &(result[0]);
memcpy(pinResult, *(((int*) (base.NativeShapeBuffer + 4))), allocatedLength);
return result;
}
set
{
int numParts = this.NumParts;
int numPoints = this.NumPoints;
Enum modopt(ShapeType) modopt(IsBoxed) shapeType = base.shapeType;
int offset = (((numPoints * 4) + numParts) * 4) + 44;
if (ShapeBuffer.HasZs(shapeType))
{
offset = ((numPoints * 8) + offset) + 16;
}
if (ShapeBuffer.HasMs(shapeType))
{
offset = ((numPoints * 8) + offset) + 16;
}
offset += 4;
int allocatedLength = ((int) base.inUseLength) - offset;
ref byte modopt(IsExplicitlyDereferenced) pinned pinBytes = (ref byte modopt(IsExplicitlyDereferenced)) &(value[0]);
memcpy((*(((int*) (base.NativeShapeBuffer + 4))) + offset), pinBytes, allocatedLength);
}
}
I am using the following work around:
ShapeBuffer shapeBuffer = row.GetGeometry();
byte[] shapeBufferBytes = shapeBuffer.shapeBuffer;
MultiPartShapeBuffer geometry = shapeBuffer;
byte[] curveBuffer = geometry.Curves;
int bytes = curveBuffer.Length;
int offset = ( ( geometry.NumPoints * 4 ) + geometry.NumParts ) * 4 + 44;
if ( ShapeBuffer.HasZs( geometry.shapeType ) )
{
offset += geometry.NumPoints * 8 + 16;
}
if ( ShapeBuffer.HasMs( geometry.shapeType ) )
{
offset += geometry.NumPoints * 8 + 16;
}
for ( int i = 0; i < bytes; i++ )
{
curveBuffer[ i ] = shapeBufferBytes[ i + offset + 4 ];
}
//Messy code copying the byte buffer to an array of structures...