描述
在现有 Web 切片图层缓存(在 ArcGIS Enterprise 或 ArcGIS Online 中)、ArcGIS Enterprise 中的 Web 地图影像图层和独立服务器中的缓存地图或影像服务中创建和更新切片。 此工具用于创建新切片、恢复缺失切片、覆盖过时切片以及删除切片。
使用方法
对于涉及较大地理范围或较大地图比例的缓存,此工具可能会需要较长的运行时间。 如果取消此工具,将停止切片创建,但不删除现有切片。 这意味着,如果您的时间不足,可以先取消工具,随后再通过将更新模式参数设置为重新创建空切片(Python 中的 update_mode = "RECREATE_EMPTY_TILES"),来在同一缓存上重新运行该工具。
语法
arcpy.server.ManageMapServerCacheTiles(input_service, scales, update_mode, {num_of_caching_service_instances}, {area_of_interest}, {update_extent}, {wait_for_job_completion})
参数 | 说明 | 数据类型 |
input_service | 待更新缓存切片所属的 web 切片图层或地图影像图层。 | Image Service; MapServer |
scales [scales,...] | 运行此工具时创建或删除切片所依据的比例级别取决于 update_mode。 | Double |
update_mode | 缓存的更新模式。
| String |
num_of_caching_service_instances (可选) | 专用于运行该工具的 System/CachingTools 服务实例的总数。 您可以通过 ArcGIS Server 的管理连接,使用服务编辑器窗口,增加 System/CachingTools 服务的每台计算机的最大实例数设置。 确保您的服务器计算机可以支持所选数量的实例。 连接到独立服务器时,默认实例数等于缓存工具服务的最大实例数设置的值。 | Long |
area_of_interest (可选) | 定义感兴趣区以对将创建或删除的切片进行约束。 该参数用于为形状不规则的区域管理切片。 它对您要对某些区域进行预缓存或让较少访问的区域保持未缓存的状态等情形也同样有用。 若未提供该参数的值,则会默认使用地图的全图范围。 | Feature Set |
update_extent (可选) | 创建或删除切片所参照的矩形范围取决于 update_mode 参数的值。 建议不要同时提供 update_extent 和 area_of_interest 两个参数的值。 如果同时提供了两个参数的值,则将使用 area_of_interest 的值。 | Extent |
wait_for_job_completion (可选) | 可以通过该参数查看在 Portal 上运行的缓存作业的进度。
| Boolean |
派生输出
名称 | 说明 | 数据类型 |
out_job_url | 输出 URL。 | String |
代码示例
ManageMapServerCacheTiles 示例 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 "
ManageMapServerCacheTiles 示例 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])
ManageMapServerCacheTiles 示例 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
# 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
import os
import sys
import time
import datetime
import traceback
import string
# Set environment settings
arcpy.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"
环境
许可信息
- Basic: 是
- Standard: 是
- Advanced: 是