管理地图服务器缓存切片 (服务器)

摘要

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

用法

语法

ManageMapServerCacheTiles_Server (server_name, object_name, data_frame, Layer, levels, update_mode, {constraining_extent}, {thread_count}, {Antialiasing}, {update_feature_class}, {ignore_status})
参数说明数据类型
server_name

用于承载待更新切片所属的地图服务的 ArcGIS Server 计算机。

String
object_name

待更新缓存切片所属的地图服务。

注注:

使用此工具前请确保已为地图服务定义切片方案。可使用服务属性 对话框的缓存 选项卡或“创建地图服务器缓存”工具来创建切片方案。

String
data_frame

地图服务的源数据框。

String
Layer
[Layer,...]

要从缓存中删除的图层。

String
levels

一系列比例级别,运行此工具时将在这些比例级别上创建或删除切片(具体要取决于更新模式)。

Double
update_mode

选择缓存的更新模式。有三种模式可用:

  • 重新创建空切片只重新创建空切片。现有切片将保持不变。
  • 重新创建所有切片如果范围发生改变或已将图层添加到多图层缓存,则更换现有切片并添加新切片。
  • 删除切片将从缓存中删除切片。缓存文件夹结构不会删除。如果要删除包括文件夹结构在内的整个缓存,请使用“删除地图服务器缓存”工具。
String
constraining_extent
(可选)

创建或删除切片所依据的矩形范围,具体取决于更新模式。

Extent
thread_count
(可选)

运行此工具时使用的地图服务实例的数量。默认情况下,使用实例的最大允许数量(对于 ArcGIS Server 服务,其默认值是 2)。如果服务器功能更强大,则可以在服务属性 对话框中增加实例的最大允许数量,然后在运行此工具时增大此参数。

Long
Antialiasing
(可选)

这是一个弃用参数,将被忽略。切片方案中的抗锯齿属性决定了是否对缓存应用抗锯齿功能。

Boolean
update_feature_class
(可选)

您可以根据要素类的要素范围使用面要素类来管理(创建、更新或删除)切片。例如,如果您正在对一个国家/地区进行缓存,则可以提供主要城区的要素类。您这样就可以要求服务器只预先创建覆盖这些市区的切片。其余区域可以根据客户端请求按需进行缓存。这样您就不必创建不需要的乡村区域切片,从而节省了时间和磁盘空间。

Feature Class
ignore_status
(可选)

如果您基于要素类边界创建切片,则可使用此参数追踪缓存的状态(请参阅 update_feature_class 参数)。

  • IGNORE_COMPLETION_STATUS_FIELD忽略要素类的已完成字段,并为要素类中的所有要素都创建切片。这是默认设置。
  • TRACK_COMPLETION_STATUS读取要素类的已完成字段(如果尚未存在此字段,则创建此字段)。此字段中标记为或空值的要素将进行缓存,在完成对要素的缓存后,会将其标记为。此字段中已标记为的要素将不进行缓存。
Boolean

代码示例

此示例使用“重新创建所有切片”选项创建或更新缓存中的所有切片。

# ManageMapServerCacheTiles example (stand-alone script)

# Name: ManageMapServerCacheTiles.py
# Description: The following stand-alone script demonstrates how to Recreate all 
#               cache tiles for 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
server = "MyServer"
service = "Rainfall"
dataFrame = "" 
inputLayers = ""
scaleValues = ""
extents = ""
updateMode = "Recreate All Tiles"
antialiasing = "NONE"
threadCount = "2"
pathToFeatureClass = ""
ignoreStatus = "IGNORE_COMPLETION_STATUS_FIELD"

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(server, service, dataFrame,
                                           inputLayers, scaleValues, updateMode,
                                           extents, threadCount ,Antialiasing,
                                           pathToFeatureClass, ignoreStatus)
    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 "
    + service + " 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 "Created Map server Cache Tiles "

此示例使用“重新创建空切片”选项更新某些比例对应的空切片。

# ManageMapServerCacheTiles example (stand-alone script)

# Name: ManageMapServerCacheTiles.py
# Description: The following stand-alone script demonstrates how to Recreate all 
#               cache tiles for 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
server = "MyServer"
service = "Rainfall"
dataFrame = "" 
inputLayers = ""
scaleValues = ""
extents = ""
updateMode = "Recreate All Tiles"
antialiasing = "NONE"
threadCount = "2"
pathToFeatureClass = ""
ignoreStatus = "IGNORE_COMPLETION_STATUS_FIELD"

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(server, service, dataFrame,
                                           inputLayers, scaleValues, updateMode,
                                           extents, threadCount ,Antialiasing,
                                           pathToFeatureClass, ignoreStatus)
    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 "
    + service + " 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 "Created Map server Cache Tiles "

此示例将切片的更新限制在要素类边界。

# ManageMapServerCacheTiles example (stand-alone script)

# Name: ManageMapServerCacheTiles.py
# Description: The following stand-alone script demonstrates how to Recreate all 
#               cache tiles for 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
server = "MyServer"
service = "Rainfall"
dataFrame = "" 
inputLayers = ""
scaleValues = ""
extents = ""
updateMode = "Recreate All Tiles"
antialiasing = "NONE"
threadCount = "2"
pathToFeatureClass = ""
ignoreStatus = "IGNORE_COMPLETION_STATUS_FIELD"

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(server, service, dataFrame,
                                           inputLayers, scaleValues, updateMode,
                                           extents, threadCount ,Antialiasing,
                                           pathToFeatureClass, ignoreStatus)
    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 "
    + service + " 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 "Created Map server Cache Tiles "

环境

此工具不使用任何地理处理环境

相关主题

许可信息

ArcView: 是
ArcEditor: 是
ArcInfo: 是

7/10/2012