arcpy.server.ManageMapServerCacheTiles(input_service, scales, update_mode, {num_of_caching_service_instances}, {area_of_interest}, {update_extent}, {wait_for_job_completion}, {portal_url})
|
名称
|
说明
|
数据类型
|
|
input_service
|
要更新缓存切片的 Web 切片图层、web 影像图层或地图图像图层。
|
Image Service; Map Server
|
|
scales
[scales,...]
|
创建切片时使用的比例级别列表。
|
Double
|
|
update_mode
|
指定将用于更新缓存的模式。
RECREATE_EMPTY_TILES—只对空的切片重新创建。 现有切片将保持不变。 此选项不适用于发布至 ArcGIS Online 的 Web 切片图层。
RECREATE_ALL_TILES—如果范围发生改变,则需要更换现有切片并添加新切片。
DELETE_TILES—将从缓存中删除切片。 缓存文件夹结构不会删除。
|
String
|
|
num_of_caching_service_instances
(可选)
|
专用于运行该工具的 System/CachingTools 服务实例的总数。 如果使用默认值 -1,将使用 ArcGIS Enterprise 设置的所有缓存工具实例。 使用较小的值可以使用较少的缓存工具实例。
您可以使用服务编辑器窗口增加 System/CachingTools 服务的每台计算机的最大实例数设置,该窗口可通过 ArcGIS Server 的管理连接访问。 确保服务器计算机可以支持所选数量的实例。
连接到独立服务器时,默认实例数等于缓存工具服务的最大实例数设置的值。
|
Long
|
|
area_of_interest
(可选)
|
包含创建或删除切片的位置的感兴趣区域。 该参数用于管理形状不规则的区域的切片。 对某些区域进行预缓存或让较少访问的区域保持未缓存的状态时,此参数也同样有用。
若未提供该参数的值,则会默认使用地图的全图范围。
|
Feature Set
|
|
update_extent
(可选)
|
用于创建或删除切片的矩形范围,取决于 update_mode 参数的值。 如果已指定 update_extent 和 area_of_interest 参数值,则将使用 area_of_interest 值。
|
Extent
|
|
wait_for_job_completion
(可选)
|
指定当缓存作业在 ArcGIS Online 或 Portal for ArcGIS 中运行时,工具是否继续运行。
WAIT—缓存作业在 ArcGIS Online 或 Portal for ArcGIS 中运行时,工具继续运行。 使用此选项,您可以随时请求详细的进度报告并查看显示的地理处理消息。 这是默认设置。 建议在 Python 脚本中使用此选项。
DO_NOT_WAIT—工具会将作业提交至服务器,允许您执行其他地理处理任务。 在发布服务之际自动构建缓存时,请使用此选项。 还可以在您所构建的任何其他缓存中设置此选项。
|
Boolean
|
|
portal_url
(可选)
|
门户的 URL。
|
String
|
派生输出
|
名称
|
说明
|
数据类型
|
|
out_job_url
|
输出 URL。
|
String
|
代码示例
ManageMapServerCacheTiles 示例(独立脚本)
以下脚本演示如何使用感兴趣的区域为地图或影像服务重新创建所有缓存切片。
# Name: ManageMapServerCacheTiles.py
# Description: The following stand-alone script demonstrates how to Recreate all
# cache tiles for for a map or image service using an area of interest.
# This tool works for weblayers published to ArcGIS Enterprise and ArcGIS Online.
# and for map and image services on a stand alone ArcGIS Server
# Example: This sample script updates map cache tiles.
import arcpy
from arcpy import env
import sys
import time
import datetime
# Set environment settings
env.workspace = "C:/data"
# Sign in to ArcGIS Enterprise
myPortal= "https://MyPortal.domain.com/portalwebadaptor"
arcpy.SignInToPortal(myPortal, "siteadminValue", "siteadminPassword")
myServer="https://Myserver.domain.com/serverwebadaptor"
serviceName= "SampleWorldCities"
serviceType= "MapServer"
myPortalServiceURL = (myServer + "/" + "rest/services" +"/" + serviceName + "/"
+ serviceType)
### Sign in to ArcGIS Online
##myPortal= "https://www.arcgis.com"
##arcpy.SignInToPortal(myPortal, "MyUserName", "MyPassword")
##serviceRestUrl="https://www.arcgis.com/tiles/orgid"
##serviceName= "MyServiceName"
##serviceType= "MapServer"
##myPortalServiceURL = (serviceRestUrl + "/" + "arcgis/rest/services" +"/" + serviceName + "/"
## + serviceType)
# Stand alone ArcGIS Server
##target_server_connection = r"C:\share\python3\arcgis on MyServer.ags"
##serviceName= "MyServiceName"
##serviceType= ".MapServer"
##myPortalServiceURL = (target_server_connection + "\\" + serviceName + serviceType)
print (myPortalServiceURL)
#variables for reporting
currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
arg2 = currentTime.strftime("%Y-%m-%d %H:%M")
file = r'C:\test\report_%s.txt'% arg1
# List of input variables for map or image service
##scales = [591657527.591555,295828763.79577702,147914381.89788899]
scales = [73957190.948944,36978595.474472]
numOfCachingServiceInstances = 8
updateMode = "RECREATE_ALL_TILES"
areaOfInterest = ""
waitForJobCompletion = "WAIT"
updateExtents = ""
portalURL =""
# Print results of the script to a report
report = open(file,'w')
try:
result = arcpy.server.ManageMapServerCacheTiles(myPortalServiceURL, scales, updateMode,
numOfCachingServiceInstances, areaOfInterest,
updateExtents, waitForJobCompletion,
portalURL)
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 )
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
report.write("Failed at step 1 \n" "Line %i" % tb.tb_lineno)
report.write(str(e))
report.close()
print ("Completed update of cache tiles for " + serviceName)