ArcGIS Desktop

  • 文档
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

管理地图服务器缓存切片

  • 摘要
  • 用法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

摘要

在现有地图或影像服务缓存中创建和更新切片。此工具用于创建新切片、恢复缺失切片、覆盖过时切片以及删除切片。

用法

    旧版本:
    在 10.1 版本中,此工具的各个参数都发生了变化。在 10.1 版本之前使用该工具编写的模型或脚本均需要经过修改才能在 10.1 版本中使用。
  • 使用此工具前请确保已为地图服务定义的切片方案。可使用服务编辑器 窗口中的缓存 选项卡或创建地图服务器缓存工具来创建切片方案。
  • 对于涉及较大地理范围或较大地图比例的缓存,此工具可能会需要较长的运行时间。如果取消此工具,将停止切片创建,但不删除现有切片。这意味着在您在时间不够时可以先取消此工具,以后再使用 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

缓存的更新模式。

  • RECREATE_EMPTY_TILES —只重新创建空切片。现有切片将保持不变。
  • RECREATE_ALL_TILES —如果范围发生改变,则需要更换现有切片并添加新切片。
  • DELETE_TILES —将从缓存中删除切片。缓存文件夹结构不会删除。如果要删除包括文件夹结构在内的整个缓存,请使用删除地图服务器缓存工具。
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
(可选)

可以通过该参数查看在服务器上运行的缓存作业的进度。

  • WAIT —该工具将继续在 ArcGIS for Desktop 中运行,同时缓存作业在 ArcGIS for Server 或 ArcGIS Online 上运行。使用此选项,您可以随时请求详细的进度报告并查看显示的地理处理消息。这是默认选项。建议在 Python 脚本中使用此选项。
  • DO_NOT_WAIT —地理处理工具会将作业提交至服务器,让您可以在 ArcGIS for Desktop 或类似 ArcGIS for Desktop 的程序中执行其它地理处理任务。在您选择在发布服务之际自动构建缓存时使用此选项,您还可在您所构建的任何其他缓存中设置此选项。要追踪缓存作业的状态,请打开 ArcGIS for Desktop,右键单击目录 窗口中的服务,然后单击查看缓存状态。您也可以使用工具生成消息中所提供的 URL。如果服务缓存目录中不存在 Status.gdb 文件地理数据库,则此选项不可用。
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: 是

相关主题

  • 缓存工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明