We are currently using Map Suite MVC 8, versions 8.0.336.0.
We are using OpenStreetMap (OSM) as the base layer for our maps. We have a
number of static layers that are based on shapefile data. These seem like a
good candidate for server-side caching to supplement the client-side caching
already in place. I have been doing some testing and figured I would look into
generating the tile caches beforehand using the Cache Generator tool ThinkGeo
has provided. Unfortunately, I am having some issues using it. Before I go into
specifics, I have several general questions regarding the Cache Generator and
its use.
Note: Our maps
use a default extent defined as “DefaultExtent = new
RectangleShape(-80.4014, 40.7301, -79.5431, 40.1972);” that then gets projected to the OSM projection of EPSG 3857 since our maps our using OSM for the base layer. I am using
in place of the values in the Cache Generator form’s textboxes.
- Since we are using OSM we are projecting all our data in our
project. Should the extent in the Cache
Generator be projected to the OSM projection (EPSG: 3857)? I tried doing this
and am not getting the expected results. - Our shapefiles use NAD83 and NAD27 projections. Should I be projecting the layers when I set
them up in the Cache Generator to the projection of the base map layer(EPSG: 3857)? Again, I am not getting the expected results
from doing this. - What is the source of the OSM Overlay and OSM Layers data? I
know ThinkGeo has their own OSM Server that you update weekly, but I do not
know if the OSM Overlay/Layer request from this server or the OSM servers in the MVC Edition. This
relates to my following question. - Is it possible to generate the tile cache for the OSM layer,
and if so would we see a performance benefit in doing so? I am not certain, but
it seems like this layer is taking the longest to render on our maps. We could
always periodically dump and regenerate the cache for this layer to account for
the changing nature of OSM data. - Can you explain the directory structure and naming for the
tiles generated? It looks to be related to the tile coordinates, but I cannot quite figure it out.
I have been doing some testing with enabling server-side
caching on our project’s maps. A number of our map layers are based on static
data, or data that gets updated biannually at most. I figured that these would
be good candidates for server-side caching in addition to the client-side
caching already implemented. That seems
to be working in my limited testing, and I figured that I would go ahead and
look into pregenerating the tiles using the Cache Generator tool. Unfortunately I am finding that the cached
tiles generated from the utility and those generated from our maps are not the
same. The directory structure is not the same either which leads me to believe that something is wrong with the tile coordinates. I am using one layer for testing, with our default extent as I listed above, and limited to ZoomLevel11 to simplify things.
Here is the code
being used to setup the layer in our project:
private
LayerOverlay SetupZipCodeOverlay(
bool
visible,
bool
visibleInOverlaySwitcher)
{
string
overlayID =
“zipCodes”
, overlayName =
“ZIP Codes”
, fileName =
“Zips.shp”
, layerKey =
“zipCodes”
;
TextStyle textStyle =
new
TextStyle(
“ZIP”
, DefaultAreaFeatureFont,
new
GeoSolidBrush(GeoColor.StandardColors.Red));
//Setup Overlay to hold and display our data
LayerOverlay zipsOverlay =
new
LayerOverlay(overlayID,
false
, TileType.MultipleTile);
//Set the Overlay’s name, which will be displayed in the Overlay Switcher.
zipsOverlay.Name = overlayName;
//Load the features from the shapefile
ShapeFileFeatureLayer zipsLayer =
new
ShapeFileFeatureLayer(GeoDataDirectory + fileName);
//Setup Styles determining how the layer will be displayed
//Display the data from the shapefile, with each feature defined in the file outlined on the map
zipsLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.StandardColors.Red);
//Label features as defined in a column value in the .dbf file associated with the shapefile, located in the center of the feature by default
zipsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = textStyle;
//Setup layer to apply the styles used to all zoom levels, consider revising or creating custom zoom levels in the future if client desires
zipsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//Apply projection to layer, the projection must be opened before this is done and should be closed afterwards
try
{
NAD83toSphMercator.Open();
zipsLayer.FeatureSource.Projection = NAD83toSphMercator;
}
finally
{
NAD83toSphMercator.Close();
}
//Add our layer to the overlay, apply caching to the overlay, set visibility, and return the constructed overlay
zipsOverlay.Layers.Add(layerKey, zipsLayer);
zipsOverlay.ClientCache = MapClientCache;
zipsOverlay.IsVisible = visible;
zipsOverlay.IsVisibleInOverlaySwitcher = visibleInOverlaySwitcher;
return
zipsOverlay;
}
Here is the code I am using to try to setup the layer in the Cache Generator, which I then add to the layersToCache Collection:
public
static
ShapeFileFeatureLayer SetupZonesLayer()
{
string
fileName =
“Zones.shp”
;
TextStyle textStyle =
new
TextStyle(
“ZONE_NAME”
, DefaultAreaFeatureFont,
new
GeoSolidBrush(GeoColor.StandardColors.Blue));
//Load the features from the shapefile
ShapeFileFeatureLayer zonesLayer =
new
ShapeFileFeatureLayer(@
"…\GeoData"
+ fileName);
//Display the data from the shapefile, with each feature defined in the file outlined on the map
zonesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.StandardColors.Blue);
//Label features as defined in a column value in the .dbf file associated with the shapefile, located in the center of the feature by default
zonesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = textStyle;
//Setup layer to apply the styles used to all zoom levels, consider revising or creating custom zoom levels in the future if client desires
zonesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//Apply projection to layer, the projection must be opened before this is done and should be closed afterwards
try
{
Debug.WriteLine(
"Zones ZoomLevel11 Scale: "
+ zonesLayer.ZoomLevelSet.ZoomLevel11.Scale);
NAD27toSphMercator.Open();
zonesLayer.FeatureSource.Projection = NAD27toSphMercator;
}
catch
(Exception e)
{
Debug.WriteLine(e.Message);
}
finally
{
NAD27toSphMercator.Close();
}
return
zonesLayer;
}