ThinkGeo.com    |     Documentation    |     Premium Support

Server Side Cache

Hey Guys,


Been working with the new server - it's  nice that the configuration has really been minimzed at this point since I no longer need to update the capabilities XML. Also the main rendering issue i had when I ran my server side cache builder is gone as well so that is good to see. It looks like one issue has been introduced though and that is the server-side cache is not getting hit when it should be. The tiles appear to be created and cached correctly on the server when i am using a server side cache but i find that when I remove my client-side cache and then return to a cached area that the server is querying my plug-in for map features rather then just using the cached tiles. When i run the the same test with the prior version of the WMS Server it is using the cached tiles correctly and not calling my plug-in for map features so this should be easy to reproduce on your end. If not i will try and provide more info or just send a test client that can hit our server.


Thanks,


Chris  



Hi, Christopher 
  
 I have tested it using latest release package and the same method with you, but I can’t find the problem about the server cache. So I want to confirm with you for some things. Whether your codes for creating your features or layers are placed at “GetMapConfigurationCore” method of your plug-in? If so, I guess you mean that the “GetMapConfigurationCore” method will be called more than once and so that you think the server-side cache is not getting hit. This situation is normal and it’s not a issue.  
 In fact, this is the biggest improvement for the latest version of WMS Server Edition. We will cache multiple MapConfiguration that depend on the requests come from client-side at the same time. So that we can make full use of the multiple CPU resources. 
  
 If I misunderstand your meaning please correct me. 
  
 Thanks, 
  
 Khalil

No it’s the GetMapCore method that is being called even when tiles for that area have already been cached on the server side. This is where the feature source gets set. Then the  GetFeaturesInsideBoundingBoxCore is still getting called for each layer for the area that has already been cached. With the previous version of the server this method only gets called when when an uncached area is requested. I have a meeting to go to but i am going to get some more info for you afterwards.

Khalil, I have put a zipped client app up on our ftp directory which will connect to the latest version of our server - you can also connect remotely to the server using the same ip in the URL in the sample app with the username and password which is specified in the comments. You will see on the server that tiles are being stored in C:\BitmapTileCache   and there is a log being written out to C:\WMSServerLogs where every time the data gets loaded it records how long it took to load all of the data and this means that GetFeaturesInsideBoundingBoxCore has been called . I think you will be able to see that the cached tiles aren’t being used. I have also included one source file called RTSMap where you can see what is going on in the plug-in methods. I think due to the complexity of what is going on if i can give you guys a little bit more visibility into my server that may help to diagnose things. Actually i am also going to post the source code in my plug-in module just in case you have an issue pulling down the unzipped source code file. 
  
 Thanks, 
 Chris

