管理地图服务器缓存切片 (服务器)
摘要
在现有地图服务缓存中创建和更新切片。此工具用于创建新切片、恢复缺失切片、覆盖过时切片以及删除切片。
用法
对于涉及较大地理范围或较大地图比例的缓存,此工具可能会需要较长的运行时间。如果取消此工具,将停止切片创建,但不删除现有切片。这意味着在您的可用时间不够时可以先取消此工具,以后再使用“重新创建空切片”更新模式在同一缓存上重新运行此工具。在您停止之处重新继续操作的另一种方式是,使用下面在最终参数 ignore_status 的描述中所介绍的状态追踪功能。
语法
参数 | 说明 | 数据类型 |
server_name |
用于承载待更新切片所属的地图服务的 ArcGIS Server 计算机。 | String |
object_name |
待更新缓存切片所属的地图服务。 注: 使用此工具前请确保已为地图服务定义切片方案。可使用服务属性 对话框的缓存 选项卡或“创建地图服务器缓存”工具来创建切片方案。 | String |
data_frame |
地图服务的源数据框。 | String |
Layer [Layer,...] |
要从缓存中删除的图层。 | String |
levels |
一系列比例级别,运行此工具时将在这些比例级别上创建或删除切片(具体要取决于更新模式)。 | Double |
update_mode |
选择缓存的更新模式。有三种模式可用:
| String |
constraining_extent (可选) |
创建或删除切片所依据的矩形范围,具体取决于更新模式。 | Extent |
thread_count (可选) |
运行此工具时使用的地图服务实例的数量。默认情况下,使用实例的最大允许数量(对于 ArcGIS Server 服务,其默认值是 2)。如果服务器功能更强大,则可以在服务属性 对话框中增加实例的最大允许数量,然后在运行此工具时增大此参数。 | Long |
Antialiasing (可选) |
这是一个弃用参数,将被忽略。切片方案中的抗锯齿属性决定了是否对缓存应用抗锯齿功能。 | Boolean |
update_feature_class (可选) |
您可以根据要素类的要素范围使用面要素类来管理(创建、更新或删除)切片。例如,如果您正在对一个国家/地区进行缓存,则可以提供主要城区的要素类。您这样就可以要求服务器只预先创建覆盖这些市区的切片。其余区域可以根据客户端请求按需进行缓存。这样您就不必创建不需要的乡村区域切片,从而节省了时间和磁盘空间。 | Feature Class |
ignore_status (可选) | 如果您基于要素类边界创建切片,则可使用此参数追踪缓存的状态(请参阅 update_feature_class 参数)。
| Boolean |
代码示例
此示例使用“重新创建所有切片”选项创建或更新缓存中的所有切片。
# ManageMapServerCacheTiles example (stand-alone script) # Name: ManageMapServerCacheTiles.py # Description: The following stand-alone script demonstrates how to Recreate all # cache tiles for the default number of scales in the cache tiling # scheme. # Requirements: os, sys, time and traceback modules # Any line that begins with a pound sign is a comment and will not be executed # Empty quotes take the default value. # To accept arguments from the command line replace values of variables to # "sys.argv[]" # Import system modules import arcpy from arcpy import env import os, sys, time, datetime, traceback, string # Set environment settings env.workspace = "C:/data" # List of input variables for map service properties server = "MyServer" service = "Rainfall" dataFrame = "" inputLayers = "" scaleValues = "" extents = "" updateMode = "Recreate All Tiles" antialiasing = "NONE" threadCount = "2" pathToFeatureClass = "" ignoreStatus = "IGNORE_COMPLETION_STATUS_FIELD" currentTime = datetime.datetime.now() arg1 = currentTime.strftime("%H-%M") arg2 = currentTime.strftime("%Y-%m-%d %H:%M") file = 'C:/data/report_%s.txt' % arg1 # print results of the script to a report report = open(file,'w') try: starttime = time.clock() result = arcpy.ManageMapServerCacheTiles_server(server, service, dataFrame, inputLayers, scaleValues, updateMode, extents, threadCount ,Antialiasing, pathToFeatureClass, ignoreStatus) finishtime = time.clock() elapsedtime= finishtime - starttime #print messages to a file while result.status < 4: time.sleep(0.2) resultValue = result.getMessages() report.write ("completed " + str(resultValue)) print "Created cache tiles for given schema successfully for " + service + " in " + str(elapsedtime) + " sec \n on " + arg2 except Exception, e: # If an error occurred, print line number and error message tb = sys.exc_info()[2] report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno) report.write(e.message) report.close() print "Created Map server Cache Tiles "
此示例使用“重新创建空切片”选项更新某些比例对应的空切片。
# ManageMapServerCacheTiles example (stand-alone script) # Name: ManageMapServerCacheTiles.py # Description: The following stand-alone script demonstrates how to Recreate all # cache tiles for the default number of scales in the cache tiling # scheme. # Requirements: os, sys, time and traceback modules # Any line that begins with a pound sign is a comment and will not be executed # Empty quotes take the default value. # To accept arguments from the command line replace values of variables to # "sys.argv[]" # Import system modules import arcpy from arcpy import env import os, sys, time, datetime, traceback, string # Set environment settings env.workspace = "C:/data" # List of input variables for map service properties server = "MyServer" service = "Rainfall" dataFrame = "" inputLayers = "" scaleValues = "" extents = "" updateMode = "Recreate All Tiles" antialiasing = "NONE" threadCount = "2" pathToFeatureClass = "" ignoreStatus = "IGNORE_COMPLETION_STATUS_FIELD" currentTime = datetime.datetime.now() arg1 = currentTime.strftime("%H-%M") arg2 = currentTime.strftime("%Y-%m-%d %H:%M") file = 'C:/data/report_%s.txt' % arg1 # print results of the script to a report report = open(file,'w') try: starttime = time.clock() result = arcpy.ManageMapServerCacheTiles_server(server, service, dataFrame, inputLayers, scaleValues, updateMode, extents, threadCount ,Antialiasing, pathToFeatureClass, ignoreStatus) finishtime = time.clock() elapsedtime= finishtime - starttime #print messages to a file while result.status < 4: time.sleep(0.2) resultValue = result.getMessages() report.write ("completed " + str(resultValue)) print "Created cache tiles for given schema successfully for " + service + " in " + str(elapsedtime) + " sec \n on " + arg2 except Exception, e: # If an error occurred, print line number and error message tb = sys.exc_info()[2] report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno) report.write(e.message) report.close() print "Created Map server Cache Tiles "
此示例将切片的更新限制在要素类边界。
# ManageMapServerCacheTiles example (stand-alone script) # Name: ManageMapServerCacheTiles.py # Description: The following stand-alone script demonstrates how to Recreate all # cache tiles for the default number of scales in the cache tiling # scheme. # Requirements: os, sys, time and traceback modules # Any line that begins with a pound sign is a comment and will not be executed # Empty quotes take the default value. # To accept arguments from the command line replace values of variables to # "sys.argv[]" # Import system modules import arcpy from arcpy import env import os, sys, time, datetime, traceback, string # Set environment settings env.workspace = "C:/data" # List of input variables for map service properties server = "MyServer" service = "Rainfall" dataFrame = "" inputLayers = "" scaleValues = "" extents = "" updateMode = "Recreate All Tiles" antialiasing = "NONE" threadCount = "2" pathToFeatureClass = "" ignoreStatus = "IGNORE_COMPLETION_STATUS_FIELD" currentTime = datetime.datetime.now() arg1 = currentTime.strftime("%H-%M") arg2 = currentTime.strftime("%Y-%m-%d %H:%M") file = 'C:/data/report_%s.txt' % arg1 # print results of the script to a report report = open(file,'w') try: starttime = time.clock() result = arcpy.ManageMapServerCacheTiles_server(server, service, dataFrame, inputLayers, scaleValues, updateMode, extents, threadCount ,Antialiasing, pathToFeatureClass, ignoreStatus) finishtime = time.clock() elapsedtime= finishtime - starttime #print messages to a file while result.status < 4: time.sleep(0.2) resultValue = result.getMessages() report.write ("completed " + str(resultValue)) print "Created cache tiles for given schema successfully for " + service + " in " + str(elapsedtime) + " sec \n on " + arg2 except Exception, e: # If an error occurred, print line number and error message tb = sys.exc_info()[2] report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno) report.write(e.message) report.close() print "Created Map server Cache Tiles "