描述
在现有已缓存地图或影像服务中更新比例级别。使用此工具可添加新比例或从缓存中删除现有比例。
使用
如果从现有缓存中移除比例,将导致此细节层次内的所有现有已缓存切片永久性删除。
语法
ManageMapServerCacheScales(input_service, scales)
参数 | 说明 | 数据类型 |
input_service | 您要添加或移除缓存比例的地图或影像服务。 这是一个包含服务器和服务器信息的字符串。要查看构建此字符串的方法,请打开 ArcCatalog,选择目录树中的服务,并注意位置 工具条中的文本。将反斜线改为正斜线,例如 GIS Servers/arcgis on MYSERVER (admin)/USA.MapServer。 | String |
scales [scales,...] | 要包含在已更新切片方案中的比例值。 | Value Table |
代码示例
ManageMapServerCacheScales 示例(独立脚本)
在本例中,将地图缓存切片方案修改为包含四个比例。
# Name: ManageMapServerCacheScales.py
# Description: The following stand-alone script demonstrates how to add/delete
# MapServer cache scales for a map service with an existing schema
#
# Requirements: os, sys, time & 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 = "250000;125000;64000;5250"
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.ManageMapServerCacheScales_server(inputService, scales)
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 "Updated the number of cache scales successfully for " + serviceName
" 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 "Updated Map server Cache scales "
环境
此工具不使用任何地理处理环境。
许可信息
- Basic: 是
- Standard: 是
- Advanced: 是