Why does densify processing time vary significantly for similar geometries?

733
1
04-08-2021 01:45 PM
Justin_ODell
New Contributor III

var g = getGeom(100000000, 10); // pPoly.Densify takes > 6 seconds
var g2 = getGeom(100000000, 1000000); // pPoly.Densify takes < 25 milliseconds

Any idea why the time differential is so big between these two different calls to getGeom? Any suggestions for how to speed it up?

 

private static IGeometry getGeom(double m, double i)
{

IEnvelope pEnv = null;
IEllipticArc pEllipticArc = null;
IConstructEllipticArc pConstEllipticArc = null;

//build a bounding box for the ellipse
pEnv = new EnvelopeClass();
pEnv.PutCoords(0d, 0d, 0d, 0d);
pEnv.Expand(i / 2, m / 2, false);

//construct arc
pEllipticArc = new EllipticArcClass();
pConstEllipticArc = (IConstructEllipticArc)pEllipticArc;
pConstEllipticArc.ConstructEnvelope(pEnv);

//translate curve to polygon
IPolygon pPoly = new PolygonClass();
ISegmentCollection pSegColl = (ISegmentCollection)pPoly;
pSegColl = (ISegmentCollection)pPoly;
pSegColl.SetSegments(1, (ISegment)pConstEllipticArc);

double dDensification = 360;
Console.WriteLine($"BEGIN densification {pPoly.Length}/{dDensification}");
//densify to ensure proper projection
pPoly.Densify(pPoly.Length / dDensification, 0);
Console.WriteLine($"END densification {pPoly.Length}/{dDensification}");

return pPoly;

}

 

Thanks much!

0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor

I would ask what is it you are expanding by 100 million in the X and 10 in the Y? That's a nonsensical shape you are creating. You also don't set the spatial reference of your geometry which is best practise. So maybe the mathematics behind the construction of the ellipse and its subsequent densification is breaking because of this insanely large differences between the X and the Y?

0 Kudos