导入地图服务器缓存 (服务器)

摘要

将切片从磁盘上的文件夹中导入地图缓存。源文件夹可以是已注册的服务器缓存目录的子文件夹,还可以是事先已导入切片的其他文件夹。目标地图服务必须与源地图缓存使用相同的切片方案和存储格式。

用法

语法

ImportMapServerCache_Server (server_name, object_name, data_frame, source_cache_dataset, {import_extent}, {levels}, thread_count, {import_feature_class})
参数说明数据类型
server_name

托管将导入切片的服务的 ArcGIS Server 计算机。

String
object_name

将导入切片的地图服务的名称。该地图服务必须将切片方案定义为与导入的切片的切片方案匹配。

String
data_frame

地图服务的源数据框。

String
source_cache_dataset

将导入的切片所在位置的路径。在工具用户界面中使用栅格数据集图标表示此参数。如果正在编写脚本,则此参数为与数据框名称匹配的缓存文件夹的路径。您不必将此参数指向已注册的服务器缓存目录;实际上,很多情况下需要指向磁盘上事先已导入切片的位置。

Raster Dataset
import_extent
(可选)

定义要导入的切片的矩形范围。默认情况下,此范围被设置为要导入切片的地图服务的全图范围。请注意此工具中的该可选参数,设置它可能会将切片导入限制为要素类边界。

Extent
levels
[levels,...]
(可选)

导入切片时使用的比例级别列表。

Double
thread_count

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

Long
import_feature_class
(可选)

定义切片导入缓存中的位置的面要素类。它用于为形状不规则的区域导入切片。

Feature Class

代码示例

使用默认值导入地图缓存。

# ImportMapServerCache example (stand-alone script)

# Name: ImportMapServerCache.py
# Description: The following stand-alone script demonstrates how to import map
#               server cache from a source directory to an existing service for 
#               the default number of scales specified
# To Import cache tiles for the scales specified for 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
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 = "" 
cacheDir = "c:\\arcgisserver\\arcgiscache\\"
importExtents = ""
scaleValues = [500000,250000,125000,64000]
threadCount = "2"
sourceCache= "C:/data/destination_folder/Layers"
specifiedFeatureClass = "C:/data/94/Portland/Portland_Metro.shp"

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 "scaleValues[0]","scaleValues[-1]","scaleValues[0:3]"

try:
    starttime = time.clock()
    result = arcpy.ImportMapServerCache_server(server, service, dataFrame, sourceCache,
                                      threadCount, importExtents , scaleValues,
                                      specifiedFeatureClass )
    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 "Imported Map server Cache Tiles successfully for " + service + "  from "
    + sourceCache + " to " + cacheDir + service + "\n using "+ specifiedFeatureClass
    + " 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 2 \n" "Line %i" % tb.tb_lineno)
    report.write(e.message)
report.close()

print "Imported Map server Cache Tiles for the given feature class"



限制为沿指定要素类边界后导入地图缓存。

# ImportMapServerCache example (stand-alone script)

# Name: ImportMapServerCache.py
# Description: The following stand-alone script demonstrates how to import map
#               server cache from a source directory to an existing service for 
#               the default number of scales specified
# To Import cache tiles for the scales specified for 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
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 = "" 
cacheDir = "c:\\arcgisserver\\arcgiscache\\"
importExtents = ""
scaleValues = [500000,250000,125000,64000]
threadCount = "2"
sourceCache= "C:/data/destination_folder/Layers"
specifiedFeatureClass = "C:/data/94/Portland/Portland_Metro.shp"

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 "scaleValues[0]","scaleValues[-1]","scaleValues[0:3]"

try:
    starttime = time.clock()
    result = arcpy.ImportMapServerCache_server(server, service, dataFrame, sourceCache,
                                      threadCount, importExtents , scaleValues,
                                      specifiedFeatureClass )
    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 "Imported Map server Cache Tiles successfully for " + service + "  from "
    + sourceCache + " to " + cacheDir + service + "\n using "+ specifiedFeatureClass
    + " 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 2 \n" "Line %i" % tb.tb_lineno)
    report.write(e.message)
report.close()

print "Imported Map server Cache Tiles for the given feature class"



环境

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

相关主题

许可信息

ArcView: 是
ArcEditor: 是
ArcInfo: 是

7/10/2012