Author: Jonio, Dennis
The DrawAbleType enums were easy. I just had to give them values that could be distinguised via “OR”ing them together.
Source code (C#):
public static int InferGeometryType(List_drawables)
{
int rtnval = 0;
if (_drawables.Count == 1)
{
switch (_drawables[0].DrawEtype)
{
case DrawAbleType.Point:
rtnval = 1;
break;
case DrawAbleType.Line:
rtnval = 2;
break;
case DrawAbleType.Surface:
rtnval = 3;
break;
}
}
else
{
int ttype = 0;
foreach (DrawAble d in _drawables)
ttype = ttype | (int)d.DrawEtype;
switch (ttype)
{
case 1:
rtnval = 5; //MultiPoint
break;
case 2:
rtnval = 6; //MultiLine
break;
case 4:
rtnval = 7; //MultiPolygon
break;
default:
rtnval = 4; //Collection
break;
}
}
return rtnval;
}
I really wrestled with these DrawAbleSubComponentEType enums. I tried to be really clever with these values and somehow take advantage of the relationship between ETYPE and INTERPRETATION. Tried is the operative word.
The specification has to many exceptions for this to work but at least I have my unique values.
I do wonder alot as to why Oracle set up the unique combinations for Circle, Rectangle and instances of all Curves. I did read the spec on “Oriented Point” and just arbitrarily decided NOT to support it. I will never use it and I guess I am the boss. So if you need that you will have to do it yourself. It should be a straight forward job for someone with the motivation.
When it gets time to resolve these into the “real” ETYPE and INTERPRETATION values I just set up a couple static methods in a static utility class.
Source code (C#):
public static int BasicETYPE(DrawAbleSubComponentEType t)
{
int rtnval = 0;
switch (t)
{
case DrawAbleSubComponentEType.Point:
case DrawAbleSubComponentEType.PointCluster:
case DrawAbleSubComponentEType.PointOriented:
rtnval = 1;
break;
case DrawAbleSubComponentEType.SimpleLine:
case DrawAbleSubComponentEType.SimpleLineAllCurves:
rtnval = 2;
break;
case DrawAbleSubComponentEType.CompoundLine:
rtnval = 4;
break;
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingLine:
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingAllCurves:
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingCircle:
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingRectangle:
rtnval = 1003;
break;
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingLine:
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingAllCurves:
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingCircle:
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingRectangle:
rtnval = 2003;
break;
case DrawAbleSubComponentEType.CompoundSurfaceOuterRingLine:
rtnval = 1005;
break;
case DrawAbleSubComponentEType.CompoundSurfaceInnerRingLine:
rtnval = 2005;
break;
default:
break;
}
return rtnval;
}
public static int BasicINTERPRETATION(DrawAbleSubComponentEType t)
{
int rtnval = 0;
switch (t)
{
case DrawAbleSubComponentEType.Point:
case DrawAbleSubComponentEType.SimpleLine:
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingLine:
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingLine:
rtnval = 1;
break;
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingAllCurves:
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingAllCurves:
case DrawAbleSubComponentEType.SimpleLineAllCurves:
rtnval = 2;
break;
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingRectangle:
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingRectangle:
rtnval = 3;
break;
case DrawAbleSubComponentEType.SimpleSurfaceInnerRingCircle:
case DrawAbleSubComponentEType.SimpleSurfaceOuterRingCircle:
rtnval = 4;
break;
case DrawAbleSubComponentEType.PointCluster:
case DrawAbleSubComponentEType.CompoundLine:
case DrawAbleSubComponentEType.CompoundSurfaceOuterRingLine:
case DrawAbleSubComponentEType.CompoundSurfaceInnerRingLine:
rtnval = 0;
break;
case DrawAbleSubComponentEType.PointOriented:
rtnval = 9;
break;
default:
break;
}
return rtnval;
}
To be continued ...
No comments:
Post a Comment