Author: Jonio, Dennis
The next on the list ...
The method signature:
public static sdogeometry SdoGeometryFromDrawAble(List
If you recall the DrawAble holds the dimensionality so the Measure and the SRID had to be injected somewhere.
Frankly the simplest of all the methods. Very straight forward implementaion.
Maybe somewhat unusual here is that I made this a static method within the static utility class.
Source code (C#):
public static sdogeometry SdoGeometryFromDrawAble(List_drawables, int _lrs, int _srid)
{
sdogeometry rtnval = null;
ListTotElms = new List ();
ListTotOrds = new List ();
int CURRENT_OFFSET = 1;
int CountOfItems = _drawables.Count;
int CountOfComponents = 0;
foreach (DrawAble drawable in _drawables)
{
CountOfComponents = drawable.SubComponents.Count;
foreach (DrawAbleSubComponent cmp in drawable.SubComponents)
{
TriInts nxt_elem = null;
//
//Compound components
//
if (cmp.Etype == DrawAbleSubComponentEType.CompoundLine ||
cmp.Etype == DrawAbleSubComponentEType.CompoundSurfaceInnerRingLine ||
cmp.Etype == DrawAbleSubComponentEType.CompoundSurfaceOuterRingLine)
{
TriInts frst_head = new TriInts(CURRENT_OFFSET, BasicETYPE(cmp.Etype), (cmp.Elem.Length / 3) - 1);
TotElms.Add(frst_head);
for (int _k = 3; _k < cmp.Elem.Length; )
{
TriInts nxt = new TriInts(CURRENT_OFFSET + cmp.Elem[_k + 0], cmp.Elem[_k + 1], cmp.Elem[_k + 2]);
TotElms.Add(nxt);
_k = _k + 3;
}
//Copy over the ordinates
for (int _i = 0; _i < cmp.Ords.Length; _i++)
TotOrds.Add(cmp.Ords[_i]);
//We get out of the major loop here ...
//so we MUST set the CURRENT_OFFSET to the end of the ordinates + start point.
CURRENT_OFFSET = CURRENT_OFFSET + cmp.Ords.Length;
continue;
}
//
//Point and PointCluster
//
if (cmp.Etype == DrawAbleSubComponentEType.Point)
{
nxt_elem = new TriInts(CURRENT_OFFSET, BasicETYPE(cmp.Etype), BasicINTERPRETATION(cmp.Etype));
TotElms.Add(nxt_elem);
//Copy over the ordinates
for (int _i = 0; _i < cmp.Ords.Length; _i++)
TotOrds.Add(cmp.Ords[_i]);
CURRENT_OFFSET = CURRENT_OFFSET + cmp.Ords.Length;
continue;
}
else if (cmp.Etype == DrawAbleSubComponentEType.PointCluster)
{
nxt_elem = new TriInts(CURRENT_OFFSET, BasicETYPE(cmp.Etype), cmp.Elem[2]);
TotElms.Add(nxt_elem);
}
//
//Lines
//
if (cmp.Etype == DrawAbleSubComponentEType.SimpleLine ||
cmp.Etype == DrawAbleSubComponentEType.SimpleLineAllCurves)
{
nxt_elem = new TriInts(CURRENT_OFFSET, BasicETYPE(cmp.Etype), BasicINTERPRETATION(cmp.Etype));
TotElms.Add(nxt_elem);
}
//
//Surface Stuff
//
if (cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceInnerRingAllCurves ||
cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceInnerRingCircle ||
cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceInnerRingLine ||
cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceInnerRingRectangle ||
cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceOuterRingAllCurves ||
cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceOuterRingCircle ||
cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceOuterRingLine ||
cmp.Etype == DrawAbleSubComponentEType.SimpleSurfaceOuterRingRectangle
)
{
nxt_elem = new TriInts(CURRENT_OFFSET, BasicETYPE(cmp.Etype), BasicINTERPRETATION(cmp.Etype));
TotElms.Add(nxt_elem);
}
//Copy over the ordinates and move the CURRENT OFFSET
for (int _i = 0; _i < cmp.Ords.Length; _i++)
TotOrds.Add(cmp.Ords[_i]);
CURRENT_OFFSET = TotOrds.Count + 1;
}
}
//
// Now build the geometry object
//
if (TotElms.Count > 0 && TotOrds.Count > 0)
{
DrawAble drawable = _drawables[0];
decimal[] tmp_elems = new decimal[TotElms.Count * 3];
for (int _e = 0; _e < TotElms.Count; _e++)
{
tmp_elems[_e * 3 + 0] = TotElms[_e].OFFSET;
tmp_elems[_e * 3 + 1] = TotElms[_e].ETYPE;
tmp_elems[_e * 3 + 2] = TotElms[_e].INTERP;
}
decimal[] tmp_ords = new decimal[TotOrds.Count];
tmp_ords = TotOrds.ToArray();
rtnval = new sdogeometry();
rtnval.LRS = _lrs;
rtnval.sdo_srid = _srid;
rtnval.Dimensionality = drawable.Dimensionality;
rtnval.ElemArray = tmp_elems;
rtnval.OrdinatesArray = tmp_ords;
rtnval.GeometryType = InferGeometryType(_drawables);
rtnval.PropertiesToGTYPE();
}
return rtnval;
}
No comments:
Post a Comment