Select to view content in your preferred language

Map Image Layer caching process

981
2
07-23-2020 07:58 AM
by Anonymous User
Not applicable

Hey everyone,

I have created a custom State Plane basemap for use in Collector (to collect in SP coordinates) 

The basemap has 9 levels of detail, and around 500MB of tiles. When I published this to our federated server site, I used the option to have the server handle the tile caching automatically. I do not know if this is best process or not. 

There aren't too many layers in the basemap that change much (other than streets) and I am unsure how to handle the re-caching. Does the server re-cache when the map service gets recycled every night? Or are there some tools I could run via Python or Geoprocessing tab in ArcMap/ArcPro to ensure the cache on this service does not grow stale. 

Thanks for any help!

0 Kudos
2 Replies
DavidColey
Honored Contributor

So what I do is this: each week I overwrite the feature classes in my filegdb that support the map.  Now the data in the map is overwritten but the cache tiles are not.  They have to be re-created.  Using the Pro Idle, here's how that looks:

# List of input variables for map service properties
portal = arcpy.SignInToPortal("https://yourportal", "yourname", "yourpw")
env.workspace = r"\\yourserver\.....\\DataConnections\\SqlProdSp.gdb" # must be registered location
try:
 input_service = "https://......yourCacheService/MapServer"
 scales = [577790.554289,288895.277144,144447.638572,72223.819286,36111.909643] #0,1,2,3,4,5,6,7 full ext
 #scales = [9027.977411,4513.988705,2256.994353,1128.497176,564.248588] # mid ext
 #scales = [282.124294] #8,9,10,11,12,13] #,14,15 tilemapped # low ext
 update_mode = "RECREATE_ALL_TILES" # DELETE_TILES
 update_extent = "412741.7365287468 915208.8897668198 672826.0004799105 1141077.7300229892" #"XMin, YMin, XMax, YMax" stateplane
 #update_extent = "-9200240.24964 3116183.75439 -9132965.67576 3172857.76957" #"XMin, YMin, XMax, YMax" webmercator
 num_of_caching_service_instances = "-1" #14 don't need in pro
 print (scales)
 area_of_interest = ""
 wait_for_job_completion = "WAIT"
 portal_url = "https://yourportal"

result = arcpy.ManageMapServerCacheTiles_server(input_service, scales, update_mode, num_of_caching_service_instances, area_of_interest, update_extent, wait_for_job_completion,portal_url)
 
 print ("Created cache tiles for scale = " + str(scales) + " and service at " + input_service + " using the full extent") 
 message = message + "Created cache tiles for scales = " + str(scales) + " " + input_service + " using the full extent"

except Exception:
 # If an error occurred, print line number and error message
 import traceback, sys
 tb = sys.exc_info()[2]
 e = sys.exc_info()[1]
 #print(e.args[0])
 #print "Line %i" % tb.tb_lineno
 message = message + "\n" + "Line %i" % tb.tb_lineno
 message = message + "\n" + e.message‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

What I have done is set up the cache tiling scheme to use the same levels as the web mercator tile scheme, because it works so well in the field, but I can still use stateplane coord system.  The cache levels in the service go all the way down to 1:70, but I only cache to 1:564 and then use the 'tilemap' capability on the service so that the service 'maps tiles' down to the lowest level.   The 'full ext' scale array above takes like 1 minute.  The 'mid ext' scale array takes about 50 minutes on our system. I run this as 2 scripts in a scheduled task.

by Anonymous User
Not applicable

Great help David, Thanks! 

I have gotten in the habit of using Pro for just about everything now. It's just so much easier that way.