# Multiple Ellipse Shapes Drawing Slowly

**URL:** <https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184>\
**Category:** WinForms\
**Created:** [March 1, 2013, 8:05am UTC](https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184 "2013-03-01T08:05:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dib](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/dib/32/19493_2.png) [@Dib](https://community.thinkgeo.com/u/Dib)\
**Post date:** [March 1, 2013, 8:05am UTC](https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184/1 "2013-03-01T08:05:42Z")

</div>

&nbsp;Hello,

&nbsp;

I&nbsp;need&nbsp;to&nbsp;represent&nbsp;1000&nbsp;lat/lon&nbsp;points&nbsp;on&nbsp;our&nbsp;map.&nbsp;&nbsp;We&nbsp;have&nbsp;objects&nbsp;that&nbsp;that&nbsp;hold&nbsp;the&nbsp;data&nbsp;for&nbsp;each&nbsp;point.&nbsp;&nbsp;The&nbsp;points&nbsp;need&nbsp;to&nbsp;be&nbsp;represented&nbsp;as&nbsp;circles&nbsp;of&nbsp;various&nbsp;diameters,&nbsp;filled&nbsp;in&nbsp;with&nbsp;various&nbsp;colors,&nbsp;and&nbsp;have&nbsp;an&nbsp;outline&nbsp;of&nbsp;various&nbsp;colors&nbsp;and&nbsp;various&nbsp;widths,&nbsp;all&nbsp;dictated&nbsp;by&nbsp;the&nbsp;data.

&nbsp;

Right&nbsp;now&nbsp;I&nbsp;am&nbsp;creating&nbsp;a&nbsp;PointShape&nbsp;for&nbsp;the&nbsp;lat/lon,&nbsp;then&nbsp;creating&nbsp;an&nbsp;EllipseShape&nbsp;using&nbsp;the&nbsp;PointShape,&nbsp;and&nbsp;the&nbsp;required&nbsp;circle&nbsp;width.&nbsp;&nbsp;I&nbsp;am&nbsp;then&nbsp;creating&nbsp;a&nbsp;new&nbsp;InMemoryFeatureLayer,&nbsp;and&nbsp;adding&nbsp;the&nbsp;EllipseShape&nbsp;to&nbsp;its&nbsp;InternalFeatures.&nbsp;&nbsp;I&nbsp;then&nbsp;set&nbsp;the&nbsp;layer's&nbsp;DefaultAreaStyle.FillSolidBrush.Color,&nbsp;DefaultAreaStyle.OutlinePen.Color,&nbsp;and&nbsp;DefaultAreaStyle.OutlinePen.Width&nbsp;based&nbsp;on&nbsp;the&nbsp;data&nbsp;for&nbsp;the&nbsp;point,&nbsp;and&nbsp;add&nbsp;the&nbsp;InMemoryFeatureLayer&nbsp;to&nbsp;a&nbsp;LayerOverlay.

&nbsp;

The&nbsp;problem&nbsp;comes&nbsp;when&nbsp;the&nbsp;map&nbsp;draws&nbsp;this&nbsp;LayerOverlay.&nbsp;&nbsp;It&nbsp;takes&nbsp;quite&nbsp;a&nbsp;long&nbsp;time,&nbsp;upwards&nbsp;of&nbsp;15&nbsp;seconds&nbsp;to&nbsp;show&nbsp;up.&nbsp;&nbsp;This&nbsp;delay&nbsp;is&nbsp;also&nbsp;apparent&nbsp;every&nbsp;time&nbsp;the&nbsp;map&nbsp;is&nbsp;moved&nbsp;or&nbsp;scaled.&nbsp;&nbsp;I&nbsp;imagine&nbsp;that&nbsp;is&nbsp;due&nbsp;to&nbsp;the&nbsp;fact&nbsp;that&nbsp;each&nbsp;point/ellipse&nbsp;is&nbsp;in&nbsp;a&nbsp;layer&nbsp;of&nbsp;its&nbsp;own,&nbsp;and&nbsp;not&nbsp;features&nbsp;within&nbsp;a&nbsp;single&nbsp;layer.&nbsp;&nbsp;The&nbsp;need&nbsp;to&nbsp;draw&nbsp;them&nbsp;with&nbsp;different&nbsp;color&nbsp;combinations&nbsp;and&nbsp;outline&nbsp;pen&nbsp;widths&nbsp;seems&nbsp;to&nbsp;necessitate&nbsp;the&nbsp;multiple&nbsp;layers.

&nbsp;

What&nbsp;is&nbsp;the&nbsp;best&nbsp;way&nbsp;for&nbsp;me&nbsp;to&nbsp;get&nbsp;this&nbsp;on&nbsp;screen&nbsp;with&nbsp;a&nbsp;faster&nbsp;draw&nbsp;rate?&nbsp;&nbsp;Can&nbsp;I&nbsp;somehow&nbsp;use&nbsp;columns,&nbsp;or&nbsp;is&nbsp;there&nbsp;another&nbsp;solution?&nbsp;&nbsp;I&nbsp;am&nbsp;considereing&nbsp;creating&nbsp;a&nbsp;new&nbsp;InMemoryFeatureLayer&nbsp;whenever&nbsp;a&nbsp;new&nbsp;fill&nbsp;color/outline&nbsp;pen&nbsp;color/outline&nbsp;pen&nbsp;width&nbsp;is&nbsp;encountered,&nbsp;and&nbsp;making&nbsp;sure&nbsp;each&nbsp;ellipse&nbsp;gets&nbsp;put&nbsp;into&nbsp;that&nbsp;corresponding&nbsp;layer.&nbsp;&nbsp;That&nbsp;should&nbsp;reduce&nbsp;the&nbsp;amount&nbsp;of&nbsp;InMemoryFeatureLayers&nbsp;greatly.

&nbsp;

Any&nbsp;thoughts&nbsp;would&nbsp;be&nbsp;helpful

&nbsp;

Thanks,&nbsp;

Dib

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [March 1, 2013, 8:19am UTC](https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184/2 "2013-03-01T08:19:59Z")

</div>

I’m&nbsp;a&nbsp;long-time&nbsp;customer&nbsp;and&nbsp;huge&nbsp;fan&nbsp;of&nbsp;ThinkGeo.&nbsp;&nbsp;I&nbsp;hope&nbsp;I’m&nbsp;not&nbsp;butting&nbsp;in,&nbsp;but&nbsp;we&nbsp;do&nbsp;exactly&nbsp;the&nbsp;type&nbsp;of&nbsp;thing&nbsp;that&nbsp;you&nbsp;are&nbsp;doing,&nbsp;except&nbsp;we&nbsp;draw&nbsp;several&nbsp;thousand&nbsp;of&nbsp;these&nbsp;symbols,&nbsp;theme&nbsp;by&nbsp;color&nbsp;and&nbsp;size,&nbsp;with&nbsp;our&nbsp;app.&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;you&nbsp;have&nbsp;a&nbsp;collection&nbsp;of&nbsp;business&nbsp;objects,&nbsp;I&nbsp;would:&nbsp;  
&nbsp;&nbsp;  
&nbsp;1)&nbsp;&nbsp;Create&nbsp;a&nbsp;custom&nbsp;layer&nbsp;(deriving&nbsp;from&nbsp;Layer)&nbsp;  
&nbsp;&nbsp;  
&nbsp;2)&nbsp;Make&nbsp;the&nbsp;layer&nbsp;operate&nbsp;off&nbsp;of&nbsp;the&nbsp;collection&nbsp;of&nbsp;your&nbsp;business&nbsp;objects&nbsp;as&nbsp;its&nbsp;data&nbsp;source.&nbsp;  
&nbsp;&nbsp;  
&nbsp;3)&nbsp;Explicitly&nbsp;draw&nbsp;the&nbsp;symbols&nbsp;for&nbsp;each&nbsp;business&nbsp;object&nbsp;within&nbsp;the&nbsp;DrawCore&nbsp;method&nbsp;of&nbsp;the&nbsp;layer.&nbsp;&nbsp;&nbsp;You’ll&nbsp;know&nbsp;the&nbsp;colors&nbsp;and&nbsp;widths&nbsp;because&nbsp;of&nbsp;the&nbsp;properties&nbsp;that&nbsp;are&nbsp;on&nbsp;your&nbsp;business&nbsp;objects.&nbsp;&nbsp;&nbsp;So,&nbsp;just&nbsp;use&nbsp;the&nbsp;canvase.DrawEllipse&nbsp;method&nbsp;with&nbsp;styles&nbsp;built&nbsp;from&nbsp;that&nbsp;info.&nbsp;  
&nbsp;&nbsp;  
&nbsp;We&nbsp;use&nbsp;this&nbsp;approach,&nbsp;and&nbsp;can&nbsp;render&nbsp;50,000&nbsp;business&nbsp;objects&nbsp;in&nbsp;1&nbsp;to&nbsp;3&nbsp;seconds.&nbsp;  
&nbsp;&nbsp;  
&nbsp;This&nbsp;is&nbsp;really&nbsp;very&nbsp;easy&nbsp;to&nbsp;do…&nbsp;but,&nbsp;as&nbsp;you&nbsp;are&nbsp;not&nbsp;deriving&nbsp;from&nbsp;a&nbsp;FeatureLayer,&nbsp;you’ll&nbsp;loose&nbsp;any&nbsp;ability&nbsp;to&nbsp;use&nbsp;the&nbsp;built&nbsp;in&nbsp;query&nbsp;tools.&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;that&nbsp;is&nbsp;important,&nbsp;and&nbsp;you&nbsp;do&nbsp;not&nbsp;want&nbsp;to&nbsp;build&nbsp;your&nbsp;own&nbsp;query&nbsp;support,&nbsp;then&nbsp;derive&nbsp;a&nbsp;new&nbsp;class&nbsp;from&nbsp;a&nbsp;FeatureSource.&nbsp;&nbsp;&nbsp;&nbsp;And&nbsp;implement&nbsp;the&nbsp;class&nbsp;to&nbsp;work&nbsp;directly&nbsp;off&nbsp;of&nbsp;your&nbsp;business&nbsp;objects,&nbsp;instead&nbsp;of&nbsp;copying&nbsp;them&nbsp;to&nbsp;in-memory&nbsp;feature&nbsp;layers.&nbsp;&nbsp;&nbsp;Then,&nbsp;you&nbsp;can&nbsp;use&nbsp;the&nbsp;standard&nbsp;styles,&nbsp;etc,&nbsp;but&nbsp;it&nbsp;will&nbsp;be&nbsp;quite&nbsp;a&nbsp;bit&nbsp;slower.&nbsp;&nbsp;&nbsp;I&nbsp;don’t&nbsp;think&nbsp;the&nbsp;ThinkGeo&nbsp;styles&nbsp;framework&nbsp;is&nbsp;optimized&nbsp;for&nbsp;rendering&nbsp;huge&nbsp;numbers&nbsp;of&nbsp;objects&nbsp;when&nbsp;the&nbsp;styles&nbsp;are&nbsp;determined&nbsp;from&nbsp;scalar&nbsp;values&nbsp;in&nbsp;the&nbsp;Feature&nbsp;objects.

