# Loading layers twice just for labels!?

**URL:** <https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228>\
**Category:** WinForms\
**Created:** [February 10, 2009, 12:03pm UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228 "2009-02-10T12:03:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![brendan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/50afbb/32.png) [@brendan](https://community.thinkgeo.com/u/brendan)\
**Post date:** [February 10, 2009, 12:03pm UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/1 "2009-02-10T12:03:35Z")

</div>

Ok,&nbsp;here's&nbsp;one&nbsp;for&nbsp;performance.&nbsp;

I&nbsp;have&nbsp;created&nbsp;my&nbsp;own&nbsp;FeatureSource&nbsp;/&nbsp;FeatureLayer.&nbsp;After&nbsp;working&nbsp;through&nbsp;a&nbsp;whole&nbsp;bunch&nbsp;of&nbsp;stuff&nbsp;that&nbsp;I&nbsp;do&nbsp;not&nbsp;wish&nbsp;on&nbsp;my&nbsp;worst&nbsp;enemy&nbsp;(namely&nbsp;creating&nbsp;my&nbsp;own&nbsp;indexing&nbsp;algorithm&nbsp;/&nbsp;writing&nbsp;binary&nbsp;files&nbsp;etc),&nbsp;I&nbsp;am&nbsp;vastly&nbsp;more&nbsp;conscious&nbsp;about&nbsp;performance&nbsp;and&nbsp;microseconds.

That&nbsp;brings&nbsp;me&nbsp;to&nbsp;labels.&nbsp;It&nbsp;seems&nbsp;that&nbsp;if&nbsp;I&nbsp;want&nbsp;to&nbsp;display&nbsp;the&nbsp;labels&nbsp;for&nbsp;my&nbsp;layers...&nbsp;looking&nbsp;at&nbsp;the&nbsp;sample&nbsp;(DrawAndLabelANiceLookingRoad),&nbsp;I&nbsp;have&nbsp;to&nbsp;add&nbsp;the&nbsp;layer&nbsp;twice&nbsp;(first&nbsp;with&nbsp;the&nbsp;line&nbsp;style,&nbsp;then&nbsp;with&nbsp;the&nbsp;text&nbsp;style).&nbsp;If&nbsp;I&nbsp;add&nbsp;a&nbsp;DefaultTextStyle&nbsp;and&nbsp;DefaultLineStyle&nbsp;to&nbsp;the&nbsp;same&nbsp;layer,&nbsp;they&nbsp;both&nbsp;seem&nbsp;to&nbsp;render,&nbsp;but&nbsp;the&nbsp;text&nbsp;is&nbsp;behind&nbsp;the&nbsp;layer?

&nbsp;

 ![](https://community.thinkgeo.com/uploads/default/original/1X/92f98eea713d8d8c5fcdba7e48288c3c1e1695a3.jpg)

&nbsp;

Is&nbsp;there&nbsp;a&nbsp;way&nbsp;to&nbsp;reverse&nbsp;this&nbsp;and&nbsp;draw&nbsp;the&nbsp;lines&nbsp;before&nbsp;the&nbsp;labels&nbsp;so&nbsp;that&nbsp;I&nbsp;can&nbsp;add&nbsp;my&nbsp;layers&nbsp;once&nbsp;(and&nbsp;half&nbsp;the&nbsp;read&nbsp;time)?&nbsp;The&nbsp;only&nbsp;other&nbsp;alternative&nbsp;is&nbsp;for&nbsp;me&nbsp;to&nbsp;take&nbsp;the&nbsp;information&nbsp;from&nbsp;the&nbsp;first&nbsp;layer&nbsp;file&nbsp;parse,&nbsp;and&nbsp;share&nbsp;it&nbsp;with&nbsp;the&nbsp;second&nbsp;layer,&nbsp;and&nbsp;that's&nbsp;just&nbsp;extra&nbsp;hacking.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [February 11, 2009, 8:15am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/2 "2009-02-11T08:15:42Z")

</div>

Brendan,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;I&nbsp;see&nbsp;the&nbsp;issue&nbsp;you&nbsp;are&nbsp;having&nbsp;and&nbsp;there&nbsp;are&nbsp;some&nbsp;complex&nbsp;reasons&nbsp;for&nbsp;it&nbsp;so&nbsp;hold&nbsp;on.&nbsp;&nbsp;First&nbsp;before&nbsp;I&nbsp;go&nbsp;into&nbsp;a&nbsp;total&nbsp;brain&nbsp;dump&nbsp;on&nbsp;this&nbsp;one&nbsp;way&nbsp;to&nbsp;fix&nbsp;this&nbsp;issue&nbsp;is&nbsp;for&nbsp;you&nbsp;to&nbsp;not&nbsp;use&nbsp;the&nbsp;default&nbsp;properties&nbsp;on&nbsp;the&nbsp;ZoomLevel&nbsp;like&nbsp;DefaultTextStyle.&nbsp;&nbsp;Instead&nbsp;use&nbsp;the&nbsp;CustomStyles&nbsp;collection&nbsp;and&nbsp;add&nbsp;the&nbsp;LineStyle&nbsp;first&nbsp;and&nbsp;then&nbsp;the&nbsp;TextStyle.&nbsp;&nbsp;We&nbsp;need&nbsp;to&nbsp;make&nbsp;this&nbsp;drawing&nbsp;order&nbsp;change&nbsp;in&nbsp;the&nbsp;code&nbsp;as&nbsp;it&nbsp;will&nbsp;come&nbsp;up&nbsp;again&nbsp;and&nbsp;again&nbsp;so&nbsp;thanks&nbsp;for&nbsp;pointing&nbsp;this&nbsp;out.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;Having&nbsp;said&nbsp;all&nbsp;of&nbsp;that&nbsp;there&nbsp;are&nbsp;some&nbsp;more&nbsp;things&nbsp;you&nbsp;need&nbsp;to&nbsp;understand&nbsp;otherwise&nbsp;you&nbsp;will&nbsp;fall&nbsp;into&nbsp;another&nbsp;trap&nbsp;later&nbsp;on.&nbsp;&nbsp;Inside&nbsp;of&nbsp;the&nbsp;Style’s&nbsp;Draw&nbsp;method&nbsp;is&nbsp;where&nbsp;we&nbsp;make&nbsp;calls&nbsp;the&nbsp;GeoCanvas&nbsp;to&nbsp;draw&nbsp;everything.&nbsp;&nbsp;When&nbsp;we&nbsp;make&nbsp;the&nbsp;call&nbsp;like&nbsp;GeoCanvas.DrawLine&nbsp;we&nbsp;have&nbsp;a&nbsp;parameter&nbsp;that&nbsp;is&nbsp;called&nbsp;drawing&nbsp;level,&nbsp;it&nbsp;is&nbsp;an&nbsp;enumeration&nbsp;and&nbsp;I&nbsp;think&nbsp;we&nbsp;have&nbsp;five&nbsp;of&nbsp;them.&nbsp;&nbsp;What&nbsp;happens&nbsp;is&nbsp;for&nbsp;every&nbsp;drawing&nbsp;level&nbsp;used&nbsp;we&nbsp;create&nbsp;a&nbsp;temporary&nbsp;bitmap.&nbsp;&nbsp;When&nbsp;you&nbsp;draw&nbsp;a&nbsp;simple&nbsp;line&nbsp;then&nbsp;it&nbsp;draws&nbsp;on&nbsp;level&nbsp;one&nbsp;by&nbsp;default.&nbsp;&nbsp;If&nbsp;you&nbsp;have&nbsp;a&nbsp;complex&nbsp;line&nbsp;like&nbsp;a&nbsp;street&nbsp;that&nbsp;you&nbsp;might&nbsp;want&nbsp;to&nbsp;display&nbsp;as&nbsp;a&nbsp;solid&nbsp;thick&nbsp;black&nbsp;line&nbsp;with&nbsp;a&nbsp;thinner&nbsp;white&nbsp;line&nbsp;inside&nbsp;then&nbsp;what&nbsp;we&nbsp;do&nbsp;is&nbsp;draw&nbsp;the&nbsp;thick&nbsp;black&nbsp;like&nbsp;on&nbsp;level&nbsp;1&nbsp;and&nbsp;then&nbsp;the&nbsp;thinner&nbsp;white&nbsp;line&nbsp;on&nbsp;level&nbsp;2.&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;When&nbsp;we&nbsp;are&nbsp;done&nbsp;with&nbsp;drawing&nbsp;that&nbsp;layer&nbsp;and&nbsp;the&nbsp;GeoCanvas.Flush&nbsp;or&nbsp;EndDrawing&nbsp;is&nbsp;called&nbsp;we&nbsp;composite&nbsp;the&nbsp;bitmaps&nbsp;in&nbsp;layer&nbsp;drawing&nbsp;order&nbsp;and&nbsp;it&nbsp;create&nbsp;the&nbsp;final&nbsp;bitmap.&nbsp;&nbsp;There&nbsp;are&nbsp;a&nbsp;number&nbsp;of&nbsp;reasons&nbsp;why&nbsp;do&nbsp;that.&nbsp;&nbsp;First&nbsp;is&nbsp;that&nbsp;if&nbsp;we&nbsp;were&nbsp;to&nbsp;draw&nbsp;the&nbsp;black&nbsp;and&nbsp;white&nbsp;line&nbsp;in&nbsp;order&nbsp;by&nbsp;feature&nbsp;the&nbsp;effect&nbsp;would&nbsp;not&nbsp;look&nbsp;very&nbsp;good&nbsp;because&nbsp;of&nbsp;the&nbsp;caps&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;lines.&nbsp;&nbsp;The&nbsp;white&nbsp;area&nbsp;would&nbsp;not&nbsp;seamlessly&nbsp;merge&nbsp;into&nbsp;an&nbsp;adjoining&nbsp;line&nbsp;correctly.&nbsp;&nbsp;You&nbsp;would&nbsp;get&nbsp;bad&nbsp;looking&nbsp;artifacts&nbsp;of&nbsp;where&nbsp;the&nbsp;black&nbsp;line&nbsp;would&nbsp;intersect&nbsp;the&nbsp;white&nbsp;line&nbsp;a&nbsp;little&nbsp;bit.&nbsp;&nbsp;The&nbsp;other&nbsp;method&nbsp;we&nbsp;had&nbsp;in&nbsp;2.x&nbsp;would&nbsp;be&nbsp;to&nbsp;draw&nbsp;all&nbsp;the&nbsp;black&nbsp;lines&nbsp;first,&nbsp;then&nbsp;loop&nbsp;through&nbsp;the&nbsp;features&nbsp;again&nbsp;and&nbsp;draw&nbsp;the&nbsp;white&nbsp;lines.&nbsp;&nbsp;The&nbsp;problem&nbsp;with&nbsp;that&nbsp;is&nbsp;at&nbsp;any&nbsp;moment&nbsp;if&nbsp;you&nbsp;wanted&nbsp;to&nbsp;interrupt&nbsp;the&nbsp;drawing&nbsp;process&nbsp;then&nbsp;you&nbsp;would&nbsp;get&nbsp;a&nbsp;picture&nbsp;of&nbsp;all&nbsp;black&nbsp;lines&nbsp;with&nbsp;some&nbsp;white&nbsp;lines&nbsp;but&nbsp;not&nbsp;all&nbsp;of&nbsp;them.&nbsp;&nbsp;The&nbsp;other&nbsp;reason&nbsp;is&nbsp;that&nbsp;it&nbsp;makes&nbsp;the&nbsp;code&nbsp;in&nbsp;the&nbsp;GeoCanvas&nbsp;much&nbsp;more&nbsp;elegant&nbsp;and&nbsp;avoids&nbsp;caching&nbsp;a&nbsp;bunch&nbsp;of&nbsp;future&nbsp;drawing&nbsp;requests.&nbsp;&nbsp;In&nbsp;our&nbsp;system&nbsp;we&nbsp;draw&nbsp;the&nbsp;each&nbsp;record&nbsp;for&nbsp;every&nbsp;style&nbsp;once&nbsp;and&nbsp;no&nbsp;need&nbsp;for&nbsp;extra&nbsp;looping.&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;The&nbsp;reason&nbsp;I&nbsp;mention&nbsp;this&nbsp;is&nbsp;because&nbsp;the&nbsp;LineStyle&nbsp;and&nbsp;TextStyle&nbsp;both&nbsp;by&nbsp;default&nbsp;draw&nbsp;on&nbsp;level&nbsp;1.&nbsp;&nbsp;While&nbsp;in&nbsp;your&nbsp;case&nbsp;it&nbsp;doesn’t&nbsp;matter&nbsp;because&nbsp;your&nbsp;line&nbsp;is&nbsp;just&nbsp;one&nbsp;single&nbsp;line&nbsp;and&nbsp;not&nbsp;a&nbsp;composite&nbsp;line&nbsp;you&nbsp;wouldn’t&nbsp;notice.&nbsp;&nbsp;If&nbsp;you&nbsp;later&nbsp;made&nbsp;the&nbsp;line&nbsp;have&nbsp;an&nbsp;outer&nbsp;and&nbsp;inner&nbsp;pen&nbsp;then&nbsp;what&nbsp;would&nbsp;happen&nbsp;is&nbsp;that&nbsp;the&nbsp;inner&nbsp;pen&nbsp;would&nbsp;draw&nbsp;on&nbsp;top&nbsp;of&nbsp;your&nbsp;labels&nbsp;while&nbsp;the&nbsp;outer&nbsp;pen&nbsp;would&nbsp;be&nbsp;behind&nbsp;them.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;One&nbsp;change&nbsp;we&nbsp;could&nbsp;make&nbsp;is&nbsp;for&nbsp;the&nbsp;TextStyle&nbsp;to&nbsp;be&nbsp;default&nbsp;draw&nbsp;on&nbsp;level&nbsp;4&nbsp;or&nbsp;higher.&nbsp;&nbsp;The&nbsp;downside&nbsp;of&nbsp;this&nbsp;is&nbsp;that&nbsp;it&nbsp;could&nbsp;still&nbsp;happen&nbsp;if&nbsp;someone&nbsp;created&nbsp;&nbsp;style&nbsp;that&nbsp;used&nbsp;all&nbsp;five&nbsp;drawing&nbsp;levels.&nbsp;&nbsp;It&nbsp;would&nbsp;however&nbsp;cover&nbsp;the&nbsp;major&nbsp;cases.&nbsp;&nbsp;We&nbsp;could&nbsp;also&nbsp;add&nbsp;a&nbsp;new&nbsp;drawing&nbsp;level&nbsp;called&nbsp;Label&nbsp;which&nbsp;would&nbsp;be&nbsp;reserved&nbsp;for&nbsp;labels.&nbsp;&nbsp;There&nbsp;are&nbsp;some&nbsp;problems&nbsp;with&nbsp;this&nbsp;for&nbsp;things&nbsp;like&nbsp;halo&nbsp;pens&nbsp;etc.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;This&nbsp;brings&nbsp;me&nbsp;to&nbsp;another&nbsp;point.&nbsp;&nbsp;I&nbsp;understand&nbsp;the&nbsp;reason&nbsp;you&nbsp;want&nbsp;to&nbsp;do&nbsp;this&nbsp;is&nbsp;for&nbsp;performance&nbsp;but&nbsp;I&nbsp;want&nbsp;to&nbsp;caution&nbsp;you&nbsp;on&nbsp;some&nbsp;side&nbsp;effects.&nbsp;&nbsp;The&nbsp;first&nbsp;is&nbsp;typically&nbsp;people&nbsp;expect&nbsp;labels&nbsp;to&nbsp;draw&nbsp;on&nbsp;top&nbsp;of&nbsp;everything&nbsp;else.&nbsp;&nbsp;In&nbsp;your&nbsp;case&nbsp;they&nbsp;would&nbsp;not.&nbsp;&nbsp;If&nbsp;you&nbsp;had&nbsp;another&nbsp;layer&nbsp;on&nbsp;top&nbsp;of&nbsp;your&nbsp;roads&nbsp;say&nbsp;of&nbsp;points&nbsp;then&nbsp;it&nbsp;might&nbsp;happen&nbsp;that&nbsp;a&nbsp;point&nbsp;might&nbsp;overlap&nbsp;your&nbsp;label&nbsp;and&nbsp;cover&nbsp;it.&nbsp;&nbsp;People&nbsp;might&nbsp;find&nbsp;this&nbsp;is&nbsp;strange.&nbsp;&nbsp;The&nbsp;second&nbsp;point&nbsp;is&nbsp;that&nbsp;if&nbsp;you&nbsp;draw&nbsp;all&nbsp;of&nbsp;your&nbsp;label&nbsp;levels&nbsp;separately&nbsp;then&nbsp;you&nbsp;could&nbsp;put&nbsp;them&nbsp;into&nbsp;their&nbsp;own&nbsp;overlay&nbsp;and&nbsp;get&nbsp;all&nbsp;of&nbsp;control&nbsp;there&nbsp;over&nbsp;caching&nbsp;etc.&nbsp;&nbsp;In&nbsp;the&nbsp;future&nbsp;as&nbsp;we&nbsp;get&nbsp;threading&nbsp;corrected&nbsp;it&nbsp;maybe&nbsp;possible&nbsp;to&nbsp;do&nbsp;the&nbsp;labels&nbsp;on&nbsp;a&nbsp;separate&nbsp;thread&nbsp;from&nbsp;the&nbsp;roads&nbsp;etc.&nbsp;&nbsp;Or&nbsp;more&nbsp;possible&nbsp;we&nbsp;could&nbsp;do&nbsp;the&nbsp;foundation&nbsp;layers&nbsp;first&nbsp;and&nbsp;then&nbsp;display&nbsp;them&nbsp;on&nbsp;the&nbsp;map&nbsp;and&nbsp;next&nbsp;work&nbsp;on&nbsp;the&nbsp;labels.&nbsp;&nbsp;This&nbsp;would&nbsp;give&nbsp;the&nbsp;user&nbsp;more&nbsp;instant&nbsp;feedback.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;Another&nbsp;thing&nbsp;I&nbsp;wanted&nbsp;to&nbsp;bring&nbsp;up&nbsp;is&nbsp;performance.&nbsp;&nbsp;I&nbsp;strongly&nbsp;suggest&nbsp;you&nbsp;try&nbsp;with&nbsp;separate&nbsp;layers&nbsp;and&nbsp;see&nbsp;what&nbsp;the&nbsp;measurements&nbsp;are.&nbsp;&nbsp;In&nbsp;my&nbsp;experience&nbsp;there&nbsp;is&nbsp;little&nbsp;overhead&nbsp;to&nbsp;go&nbsp;back&nbsp;and&nbsp;get&nbsp;the&nbsp;data.&nbsp;&nbsp;Let&nbsp;me&nbsp;first&nbsp;preface&nbsp;that&nbsp;with&nbsp;it&nbsp;applies&nbsp;to&nbsp;shape&nbsp;files.&nbsp;&nbsp;If&nbsp;you&nbsp;are&nbsp;doing&nbsp;with&nbsp;a&nbsp;spatial&nbsp;database&nbsp;then&nbsp;this&nbsp;is&nbsp;not&nbsp;the&nbsp;case&nbsp;as&nbsp;there&nbsp;is&nbsp;overhead&nbsp;in&nbsp;the&nbsp;data&nbsp;request&nbsp;etc.&nbsp;&nbsp;The&nbsp;reason&nbsp;is&nbsp;that&nbsp;there&nbsp;are&nbsp;so&nbsp;many&nbsp;caches&nbsp;in&nbsp;between&nbsp;you&nbsp;and&nbsp;your&nbsp;data&nbsp;on&nbsp;e&nbsp;disk&nbsp;it&nbsp;is&nbsp;most&nbsp;likely&nbsp;that&nbsp;after&nbsp;the&nbsp;initial&nbsp;call&nbsp;the&nbsp;data&nbsp;is&nbsp;already&nbsp;hot&nbsp;in&nbsp;one&nbsp;of&nbsp;the&nbsp;caches.&nbsp;&nbsp;The&nbsp;disk&nbsp;has&nbsp;a&nbsp;16&nbsp;–&nbsp;32&nbsp;+&nbsp;megabyte&nbsp;cache&nbsp;and&nbsp;the&nbsp;OS&nbsp;caches&nbsp;quite&nbsp;a&nbsp;bit&nbsp;on&nbsp;its&nbsp;own.&nbsp;&nbsp;In&nbsp;many&nbsp;tests&nbsp;I&nbsp;have&nbsp;run&nbsp;on&nbsp;some&nbsp;unrelated&nbsp;things&nbsp;I&nbsp;can&nbsp;see&nbsp;the&nbsp;same&nbsp;pattern&nbsp;over&nbsp;and&nbsp;over.&nbsp;&nbsp;The&nbsp;first&nbsp;time&nbsp;the&nbsp;map&nbsp;loads&nbsp;the&nbsp;cost&nbsp;to&nbsp;draw&nbsp;a&nbsp;map&nbsp;is&nbsp;say&nbsp;1&nbsp;second&nbsp;and&nbsp;then&nbsp;every&nbsp;refresh&nbsp;if&nbsp;maybe&nbsp;0.5&nbsp;seconds.&nbsp;&nbsp;If&nbsp;you&nbsp;monitor&nbsp;the&nbsp;disk&nbsp;active&nbsp;you&nbsp;can&nbsp;see&nbsp;there&nbsp;aren’t&nbsp;any&nbsp;disk&nbsp;reads.&nbsp;&nbsp;In&nbsp;fact&nbsp;when&nbsp;I&nbsp;deal&nbsp;with&nbsp;people&nbsp;who&nbsp;use&nbsp;the&nbsp;InMemoryFeatureSource&nbsp;they&nbsp;can’t&nbsp;get&nbsp;over&nbsp;that&nbsp;it&nbsp;is&nbsp;just&nbsp;not&nbsp;that&nbsp;much&nbsp;faster&nbsp;than&nbsp;shape&nbsp;files&nbsp;on&nbsp;many&nbsp;cases.&nbsp;&nbsp;The&nbsp;reasons&nbsp;is&nbsp;after&nbsp;you&nbsp;take&nbsp;the&nbsp;first&nbsp;hit&nbsp;to&nbsp;take&nbsp;it&nbsp;off&nbsp;disk&nbsp;it&nbsp;tends&nbsp;to&nbsp;stick&nbsp;around&nbsp;in&nbsp;memory&nbsp;anyway.&nbsp;&nbsp;One&nbsp;prominent&nbsp;book&nbsp;I&nbsp;read&nbsp;in&nbsp;the&nbsp;past&nbsp;talked&nbsp;about&nbsp;how&nbsp;you&nbsp;can&nbsp;degrade&nbsp;performance&nbsp;by&nbsp;keeping&nbsp;too&nbsp;much&nbsp;stuff&nbsp;in&nbsp;your&nbsp;own&nbsp;caches.&nbsp;&nbsp;You&nbsp;may&nbsp;have&nbsp;the&nbsp;data&nbsp;two&nbsp;or&nbsp;three&nbsp;times&nbsp;in&nbsp;memory&nbsp;and&nbsp;there&nbsp;also&nbsp;overhead&nbsp;to&nbsp;managing&nbsp;it.&nbsp;&nbsp;I&nbsp;trust&nbsp;Windows&nbsp;caching&nbsp;system&nbsp;is&nbsp;pretty&nbsp;efficient.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;I&nbsp;am&nbsp;not&nbsp;trying&nbsp;to&nbsp;talk&nbsp;you&nbsp;out&nbsp;of&nbsp;your&nbsp;strategy&nbsp;however&nbsp;what&nbsp;I&nbsp;am&nbsp;strongly&nbsp;suggesting&nbsp;is&nbsp;that&nbsp;you&nbsp;measure,&nbsp;measure&nbsp;and&nbsp;measure&nbsp;some&nbsp;more.&nbsp;&nbsp;Try&nbsp;some&nbsp;things&nbsp;that&nbsp;dump&nbsp;your&nbsp;disk&nbsp;cache&nbsp;etc.&nbsp;&nbsp;One&nbsp;of&nbsp;traps&nbsp;we&nbsp;can&nbsp;fall&nbsp;in&nbsp;is&nbsp;to&nbsp;work&nbsp;on&nbsp;a&nbsp;new&nbsp;technique&nbsp;that&nbsp;is&nbsp;supposed&nbsp;to&nbsp;be&nbsp;faster&nbsp;an&nbsp;dthen&nbsp;since&nbsp;we&nbsp;are&nbsp;working&nbsp;on&nbsp;it&nbsp;that&nbsp;data&nbsp;is&nbsp;hot&nbsp;in&nbsp;cache&nbsp;so&nbsp;we&nbsp;get&nbsp;good&nbsp;numbers.&nbsp;&nbsp;Only&nbsp;every&nbsp;once&nbsp;and&nbsp;while&nbsp;we&nbsp;test&nbsp;the&nbsp;old&nbsp;way.&nbsp;&nbsp;Since&nbsp;it&nbsp;is&nbsp;not&nbsp;in&nbsp;cache&nbsp;it&nbsp;does&nbsp;not&nbsp;perform&nbsp;well&nbsp;and&nbsp;we&nbsp;validate&nbsp;our&nbsp;new&nbsp;method&nbsp;with&nbsp;that.&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;Having&nbsp;said&nbsp;all&nbsp;of&nbsp;that&nbsp;I&nbsp;know&nbsp;you&nbsp;are&nbsp;a&nbsp;smart&nbsp;guy&nbsp;and&nbsp;I&nbsp;would&nbsp;not&nbsp;be&nbsp;surprised&nbsp;if&nbsp;you&nbsp;came&nbsp;back&nbsp;tomorrow&nbsp;and&nbsp;told&nbsp;me&nbsp;in&nbsp;detail&nbsp;how&nbsp;we&nbsp;could&nbsp;get&nbsp;a&nbsp;50%&nbsp;performance&nbsp;increase&nbsp;by&nbsp;doing&nbsp;X&nbsp;or&nbsp;Y.&nbsp;&nbsp;I&nbsp;am&nbsp;mainly&nbsp;saying&nbsp;this&nbsp;to&nbsp;others&nbsp;that&nbsp;might&nbsp;look&nbsp;at&nbsp;this&nbsp;thread&nbsp;and&nbsp;want&nbsp;to&nbsp;go&nbsp;down&nbsp;the&nbsp;optimization&nbsp;road&nbsp;prematurely.&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;With&nbsp;all&nbsp;of&nbsp;that&nbsp;said&nbsp;good&nbsp;luck&nbsp;and&nbsp;let&nbsp;me&nbsp;know&nbsp;how&nbsp;it&nbsp;goes,&nbsp;I&nbsp;am&nbsp;hear&nbsp;to&nbsp;light&nbsp;your&nbsp;way&nbsp;in&nbsp;any&nbsp;way&nbsp;I&nbsp;can.&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [February 11, 2009, 8:18am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/3 "2009-02-11T08:18:07Z")

</div>

Brendan,&nbsp;  
&nbsp;&nbsp;  
&nbsp;One&nbsp;other&nbsp;thing.&nbsp;&nbsp;I&nbsp;will&nbsp;take&nbsp;some&nbsp;time&nbsp;and&nbsp;talk&nbsp;with&nbsp;our&nbsp;core&nbsp;team&nbsp;to&nbsp;see&nbsp;what&nbsp;else&nbsp;we&nbsp;can&nbsp;do.&nbsp;&nbsp;Maybe&nbsp;there&nbsp;is&nbsp;a&nbsp;yet&nbsp;unknown&nbsp;third&nbsp;solution&nbsp;out&nbsp;there.&nbsp;&nbsp;We&nbsp;love&nbsp;challenges!&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![brendan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/50afbb/32.png) [@brendan](https://community.thinkgeo.com/u/brendan)\
**Post date:** [February 11, 2009, 1:25pm UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/4 "2009-02-11T13:25:59Z")

</div>

Thanks&nbsp;for&nbsp;the&nbsp;insight…&nbsp;we’re&nbsp;doing&nbsp;something&nbsp;similar&nbsp;(multiple&nbsp;layers&nbsp;to&nbsp;layout&nbsp;stuff)&nbsp;when&nbsp;it&nbsp;comes&nbsp;to&nbsp;the&nbsp;WPF&nbsp;overlay.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’m&nbsp;timing&nbsp;everything&nbsp;in&nbsp;the&nbsp;GetFeaturesInsideBoundingBoxCore&nbsp;method…&nbsp;and&nbsp;it&nbsp;takes&nbsp;the&nbsp;same&nbsp;amount&nbsp;of&nbsp;time&nbsp;for&nbsp;both&nbsp;the&nbsp;shape&nbsp;pass&nbsp;and&nbsp;the&nbsp;label&nbsp;pass.&nbsp;I’m&nbsp;storing&nbsp;the&nbsp;“database”&nbsp;information&nbsp;(names&nbsp;etc)&nbsp;inside&nbsp;my&nbsp;data&nbsp;file&nbsp;(so&nbsp;no&nbsp;dbf&nbsp;file).&nbsp;This&nbsp;means&nbsp;that&nbsp;the&nbsp;second&nbsp;layer&nbsp;has&nbsp;to&nbsp;get&nbsp;all&nbsp;the&nbsp;same&nbsp;information&nbsp;again…&nbsp;which&nbsp;is&nbsp;taking&nbsp;the&nbsp;same&nbsp;time&nbsp;(to&nbsp;within&nbsp;a&nbsp;few&nbsp;milliseconds).&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;have&nbsp;control&nbsp;of&nbsp;all&nbsp;the&nbsp;FeatureSource,&nbsp;so&nbsp;I&nbsp;can&nbsp;work&nbsp;out&nbsp;a&nbsp;way&nbsp;to&nbsp;link&nbsp;my&nbsp;feature&nbsp;layers.&nbsp;I&nbsp;was&nbsp;thinking&nbsp;that&nbsp;if&nbsp;I&nbsp;add&nbsp;the&nbsp;layer&nbsp;twice,&nbsp;I&nbsp;can&nbsp;set&nbsp;a&nbsp;flag&nbsp;that&nbsp;will&nbsp;ensure&nbsp;that&nbsp;it&nbsp;doesn’t&nbsp;try&nbsp;load&nbsp;shapes,&nbsp;but&nbsp;only&nbsp;asked&nbsp;for&nbsp;an&nbsp;already&nbsp;cached&nbsp;list&nbsp;of&nbsp;shapes&nbsp;with&nbsp;labels&nbsp;(from&nbsp;the&nbsp;first&nbsp;layer’s&nbsp;pass).&nbsp;  
&nbsp;&nbsp;  
&nbsp;Of&nbsp;course,&nbsp;it&nbsp;would&nbsp;be&nbsp;nice&nbsp;to&nbsp;have&nbsp;a&nbsp;solution&nbsp;built&nbsp;into&nbsp;the&nbsp;GDI.&nbsp;That&nbsp;will&nbsp;be&nbsp;quicker&nbsp;to&nbsp;load&nbsp;I&nbsp;expect.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’ll&nbsp;let&nbsp;you&nbsp;know&nbsp;how&nbsp;that&nbsp;turns&nbsp;out.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [February 11, 2009, 5:33pm UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/5 "2009-02-11T17:33:53Z")

</div>

Brendan,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;On&nbsp;thing&nbsp;you&nbsp;can&nbsp;try&nbsp;is&nbsp;the&nbsp;cache&nbsp;property&nbsp;on&nbsp;the&nbsp;FeatureSource.&nbsp;&nbsp;We&nbsp;may&nbsp;have&nbsp;this,&nbsp;can;t&nbsp;remember&nbsp;the&nbsp;status&nbsp;of&nbsp;it.&nbsp;&nbsp;If&nbsp;you&nbsp;used&nbsp;this&nbsp;then&nbsp;you&nbsp;would&nbsp;not&nbsp;have&nbsp;to&nbsp;share&nbsp;the&nbsp;same&nbsp;feature&nbsp;source&nbsp;but&nbsp;you&nbsp;could&nbsp;share&nbsp;the&nbsp;same&nbsp;cache.&nbsp;&nbsp;Just&nbsp;make&nbsp;sure&nbsp;if&nbsp;the&nbsp;roads&nbsp;draw&nbsp;first&nbsp;you&nbsp;request&nbsp;the&nbsp;columns&nbsp;you&nbsp;will&nbsp;need&nbsp;for&nbsp;the&nbsp;labels.&nbsp;&nbsp;This&nbsp;way&nbsp;the&nbsp;data&nbsp;will&nbsp;be&nbsp;in&nbsp;the&nbsp;cache.&nbsp;&nbsp;I&nbsp;think&nbsp;this&nbsp;is&nbsp;a&nbsp;little&nbsp;oversight&nbsp;on&nbsp;our&nbsp;part.&nbsp;:-)&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;You&nbsp;can&nbsp;also&nbsp;inherit&nbsp;from&nbsp;cache&nbsp;and&nbsp;build&nbsp;your&nbsp;own.&nbsp;&nbsp;The&nbsp;way&nbsp;the&nbsp;ones&nbsp;that&nbsp;comes&nbsp;with&nbsp;the&nbsp;system&nbsp;works&nbsp;is&nbsp;that&nbsp;it&nbsp;caches&nbsp;the&nbsp;bounding&nbsp;box&nbsp;and&nbsp;features&nbsp;associated&nbsp;with&nbsp;it.&nbsp;&nbsp;If&nbsp;the&nbsp;same&nbsp;or&nbsp;smaller&nbsp;bounding&nbsp;box&nbsp;comes&nbsp;in&nbsp;then&nbsp;we&nbsp;use&nbsp;those&nbsp;records&nbsp;in&nbsp;memory.&nbsp;&nbsp;There&nbsp;are&nbsp;many&nbsp;different&nbsp;ways&nbsp;to&nbsp;build&nbsp;a&nbsp;cache&nbsp;though&nbsp;and&nbsp;this&nbsp;was&nbsp;just&nbsp;one&nbsp;way&nbsp;we&nbsp;did&nbsp;rather&nbsp;quickly.&nbsp;&nbsp;We&nbsp;have&nbsp;ideas&nbsp;fr&nbsp;a&nbsp;number&nbsp;of&nbsp;different&nbsp;way&nbsp;in&nbsp;memory&nbsp;on&nbsp;disk,&nbsp;using&nbsp;in&nbsp;memory&nbsp;spatial&nbsp;indexes&nbsp;etc.&nbsp;&nbsp;Caching&nbsp;is&nbsp;wide&nbsp;open&nbsp;at&nbsp;this&nbsp;point&nbsp;and&nbsp;different&nbsp;strategies&nbsp;work&nbsp;better&nbsp;for&nbsp;different&nbsp;kinds&nbsp;of&nbsp;FeatureSources.&nbsp;&nbsp;In&nbsp;your&nbsp;case&nbsp;you&nbsp;need&nbsp;to&nbsp;back&nbsp;it&nbsp;with&nbsp;memory&nbsp;as&nbsp;you&nbsp;use&nbsp;the&nbsp;local&nbsp;file&nbsp;system&nbsp;which&nbsp;is&nbsp;already&nbsp;pretty&nbsp;fast.&nbsp;&nbsp;People&nbsp;that&nbsp;use&nbsp;spatial&nbsp;databases&nbsp;such&nbsp;as&nbsp;Oracle&nbsp;Spatial&nbsp;get&nbsp;a&nbsp;big&nbsp;bang&nbsp;from&nbsp;writing&nbsp;the&nbsp;cache&nbsp;to&nbsp;disk&nbsp;and&nbsp;persisting&nbsp;it.&nbsp;&nbsp;It&nbsp;allows&nbsp;them&nbsp;to&nbsp;cache&nbsp;more&nbsp;data&nbsp;over&nbsp;time&nbsp;and&nbsp;cut&nbsp;down&nbsp;on&nbsp;their&nbsp;round&nbsp;trips.&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![brendan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/50afbb/32.png) [@brendan](https://community.thinkgeo.com/u/brendan)\
**Post date:** [February 12, 2009, 3:31am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/6 "2009-02-12T03:31:41Z")

</div>

Thanks&nbsp;David.&nbsp;The&nbsp;GeoCache&nbsp;property&nbsp;seems&nbsp;to&nbsp;help&nbsp;quite&nbsp;a&nbsp;bit.&nbsp;The&nbsp;trick&nbsp;is&nbsp;deciding&nbsp;when&nbsp;to&nbsp;use&nbsp;it&nbsp;because&nbsp;I&nbsp;don’t&nbsp;want&nbsp;to&nbsp;cache&nbsp;the&nbsp;world.&nbsp;I’ll&nbsp;work&nbsp;out&nbsp;a&nbsp;way&nbsp;that&nbsp;fits&nbsp;well&nbsp;for&nbsp;the&nbsp;project.&nbsp;Thanks.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [February 12, 2009, 3:48am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/7 "2009-02-12T03:48:29Z")

</div>

Brendan,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;If&nbsp;you&nbsp;have&nbsp;some&nbsp;scenerios&nbsp;or&nbsp;ideas&nbsp;let&nbsp;me&nbsp;know.&nbsp;&nbsp;This&nbsp;was&nbsp;a&nbsp;last&nbsp;minute&nbsp;class&nbsp;and&nbsp;we&nbsp;made&nbsp;it&nbsp;simple&nbsp;but&nbsp;expected&nbsp;to&nbsp;expand&nbsp;the&nbsp;types&nbsp;of&nbsp;caches&nbsp;in&nbsp;the&nbsp;future.&nbsp;&nbsp;Caching&nbsp;is&nbsp;a&nbsp;tricky&nbsp;business&nbsp;and&nbsp;any&nbsp;feedback&nbsp;on&nbsp;the&nbsp;API’s&nbsp;usefullness&nbsp;if&nbsp;you&nbsp;subclass&nbsp;is&nbsp;welcomed.&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![brendan](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/50afbb/32.png) [@brendan](https://community.thinkgeo.com/u/brendan)\
**Post date:** [February 12, 2009, 4:02am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/8 "2009-02-12T04:02:50Z")

</div>

I’ll&nbsp;let&nbsp;you&nbsp;know&nbsp;how&nbsp;we&nbsp;end&nbsp;up&nbsp;using&nbsp;it&nbsp;/&nbsp;if&nbsp;we&nbsp;need&nbsp;to&nbsp;inherit&nbsp;it&nbsp;etc.&nbsp;I&nbsp;have&nbsp;a&nbsp;few&nbsp;ideas&nbsp;about&nbsp;how&nbsp;we&nbsp;might&nbsp;do&nbsp;it,&nbsp;but&nbsp;there’s&nbsp;no&nbsp;point&nbsp;talking&nbsp;about&nbsp;it&nbsp;now&nbsp;until&nbsp;I&nbsp;have&nbsp;concrete&nbsp;ideas.&nbsp;Thanks.

---

<div class="post-metadata">

**Author:** ![David](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@David](https://community.thinkgeo.com/u/David)\
**Post date:** [February 13, 2009, 8:58am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/9 "2009-02-13T08:58:05Z")

</div>

Brendan,&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;Great.&nbsp;&nbsp;Let&nbsp;me&nbsp;know&nbsp;what&nbsp;you&nbsp;end&nbsp;up&nbsp;doing.&nbsp;  
&nbsp;&nbsp;  
&nbsp;David

---

<div class="post-metadata">

**Author:** ![Clint1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/f6c823/32.png) [@Clint1](https://community.thinkgeo.com/u/Clint1)\
**Post date:** [March 23, 2009, 10:25am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/10 "2009-03-23T10:25:04Z")

</div>

Hi,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;noticed&nbsp;that&nbsp;if&nbsp;I&nbsp;use&nbsp;the&nbsp;default&nbsp;line&nbsp;style&nbsp;and&nbsp;default&nbsp;text&nbsp;style&nbsp;that&nbsp;my&nbsp;label&nbsp;shows&nbsp;up&nbsp;below&nbsp;my&nbsp;line&nbsp;too.&nbsp;&nbsp;While&nbsp;I&nbsp;understant&nbsp;I&nbsp;can&nbsp;work&nbsp;around&nbsp;this&nbsp;is&nbsp;this&nbsp;something&nbsp;that&nbsp;will&nbsp;be&nbsp;changed?&nbsp;&nbsp;David&nbsp;aboves&nbsp;references&nbsp;maybing&nbsp;making&nbsp;the&nbsp;textstyle&nbsp;draw&nbsp;on&nbsp;level&nbsp;4&nbsp;or&nbsp;higher&nbsp;or&nbsp;even&nbsp;have&nbsp;it’s&nbsp;own&nbsp;specific&nbsp;level.&nbsp;&nbsp;I&nbsp;would&nbsp;think&nbsp;a&nbsp;lot&nbsp;of&nbsp;people&nbsp;might&nbsp;run&nbsp;into&nbsp;this&nbsp;issue,&nbsp;is&nbsp;there&nbsp;any&nbsp;plan&nbsp;to&nbsp;implement&nbsp;this&nbsp;before&nbsp;the&nbsp;final&nbsp;release?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks!

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [March 24, 2009, 5:23am UTC](https://community.thinkgeo.com/t/loading-layers-twice-just-for-labels/228/11 "2009-03-24T05:23:43Z")

</div>

Clint,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;will&nbsp;make&nbsp;sure&nbsp;it&nbsp;is&nbsp;on&nbsp;the&nbsp;Tracking&nbsp;system&nbsp;and&nbsp;remind&nbsp;the&nbsp;team&nbsp;to&nbsp;discuss&nbsp;it&nbsp;for&nbsp;the&nbsp;upcoming&nbsp;release.&nbsp;&nbsp;I&nbsp;think&nbsp;it&nbsp;is&nbsp;not&nbsp;that&nbsp;difficult&nbsp;to&nbsp;solve.&nbsp;&nbsp;Thanks&nbsp;for&nbsp;pointing&nbsp;it&nbsp;out.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben.
