ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

管理地图服务器缓存切片

  • 描述
  • 使用方法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

描述

在现有 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

缓存的更新模式。

  • RECREATE_EMPTY_TILES —只对空的切片重新创建。 现有切片将保持不变。 此选项不适用于发布至 ArcGIS Online 的 web 切片图层。
  • RECREATE_ALL_TILES —如果范围发生改变,则需要更换现有切片并添加新切片。
  • DELETE_TILES —将从缓存中删除切片。 缓存文件夹结构不会删除。
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 上运行的缓存作业的进度。

  • WAIT —该工具将继续在 Python 窗口中运行,同时缓存作业在 Portal for ArcGIS 或 ArcGIS Online 上运行。 使用此选项,您可以随时请求详细的进度报告并查看显示的地理处理消息。 这是默认选项。 建议在 Python 脚本中使用此选项。
  • DO_NOT_WAIT —地理处理工具会将作业提交至服务器,以便您执行其它地理处理任务。 在您选择在发布服务之际自动构建缓存时使用此选项,您还可在您所构建的任何其他缓存中设置此选项。
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: 是

相关主题

  • 缓存工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明