摘要
在现有地图或影像服务缓存中创建和更新切片。此工具用于创建新切片、恢复缺失切片、覆盖过时切片以及删除切片。
用法
- 使用此工具前请确保已为地图服务定义的切片方案。可使用服务编辑器 窗口中的缓存 选项卡或创建地图服务器缓存工具来创建切片方案。
对于涉及较大地理范围或较大地图比例的缓存,此工具可能会需要较长的运行时间。如果取消此工具,将停止切片创建,但不删除现有切片。这意味着在您在时间不够时可以先取消此工具,以后再使用 RECREATE_EMPTY_TILES 更新模式在同一缓存上重新运行此工具。
语法
ManageMapServerCacheTiles_server (input_service, scales, update_mode, {num_of_caching_service_instances}, {area_of_interest}, {update_extent}, {wait_for_job_completion})
参数 | 说明 | 数据类型 |
input_service | 待更新缓存切片所属的地图或影像服务。 这是一个包含服务器和服务器信息的字符串。要查看构建此字符串的方法,请打开 ArcCatalog,选择“目录”树中的服务,并注意位置 工具条中的文本。然后将反斜线改为正斜线,例如,MYSERVER (admin)/USA.MapServer 上的 GIS Servers/arcgis。 | String |
scales | 一系列比例级别,运行此工具时将在这些比例级别上创建或删除切片(具体要取决于更新模式)。 | Double |
update_mode | 缓存的更新模式。
| String |
num_of_caching_service_instances (可选) |
专用于运行该工具的系统/缓存工具服务实例的总数。您可以通过与 ArcGIS Server 的管理连接,使用 服务编辑器 窗口,增加系统/缓存工具服务的每台计算机的最大实例数。确保您的服务器计算机可以支持所选数量的实例。 | Long |
area_of_interest (可选) | 定义感兴趣区以对将创建或删除的切片进行约束。它可能是一个要素类,也可能是在 ArcMap 中以交互方式定义的要素。该参数用于为形状不规则的区域管理切片。它对您要对某些区域进行预缓存或让较少访问的区域保持未缓存的状态等情形也同样有用。 若未提供该参数的值,则会默认使用地图的全图范围。 | Feature Set |
update_extent (可选) | 创建或删除切片时所参照的矩形范围,具体取决于 update_mode 参数的值。建议不要同时提供 update_extent 和 area_of_interest 两个参数的值。如果同时提供了这两个参数的值,则会使用 area_of_interest 的值。 | Extent |
wait_for_job_completion (可选) | 可以通过该参数查看在服务器上运行的缓存作业的进度。
| Boolean |
代码示例
示例 1使用 RECREATE_ALL_TILES 选项在缓存中创建或更新所有切片
# Name: ManageMapServerCacheTiles.py
# Description: The following stand-alone script demonstrates how to Recreate all
# cache tiles for the 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
scales = [500000,250000,125000,64000]
numOfCachingServiceInstances = 2
updateMode = "RECREATE_ALL_TILES"
areaOfInterest = ""
waitForJobCompletion = "WAIT"
updateExtents = ""
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(inputService, scales,
updateMode,
numOfCachingServiceInstances,
areaOfInterest, updateExtents,
waitForJobCompletion)
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 " +\
serviceName + " in " + str(elapsedtime) + " sec 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 "
示例 2使用 RECREATE_EMPTY_TILES 选项更新部分比例的空切片
# Name: ManageMapServerCacheTiles.py
# Description: The following stand-alone script demonstrates how to Recreate
# empty tiles for one of 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
scales = [500000,250000,125000,64000]
numOfCachingServiceInstances = 2
updateMode = "RECREATE_EMPTY_TILES"
areaOfInterest = ""
waitForJobCompletion = "WAIT"
updateExtents = ""
cacheDir = "c:\\arcgisserver\\arcgiscache\\"
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')
# use "scales[0]","scales[-1]","scales[0:3]"
try:
starttime = time.clock()
result = arcpy.ManageMapServerCacheTiles_server(inputService, scales[-1],
updateMode, numOfCachingServiceInstances,
areaOfInterest, updateExtents,
waitForJobCompletion)
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 scale =" + str(scales[-1]) + "for " +\
serviceName + " at " + cacheDir + " in " + str(elapsedtime) +\
" sec 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 "Rereated Map server Cache Tiles for scale = " + str(scaleValues[-1])
示例 3使用“感兴趣区”更新切片
# Name: ManageMapServerCacheTiles.py
# Description: The following stand-alone script demonstrates how to Recreate all
# tiles using given feature class.
# Requirements: os, sys, time and traceback modules
# Author: ESRI
# 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
scales = [500000,250000,125000,64000]
numOfCachingServiceInstances = 2
updateMode = "RECREATE_ALL_TILES"
areaOfInterest = "C:/data/shp/CaTxFlMaMin.shp"
waitForJobCompletion = "WAIT"
updateExtents = ""
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')
# use "scales[0]","scales[-1]","scales[0:3]"
try:
starttime = time.clock()
result = arcpy.ManageMapServerCacheTiles_server(inputService, scales[-1],
updateMode,
numOfCachingServiceInstances,
areaOfInterest, updateExtents,
waitForJobCompletion)
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 scale =" + str(scales[-1]) + "for " +\
serviceName + "at " + cacheDir + " using specified feature class " +\
areaOfInterest + " in " + str(elapsedtime) + " sec on " + arg2
except Exception, e:
# If an error occurred, print line number and error message
tb = sys.exc_info()[2]
report.write("Failed at \n" "Line %i" % tb.tb_lineno)
report.write(e.message)
report.close()
print "Rereated Map server Cache Tiles"
print "for scale = " + str(scaleValues[-1]) + " using area of Interest"
环境
此工具不使用任何地理处理环境
许可信息
- ArcGIS Desktop Basic: 是
- ArcGIS Desktop Standard: 是
- ArcGIS Desktop Advanced: 是