Generate Map Server Cache Tiling Scheme (Server)

Summary

Generates an XML tiling scheme file that defines the scale levels, tile dimensions, and other properties for a map service cache. This tool is useful when creating a tiling scheme to use in multiple caches. You can load the tiling scheme file when you create a cache in ArcCatalog or Manager, or you can run Create Map Server Cache and pass in the tiling scheme file as a parameter.

A tiling scheme describes how clients should reference the tiles in a cache and is a mapping between the spatial reference of the source map document and the tiling grid. The tiling grid uses a level-of-detail (scale-level), row, and column reference scheme. The scheme also defines the scale levels (levels of detail) at which the cache has tiles, the size of the tiles in pixels, and the screen resolution for which the tiles are intended to be most commonly displayed. A tiling scheme is needed to generate a map cache.

Usage

Syntax

GenerateMapServerCacheTilingScheme_Server (map_document, data_frame, tile_origin, tiling_schema, cache_levels, levels, dpi, tile_width, tile_height)
ParameterExplanationData Type
map_document

The source map document to be used for the tiling scheme.

File
data_frame

The data frame to be used for the tiling scheme.

String
tile_origin

The upper left corner of the tiling scheme in coordinates of the spatial reference of the source data frame.

Point
tiling_schema

Path and file name of the tiling scheme file to create.

File
cache_levels

Number of scale levels in the tiling scheme.

Long
levels
[levels,...]

Scale levels to include in the tiling scheme. These are not represented as fractions. Instead, use 500 to represent a scale of 1:500, and so on.

Value Table
dpi

The dots per inch of the intended output device. If a DPI is chosen that does not match the resolution of the output device, the scale of the map tile will appear incorrect. The default value is 96.

Long
tile_width

The width of the cache tiles in pixels. The default is 256. For the best balance between performance and manageability, avoid deviating from standard widths of 256 or 512.

Long
tile_height

The height of the cache tiles in pixels. The default is 256. For the best balance between performance and manageability, avoid deviating from standard widths of 256 or 512.

Long

Code Sample

This example creates a map cache tiling scheme with four scales.

# GeneateMapServerCacheTilingScheme example (stand-alone script)

# 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
# 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
pathToMapDocument = "C:/data/94/Portland/mxd/_M_Portland_classic_FGDB_Local.mxd"
dataFrame = "" 
pathForXml = "C:/data/port.xml"
tileOrigin = ""
scales = "4"
scaleValues = "500000,250000,125000,64000"
tileWidth = "256"
tileHeight = "256"
dpi = "96"

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.GenerateMapServerCacheTilingScheme_server( pathToMapDocument, 
                                                     dataFrame, tileOrigin, 
                                                     pathForXml,scales, 
                                                     scaleValues, dpi, 
                                                     tileWidth, tileHeight)
    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"
    + pathToMapDocument + " at "+ pathForXml + " 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)
    
print "Created Map server Cache Tiling schema "

report.close()

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes

5/9/2011