Here is the source code in my plug-in module - this might help to make it a little clearer what i am doing thought it wont help much in reproducing the issue. It would surprise me though if the server side cache was working for you since i don’t think i am doing anything unusual as far as how i am using it. 
  
 using System; 
 using System.Web; 
 using System.Web.Caching; 
 using System.Threading; 
 using System.IO
 using System.Text; 
 using System.Collections.ObjectModel; 
 using System.Collections.Specialized; 
 using System.Drawing; 
 using System.Collections.Generic; 
 using ThinkGeo.MapSuite.Core; 
 using ThinkGeo.MapSuite.WmsServerEdition; 
 using UPSLT.RTS.Server.RoadNetwork.Data; 
 using UPSLT.Base.Spatial; 
  
 namespace RTSPlugin { 
  
     public class RTSMap : WmsLayerPlugin 
     { 
  
         private static NetworkDataStore _cachedDataStore = new NetworkDataStore(@“C:\Maps\TANA2009.6RN8”); 
         private static bool initialized = false; 
  
         private static RTSMapLog _mapLog = new RTSMapLog(); 
         private static Dictionary<string, Feature> _featureCache = new Dictionary<string, Feature>(); 
  
         public RTSMap() 
         { 
             RTSMapLog mapLog = new RTSMapLog(); 
             mapLog.Log(@"C:\WMSServerLogs&#34;, “Initializing…”); 
             /* 
             if (!initialized) 
             { 
                 _cachedDataStore.Initialize(); 
                 initialized = true; 
                 RTSMapLog mapLog = new RTSMapLog(); 
                 mapLog.Log(@"C:\WMSServerLogs&#34;, “Initializing…”); 
             } 
             */ 
         } 
  
         protected static void CacheItemRemoved(string key, object o, CacheItemRemovedReason reason) 
         { 
             RTSDataStore removedDataStore = (RTSDataStore)o; 
             removedDataStore.ClearFeatureCollections(); 
             removedDataStore = null; 
         } 
  
         protected override MapConfiguration GetMapConfigurationCore(string style, string crs) 
         { 
             MapConfiguration mapConfiguration = new MapConfiguration(); 
             mapConfiguration.TileCache = new FileBitmapTileCache(@“C:\BitmapTileCache”); 
              
             switch (style) 
             { 
                 case “DEFAULT”: 
                     AddDefaultLayers(mapConfiguration.Layers, RTSMapInitialization.StyleType.Default); 
                     mapConfiguration.TileCache.TileAccessMode = TileAccessMode.ReadOnly; 
                     break; 
  
                 case “SATELLITE”: 
                     AddSatelliteLayers(mapConfiguration.Layers, RTSMapInitialization.StyleType.Satellite); 
                     mapConfiguration.TileCache.TileAccessMode = TileAccessMode.ReadOnly; 
                     break; 
  
                 case “CACHE”: 
                     AddDefaultLayers(mapConfiguration.Layers, RTSMapInitialization.StyleType.Cached); 
                     mapConfiguration.TileCache.TileAccessMode = TileAccessMode.ReadAddDelete; 
                     break; 
  
                 default: 
                     AddDefaultLayers(mapConfiguration.Layers, RTSMapInitialization.StyleType.Default); 
                     mapConfiguration.TileCache.TileAccessMode = TileAccessMode.ReadOnly; 
                     break; 
             } 
  
             return mapConfiguration; 
         } 
  
  
         protected override Bitmap GetMapCore(GetMapRequest getMapRequest, MapConfiguration mapConfiguration, HttpContext context) 
         { 
            DateTime startTime = DateTime.Now; 
  
            RTSMapLog mapLog = new RTSMapLog(); 
                        
            NameValueCollection queryString = context.Request.QueryString; 
            string mapExtentKey = queryString[“MapExtent”]; 
                         
              
            if (mapExtentKey == null) 
            { 
                mapExtentKey = new RectangleShape(-123.097872617701, 44.6638374044447,  
                                                  -122.324772617701, 43.8907374044447).GetWellKnownText(); 
                //mapExtentKey = new RectangleShape(-76.615411, 39.295277, -76.610031, 39.29167).GetWellKnownText(); 
            } 
  
  
            RTSDataStore dataStore; 
            //MapConfiguration configuration = new MapConfiguration(); 
             
  
            switch (getMapRequest.Styles[0]) 
            { 
                case “DEFAULT”: 
                    //configuration.TileCache = mapConfiguration.TileCache; 
                    dataStore = GetMapRequestDataStore(mapExtentKey, context, RTSMapInitialization.StyleType.Default); 
                    //AddDefaultLayers(configuration.Layers, dataStore, RTSMapInitialization.StyleType.Default); 
                    SetDataStoreForAllLayers(dataStore, mapConfiguration.Layers); 
                    break; 
  
                case “SATELLITE”: 
                    dataStore = GetMapRequestDataStore(mapExtentKey, context, RTSMapInitialization.StyleType.Satellite); 
                    //AddSatelliteLayers(configuration.Layers, dataStore); 
                    SetDataStoreForAllLayers(dataStore, mapConfiguration.Layers); 
                    break; 
  
                case “CACHE”: 
                    //configuration.TileCache = mapConfiguration.TileCache; 
                    dataStore = GetMapRequestDataStore(mapExtentKey, context, RTSMapInitialization.StyleType.Cached); 
                    //AddDefaultLayers(configuration.Layers, /* dataStore,*/ RTSMapInitialization.StyleType.Cached); 
                    SetDataStoreForAllLayers(dataStore, mapConfiguration.Layers); 
                    break; 
  
                default: 
                    dataStore = GetMapRequestDataStore(mapExtentKey, context, RTSMapInitialization.StyleType.Default); 
                    //AddDefaultLayers(configuration.Layers, dataStore, RTSMapInitialization.StyleType.Default); 
                    SetDataStoreForAllLayers(dataStore, mapConfiguration.Layers); 
                    break; 
            } 
             
            Bitmap tileBitmap = base.GetMapCore(getMapRequest, mapConfiguration /*configuration*/, context); 
  
            DateTime endTime = DateTime.Now; 
            TimeSpan duration = endTime.Subtract(startTime); 
            int timeInMS = (duration .Seconds * 1000) + duration .Milliseconds; 
  
            mapLog.Log(@"C:\WMSServerLogs&#34;, "Total Rendering Time: " + timeInMS.ToString()); 
  
            return tileBitmap; 
  
         } 
  
         protected override RectangleShape GetBoundingBoxCore(string crs) 
         { 
             Proj4Projection proj4 = new Proj4Projection(); 
             proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
             proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
  
             proj4.Open(); 
             //Vertex llPoint = proj4.ConvertToExternalProjection(-76.615411, 39.29167); 
             //Vertex urPoint = proj4.ConvertToExternalProjection(-76.610031, 39.295277); 
             // -123.097872617701, 44.6638374044447, -122.324772617701, 43.8907374044447  
             Vertex llPoint = proj4.ConvertToExternalProjection(-123.097872617701, 43.8907374044447); 
             Vertex urPoint = proj4.ConvertToExternalProjection(-122.324772617701, 44.6638374044447); 
             proj4.Close(); 
  
             RectangleShape mapBounds = new RectangleShape(llPoint.X, urPoint.Y, 
                                                           urPoint.X, llPoint.Y); 
             return mapBounds; 
         } 
  
          
         protected override Collection<WmsLayerStyle> GetStylesCore() 
         { 
             Collection<WmsLayerStyle> styles = new Collection<WmsLayerStyle>(); 
             styles.Add(new WmsLayerStyle(“DEFAULT”)); 
             styles.Add(new WmsLayerStyle(“SATELLITE”)); 
             styles.Add(new WmsLayerStyle(“CACHE”)); 
             return styles; 
         } 
  
         protected override Collection<string> GetProjectionsCore() 
         { 
             Collection<string> projections = new Collection<string>(); 
             projections.Add(“EPSG:4326”); 
             projections.Add(“EPSG:900913”); 
             return projections; 
         } 
  
         protected override GeographyUnit GetGeographyUnitCore(string projectionName) 
         { 
             return GeographyUnit.Meter; 
         } 
  
         protected override string GetNameCore() 
         { 
             return GetType().Name; 
         } 
  
         private Proj4Projection CreateMercatorProjection() 
         { 
             Proj4Projection proj4 = new Proj4Projection(); 
             proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
             proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
             return proj4; 
         } 
  
  
  
         private static RTSDataStore GetMapRequestDataStore(string mapExtentKey, HttpContext context, 
                                                            RTSMapInitialization.StyleType style) 
         { 
  
             int cacheExpiration = 20; 
  
             RTSDataStore dataStore; 
             if (context.Cache[mapExtentKey] != null) 
             { 
                 dataStore = (RTSDataStore)context.Cache[mapExtentKey]; 
             } 
             else 
             { 
                 RectangleShape mapExtent = new RectangleShape(mapExtentKey); 
                 if (style == RTSMapInitialization.StyleType.Cached) mapExtent.ScaleUp(0); 
                 else mapExtent.ScaleUp(80); 
  
                 dataStore = new RTSDataStore(_cachedDataStore, mapExtent, style); 
  
                 // need more time for pre-rendered tiles 
                 if (style == RTSMapInitialization.StyleType.Cached) cacheExpiration = 30; 
  
                 try 
                 { 
                     // TODO - reset cache expiration to 20 seconds 
                     CacheItemRemovedCallback cacheItemRemoveCallback = new CacheItemRemovedCallback(CacheItemRemoved); 
                     context.Cache.Add(mapExtentKey, dataStore, null, DateTime.Now.AddSeconds(cacheExpiration), 
                                       TimeSpan.Zero, CacheItemPriority.Default, cacheItemRemoveCallback); 
                 } 
                 catch (System.Exception e) 
                 { 
                     dataStore = (RTSDataStore)context.Cache[mapExtentKey]; 
                 } 
             } 
  
             return dataStore; 
  
         } 
  
         private RTSDataStore GetLegacyDataStore(RectangleShape mapExtent) 
         { 
             RTSDataStore dataStore = new RTSDataStore(_cachedDataStore, mapExtent, RTSMapInitialization.StyleType.Default); 
             return dataStore; 
         } 
  
  
         private void AddDefaultLayers(GeoCollection<Layer> layers, RTSDataStore dataStore, RTSMapInitialization.StyleType style) 
         { 
              
             InMemoryFeatureLayer outerZoomLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”, dataStore); 
             InMemoryFeatureLayer highwayShieldLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”, dataStore); 
             InMemoryFeatureLayer outerZoomLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”, dataStore); 
             InMemoryFeatureLayer highwayShieldLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”, dataStore); 
             InMemoryFeatureLayer outerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “OUTERZOOMLEVEL2”, dataStore); 
             InMemoryFeatureLayer innerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL2”, dataStore); 
             InMemoryFeatureLayer innerZoomLevel3Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL3”, dataStore); 
  
  
             InMemoryFeatureLayer polygonDetail0Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL0”, dataStore); 
             InMemoryFeatureLayer polygonDetail1Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL1”, dataStore); 
             InMemoryFeatureLayer polygonDetail2Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL2”, dataStore); 
             InMemoryFeatureLayer polygonDetail3Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL3”, dataStore); 
             InMemoryFeatureLayer polygonDetail4Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL4”, dataStore);       
  
             Proj4Projection proj4 = new Proj4Projection(); 
             proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
             proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
             innerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel1Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel0Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel1Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel0Layer.FeatureSource.Projection = proj4; 
             polygonDetail0Layer.FeatureSource.Projection = proj4; 
             polygonDetail1Layer.FeatureSource.Projection = proj4; 
             polygonDetail2Layer.FeatureSource.Projection = proj4; 
             polygonDetail3Layer.FeatureSource.Projection = proj4; 
             polygonDetail4Layer.FeatureSource.Projection = proj4; 
  
             RTSMapInitialization.InitializeDetailLevel0(outerZoomLevel0Layer, style); 
             RTSMapInitialization.InitializeHwyShieldLevel0(highwayShieldLevel0Layer, style); 
             RTSMapInitialization.InitializeDetailLevel1(outerZoomLevel1Layer, RTSMapInitialization.StyleType.Default); 
             RTSMapInitialization.InitializeHwyShieldLevel1(highwayShieldLevel1Layer, style); 
             RTSMapInitialization.InitializeOuterZoomDetailLevel2(outerZoomLevel2Layer, RTSMapInitialization.StyleType.Default); 
             RTSMapInitialization.InitializeInnerZoomDetailLevel2(innerZoomLevel2Layer, RTSMapInitialization.StyleType.Default); 
             RTSMapInitialization.InitializePolygonLevels(polygonDetail0Layer, polygonDetail1Layer, 
                                                          polygonDetail2Layer, polygonDetail3Layer, 
                                                          polygonDetail4Layer, style); 
  
  
             layers.Add(polygonDetail0Layer); 
             layers.Add(polygonDetail1Layer); 
             layers.Add(polygonDetail2Layer); 
             layers.Add(polygonDetail3Layer); 
             layers.Add(polygonDetail4Layer); 
             layers.Add(innerZoomLevel2Layer); 
             layers.Add(outerZoomLevel2Layer); 
             layers.Add(outerZoomLevel1Layer); 
             layers.Add(outerZoomLevel0Layer); 
             layers.Add(highwayShieldLevel1Layer); 
             layers.Add(highwayShieldLevel0Layer); 
  
         } 
  
         private void AddDefaultLayers(GeoCollection<Layer> layers, RTSMapInitialization.StyleType style) 
         { 
  
             InMemoryFeatureLayer outerZoomLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”); 
             InMemoryFeatureLayer highwayShieldLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”); 
             InMemoryFeatureLayer outerZoomLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”); 
             InMemoryFeatureLayer highwayShieldLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”); 
             InMemoryFeatureLayer outerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “OUTERZOOMLEVEL2”); 
             InMemoryFeatureLayer innerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL2”); 
             InMemoryFeatureLayer innerZoomLevel3Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL3”); 
  
  
             InMemoryFeatureLayer polygonDetail0Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL0”); 
             InMemoryFeatureLayer polygonDetail1Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL1”); 
             InMemoryFeatureLayer polygonDetail2Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL2”); 
             InMemoryFeatureLayer polygonDetail3Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL3”); 
             InMemoryFeatureLayer polygonDetail4Layer = new RTSFeatureLayer(FeatureType.Polygons, “LEVEL4”); 
  
  
             Proj4Projection proj4 = new Proj4Projection(); 
             proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
             proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
             innerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel1Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel0Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel1Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel0Layer.FeatureSource.Projection = proj4; 
             polygonDetail0Layer.FeatureSource.Projection = proj4; 
             polygonDetail1Layer.FeatureSource.Projection = proj4; 
             polygonDetail2Layer.FeatureSource.Projection = proj4; 
             polygonDetail3Layer.FeatureSource.Projection = proj4; 
             polygonDetail4Layer.FeatureSource.Projection = proj4; 
  
             RTSMapInitialization.InitializeDetailLevel0(outerZoomLevel0Layer, style); 
             RTSMapInitialization.InitializeHwyShieldLevel0(highwayShieldLevel0Layer, style); 
             RTSMapInitialization.InitializeDetailLevel1(outerZoomLevel1Layer, style); 
             RTSMapInitialization.InitializeHwyShieldLevel1(highwayShieldLevel1Layer, style); 
             RTSMapInitialization.InitializeOuterZoomDetailLevel2(outerZoomLevel2Layer, style); 
             RTSMapInitialization.InitializeInnerZoomDetailLevel2(innerZoomLevel2Layer, style); 
             RTSMapInitialization.InitializePolygonLevels(polygonDetail0Layer, polygonDetail1Layer, 
                                                          polygonDetail2Layer, polygonDetail3Layer, 
                                                          polygonDetail4Layer, style); 
  
             layers.Add(polygonDetail0Layer); 
             layers.Add(polygonDetail1Layer); 
             layers.Add(polygonDetail2Layer); 
             layers.Add(polygonDetail3Layer); 
             layers.Add(polygonDetail4Layer); 
             layers.Add(innerZoomLevel2Layer); 
             layers.Add(outerZoomLevel2Layer); 
             layers.Add(outerZoomLevel1Layer); 
             layers.Add(outerZoomLevel0Layer); 
             layers.Add(highwayShieldLevel1Layer); 
             layers.Add(highwayShieldLevel0Layer); 
  
         } 
  
         private void AddSatelliteLayers(GeoCollection<Layer> layers, RTSMapInitialization.StyleType style) 
         { 
  
             InMemoryFeatureLayer outerZoomLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”); 
             InMemoryFeatureLayer highwayShieldLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”); 
             InMemoryFeatureLayer outerZoomLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”); 
             InMemoryFeatureLayer highwayShieldLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”); 
             InMemoryFeatureLayer outerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “OUTERZOOMLEVEL2”); 
             InMemoryFeatureLayer innerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL2”); 
             InMemoryFeatureLayer innerZoomLevel3Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL3”); 
  
  
             Proj4Projection proj4 = new Proj4Projection(); 
             proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
             proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
             innerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel1Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel0Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel1Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel0Layer.FeatureSource.Projection = proj4; 
  
  
             RTSMapInitialization.InitializeDetailLevel0(outerZoomLevel0Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeHwyShieldLevel0(highwayShieldLevel0Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeDetailLevel1(outerZoomLevel1Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeHwyShieldLevel1(highwayShieldLevel1Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeOuterZoomDetailLevel2(outerZoomLevel2Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeInnerZoomDetailLevel2(innerZoomLevel2Layer, RTSMapInitialization.StyleType.Satellite); 
  
             layers.Add(innerZoomLevel2Layer); 
             layers.Add(outerZoomLevel2Layer); 
             layers.Add(outerZoomLevel1Layer); 
             layers.Add(outerZoomLevel0Layer); 
             layers.Add(highwayShieldLevel1Layer); 
             layers.Add(highwayShieldLevel0Layer); 
  
         } 
  
         private void AddSatelliteLayers(GeoCollection<Layer> layers, RTSDataStore dataStore) 
         {  
              
             InMemoryFeatureLayer outerZoomLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”, dataStore); 
             InMemoryFeatureLayer highwayShieldLevel0Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL0”, dataStore); 
             InMemoryFeatureLayer outerZoomLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”, dataStore); 
             InMemoryFeatureLayer highwayShieldLevel1Layer = new RTSFeatureLayer(FeatureType.Streets, “LEVEL1”, dataStore); 
             InMemoryFeatureLayer outerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “OUTERZOOMLEVEL2”, dataStore); 
             InMemoryFeatureLayer innerZoomLevel2Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL2”, dataStore); 
             InMemoryFeatureLayer innerZoomLevel3Layer = new RTSFeatureLayer(FeatureType.Streets, “INNERZOOMLEVEL3”, dataStore); 
  
              
             Proj4Projection proj4 = new Proj4Projection(); 
             proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); 
             proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); 
             innerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel2Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel1Layer.FeatureSource.Projection = proj4; 
             outerZoomLevel0Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel1Layer.FeatureSource.Projection = proj4; 
             highwayShieldLevel0Layer.FeatureSource.Projection = proj4; 
  
  
             RTSMapInitialization.InitializeDetailLevel0(outerZoomLevel0Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeHwyShieldLevel0(highwayShieldLevel0Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeDetailLevel1(outerZoomLevel1Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeHwyShieldLevel1(highwayShieldLevel1Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeOuterZoomDetailLevel2(outerZoomLevel2Layer, RTSMapInitialization.StyleType.Satellite); 
             RTSMapInitialization.InitializeInnerZoomDetailLevel2(innerZoomLevel2Layer, RTSMapInitialization.StyleType.Satellite); 
              
             layers.Add(innerZoomLevel2Layer); 
             layers.Add(outerZoomLevel2Layer); 
             layers.Add(outerZoomLevel1Layer); 
             layers.Add(outerZoomLevel0Layer); 
             layers.Add(highwayShieldLevel1Layer); 
             layers.Add(highwayShieldLevel0Layer); 
  
         } 
  
         private void SetDataStoreForAllLayers(RTSDataStore dataStore, GeoCollection<Layer> layers) 
         { 
             foreach (RTSFeatureLayer layer in layers) 
             { 
                 ((RTSFeatureSource)layer.RTSFeatureSource).DataStore = dataStore; 
             } 
         } 
  
  
     } 
 } 


Christopher,


Thanks for your information about this post.


I don't know how to connect to your ftp directry to get the zipped client app, please provide me with the ftp url, also the username and password if necessary.


For the GetMapCore method, if you have overrided this method and it will be called no matter whether the tiles cache exists, the logic for generating tile image on the fly or get the tile images from cache is placed in this method.


For the Server Cache, maybe I need to clarify some things about it and make you understand how it works. In the GetMapCore method of base WmsLayerPlugin class, first off, we will check whether user has set the TileCache, if TileCache objext is not null, and then we will continue to check whether the tile cache images exist in the physical disk, and if not the render logic for the layers of MapConfiguration will be called, and so the  GetFeaturesInsideBoundingBoxCore will be called.


As for the source code of your plug-in module, and  I noticed that you didn't set the cache id for the TileCache of MapConfiguration in the GetMapConfigurationCore method. We will check whether the tile image exists depend on this property. Maybe this is the problem. If it's not set, and we will assign a GUID to it randomly. So that if there exists more than one MapConfiguration and they have different cache ids, so that the render logic is still getting called.  I suggest you set it as a fixed value and give it a try.


Also, I have tried to use the DisplayASimpleMapWmsLayerPlugin to have a test. First off I generate the tile cache for the higher 5 zoom levels, and in order to see whether it will generate the tile image for the cached area, and I create a TempShapeFileFeatureLayer that inherits from ShapeFileFeatureLayer and only override the DrawCore method, also add some debug information. Please refer to the codes below:




protected override MapConfiguration GetMapConfigurationCore(string style, string crs)
{
    // Get the directory to the sample data
    string worldLayerFilePath = Directory.GetParent(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).FullName).FullName + "\\SampleData\\Countries02.shp";

    // Create the world layer from a shapefile and add a style to it
    TempShapeFileFeatureLayer worldLayer = new TempShapeFileFeatureLayer(worldLayerFilePath);
    worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
    worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

    // Create a MapConfiguration and add the layer to it
    MapConfiguration mapConfiguration = new MapConfiguration();
    mapConfiguration.Layers.Add("WorldLayer", worldLayer);
    // Add TileCache object to MapConfiguration
    mapConfiguration.TileCache = new FileBitmapTileCache(@"C:\TEMP", "WorldLayerCache");
    return mapConfiguration;
}



    public class TempShapeFileFeatureLayer : ShapeFileFeatureLayer
    {
        public TempShapeFileFeatureLayer(string shapePathFilename)
            : base(shapePathFilename)
        {

        }

        protected override void DrawCore(GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
        {
            base.DrawCore(canvas, labelsInAllLayers);
            System.Diagnostics.Debug.WriteLine("TempShapeFileFeatureLayer DrawCore");
        }
    }


Please let us know if you have any questions.


Thanks,


Khalil



Khalil - you are correct the problem was that i was not setting the Cache ID - it appears to be working with that change. 
  
 Just for future reference i was refering to a directory we have on your ftp site - so you should be able to access stuff i put out there. 
  
 Thanks for your help on this - initially we weren’t even going to use the server side tile caching until i found that people were insisting on google like performance, and there doesn’t seem to be any substitute for using server side tile caching to deliver that. 
  
 Since you did  so well with this one i have another issue/question about the server i’m going to post that you might be able to help me understand better.  
  


Hi Khalil, 
  
 Another thing i’ve noticed with the server side cache is that the tiles are still getting created and cached when the Tile Access mode is set to read-only. 
  
 So i am running a client that is using the DEFAULT map style. This style is using a tile cache with the tile access mode set to Read-Only as you can see in the code i’ve posted, but tiles are still being created and stored on the server. 
  
  


Hi, Christopher 
  
 Thanks for your post and questions. I have tested it and this problem does exist. 
 Anyway, we have fixed this issue and it should be available in the latest Daily Build(4.0.101.0 or later). Please get it through  
 helpdesk.thinkgeo.com/helpdesk/login.aspx
  
 Please let me know if you have any questions. 
  
 Thanks, 
  
 Khalil