生成地图服务器缓存切片方案 (服务器)

摘要

生成用于定义比例级别、切片尺寸以及其他 Web 切片图层属性的自定义切片方案文件。

切片方案是一种源地图文档空间参考与切片格网之间的映射,用于说明客户端应如何引用缓存中的切片。切片格网将使用细节层次(比例)、行和列参考方案。方案中还将定义缓存中切片的比例级别(细节层次)、切片大小(以像素为单位)以及显示切片时最常用的屏幕分辨率。要生成地图缓存需要切片方案。

使用情况

  • 默认情况下,切片原点起始于服务的源地图文档所用坐标系的左上角。

参数

标注说明数据类型
地图文档

切片方案中将用到的当前地图或现有 .mxd 文档。

Map
切片原点(地图单位)

切片方案的左上角,采用源数据框的空间参考坐标。

Point
输出切片方案

要创建的切片方案文件的路径和文件名。

File
比例级数

切片方案中的比例级数。

Long
比例

要包含在切片方案中的比例级别。不使用分数表示比例级别, 而使用 500 表示比例 1:500,依此类推。

Value Table
每英寸的点(像素)数

专用输出设备的每英寸点数。如果所选择的 DPI 与输出设备的分辨率不匹配,则地图切片将显示错误比例。默认值为 96。

Long
切片大小

缓存切片的宽度和高度(以像素为单位)。默认值为 256 x 256。为在性能和可管理性之间寻求最佳平衡,应避免偏离标准尺寸 256 x 256 或 512 x 512。

  • 128 x 128 像素128 x 128 像素
  • 256 x 256 像素256 x 256 像素
  • 512 x 512 像素512 x 512 像素
  • 1024 x 1024 像素1024 x 1024 像素
String

arcpy.server.GenerateMapServerCacheTilingScheme(in_map, tile_origin, output_tiling_scheme, num_of_scales, scales, dots_per_inch, tile_size)
名称说明数据类型
in_map

切片方案中将用到的当前地图或现有 .mxd 文档。

Map
tile_origin

切片方案的左上角,采用源数据框的空间参考坐标。

Point
output_tiling_scheme

要创建的切片方案文件的路径和文件名。

File
num_of_scales

切片方案中的比例级数。

Long
scales
[scales,...]

要包含在切片方案中的比例级别。不使用分数表示比例级别, 而使用 500 表示比例 1:500,依此类推。

Value Table
dots_per_inch

专用输出设备的每英寸点数。如果所选择的 DPI 与输出设备的分辨率不匹配,则地图切片将显示错误比例。默认值为 96。

Long
tile_size

缓存切片的宽度和高度(以像素为单位)。默认值为 256 x 256。为在性能和可管理性之间寻求最佳平衡,应避免偏离标准尺寸 256 x 256 或 512 x 512。

  • 128 x 128128 x 128 像素
  • 256 x 256256 x 256 像素
  • 512 x 512512 x 512 像素
  • 1024 x 10241024 x 1024 像素
String

代码示例

GenerateMapServerCacheTilingScheme 示例

创建具有四种比例的地图缓存切片方案。

# Name: GeneateMapServerCacheTilingScheme.py
# Description: The following stand-alone script demonstrates how to create map
#               server cache schema using a given map document at a given
#               "pathForOutputXml"
# 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
mapDocument = "C:/data/101/Portland/mxd/_M_Portland_classic_FGDB_Local.mxd"
dataFrame = ""
outputTilingScheme = "C:/data/port.xml"
tileOrigin = ""
numOfScales = "4"
scales = "500000,250000,125000,64000"
tileSize = "256 x 256"
dotsPerInch = "96"

currentTime = datetime.datetime.now()
arg1 = currentTime.strftime("%H-%M")
arg2 = currentTime.strftime("%Y-%m-%d %H:%M")
file = r'C:/data/report_%s.txt' % arg1

# print results of the script to a report
report = open(file,'w')

try:
    starttime = time.clock()
    result = arcpy.GenerateMapServerCacheTilingScheme_server(mapDocument, dataFrame,
                                                             tileOrigin, outputTilingScheme,
                                                             numOfScales, scales,
                                                             dotsPerInch, tileSize)
    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 MapServer cache tiling schema successfully using" + \
        mapDocument + " at "+ outputTilingScheme + " in " + str(elapsedtime) + \
        " sec \n on " + arg2)

except Exception as 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(str(e))

print("Created Map server Cache Tiling schema ")

report.close()

环境

特殊情况

许可信息

  • Basic: 是
  • Standard: 是
  • Advanced: 是

相关主题