---

<div class="post-metadata">

**Author:** ![Dib](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/dib/32/19493_2.png) [@Dib](https://community.thinkgeo.com/u/Dib)\
**Post date:** [March 1, 2013, 9:34am UTC](https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184/3 "2013-03-01T09:34:17Z")

</div>

Loading&nbsp;them&nbsp;as&nbsp;features&nbsp;into&nbsp;specific&nbsp;layers&nbsp;made&nbsp;a&nbsp;huge&nbsp;difference.&nbsp;&nbsp;Seems&nbsp;to&nbsp;be&nbsp;working&nbsp;well&nbsp;that&nbsp;way.

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [March 6, 2013, 3:36am UTC](https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184/4 "2013-03-06T03:36:46Z")

</div>

&nbsp;Thank&nbsp;you&nbsp;very&nbsp;much,&nbsp;Ted,&nbsp;I&nbsp;guess&nbsp;you&nbsp;gave&nbsp;a&nbsp;good&nbsp;answer&nbsp;here.&nbsp;Another&nbsp;option&nbsp;could&nbsp;be&nbsp;“ClassBreakStyle”,&nbsp;we&nbsp;use&nbsp;the&nbsp;“ClassBreakStyle”&nbsp;and&nbsp;created&nbsp;2000&nbsp;ellipses,&nbsp;and&nbsp;the&nbsp;drawing&nbsp;time&nbsp;is&nbsp;only&nbsp;904.2727ms&nbsp;on&nbsp;our&nbsp;end.&nbsp;The&nbsp;code&nbsp;just&nbsp;looks&nbsp;like:

`  private void DisplayMap_Load(object sender, EventArgs e)        {           …………            InMemoryFeatureLayer inmLayer = new InMemoryFeatureLayer();            inmLayer.Open();            inmLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            ClassBreakStyle classBreakStyle = new ClassBreakStyle("index");            inmLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);            inmLayer.Columns.Add(new FeatureSourceColumn("index"));            Random random = new Random();            for (int i = 0; i < 2000; i++)            {                PointShape pointshape = new PointShape(random.Next(0, 100), random.Next(0, 100));                EllipseShape ellipseShape = new EllipseShape(pointshape, random.Next(1, 3));                Feature ellipseFeature = new Feature(ellipseShape);                ellipseFeature.ColumnValues.Add("index", i.ToString());                inmLayer.InternalFeatures.Add(ellipseFeature);                ClassBreak classBreak = new ClassBreak(i, new AreaStyle(new GeoPen(GeoColor.GetRandomGeoColor(RandomColorType.All)), new GeoSolidBrush(GeoColor.GetRandomGeoColor(RandomColorType.All))));                classBreakStyle.ClassBreaks.Add(classBreak);            }          …….        }`

Please&nbsp;take&nbsp;a&nbsp;check.

Thanks,

Johnny

---

<div class="post-metadata">

**Author:** ![Ted](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@Ted](https://community.thinkgeo.com/u/Ted)\
**Post date:** [March 6, 2013, 6:23am UTC](https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184/5 "2013-03-06T06:23:34Z")

</div>

&nbsp;Very&nbsp;interesting.&nbsp;&nbsp;&nbsp;&nbsp;I've&nbsp;never&nbsp;used&nbsp;ClassBreak&nbsp;with&nbsp;that&nbsp;kind&nbsp;of&nbsp;volume.&nbsp;&nbsp;&nbsp;&nbsp;I&nbsp;would&nbsp;be&nbsp;interested&nbsp;in&nbsp;seeing&nbsp;your&nbsp;performance&nbsp;with&nbsp;what&nbsp;I&nbsp;think&nbsp;you&nbsp;call&nbsp;a&nbsp;ValueBreak&nbsp;style?&nbsp;&nbsp;&nbsp;Somthing&nbsp;that&nbsp;breaks&nbsp;on&nbsp;a&nbsp;scalar&nbsp;value,&nbsp;and&nbsp;than&nbsp;make&nbsp;you&nbsp;Index&nbsp;attribute&nbsp;be&nbsp;a&nbsp;double.

&nbsp;

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [March 6, 2013, 11:45pm UTC](https://community.thinkgeo.com/t/multiple-ellipse-shapes-drawing-slowly/2184/6 "2013-03-06T23:45:56Z")

</div>

By&nbsp;the&nbsp;way,&nbsp;if&nbsp;using&nbsp;the&nbsp;InMemoryFeatureLayer,&nbsp;I&nbsp;guess&nbsp;it&nbsp;should&nbsp;be&nbsp;faster&nbsp;after&nbsp;building&nbsp;spatial&nbsp;index&nbsp;for&nbsp;it&nbsp;by&nbsp;calling&nbsp;"BuildIndex()"&nbsp;method.&nbsp;Please&nbsp;have&nbsp;try.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Johnny
