マップ サービス キャッシュの作成(Create Map Server Cache) (サーバ)
サマリ
マップまたはイメージ サービス キャッシュ用のタイル スキーマおよびフォルダを作成します。このツールの実行後は、[マップ サービス キャッシュのタイルを管理(Manage Map Server Cache Tiles)] を実行して、タイルをキャッシュに追加できます。
使用法
- このツールは、ArcGIS Server のマップまたはイメージ サービスに対してのみ機能します。
- 一度に表示できるデータ フレームは 1 つだけです。複数のデータ フレームからのマップが必要な場合は、それぞれのデータ フレームに対して別のマップ サービスとキャッシュを作成しなければなりません。 
- 
一度タイル スキーマを作成すると、それを変更することはできません。ただし、[マップ サービス キャッシュの縮尺を管理(Manage Map Server Cache Scales)] ツールを使用して、キャッシュの縮尺を追加または削除することができます。 
- 
ラスタ データは、JPEG または MIXED イメージ形式にするのが最適です。ベクタ マップで JPEG または MIXED を使用する場合は、高い圧縮品質値(90 など)を使用して、ラインやテキストの不鮮明さを軽減します。ベクタ データは PNG 形式でも提供できます。 
- 
キャッシュのイメージ形式は、キャッシュが生成された後で変更することはできません。別の形式に切り替える前に、キャッシュを最初に削除しなければなりません。 
 レガシー:
レガシー:構文
| パラメータ | 説明 | データ タイプ | 
| input_service | キャッシュを作成するマップまたはイメージ サービス。 これは、サーバとサービスの両方の情報を含む文字列です。この文字列の構築方法を確認するには、ArcCatalog を開き、カタログ ツリーでサービスを選択して、[場所] ツールバーに表示されているテキストを記録します。バックスラッシュをスラッシュに変更します(たとえば、GIS Servers/arcgis on MYSERVER (admin)/USA.MapServer)。 | String | 
| service_cache_directory | キャッシュの親ディレクトリ。この ArcGIS Server キャッシュ ディレクトリは、登録済みのものでなければなりません。 | String | 
| tiling_scheme_type | 新しい(NEW)タイル スキーマまたは定義済み(PREDEFINED)のタイル スキーマの使用を選択します。このツールで新しいタイル スキーマを定義するか、または定義済みタイル スキーマ(*.xml)を参照することができます。定義済みスキーマは、[マップ サービス キャッシュ タイル スキーマの生成(Generate Map Server Cache Tiling Scheme)] ツールを実行することによって生成できます。 
 | String | 
| scales_type | タイルの縮尺を定義する方法を指定します。 
 | String | 
| num_of_scales | キャッシュ内に作成される縮尺レベルの数。縮尺のカスタム リストを作成した場合、このオプションは無効です。 | Long | 
| dots_per_inch | 対象となる出力デバイスの 1 インチあたりのドット数。選択した DPI が出力デバイスの解像度と一致していない場合、その縮尺のマップ タイルは正しく表示されません。デフォルト値は 96 です。 | Long | 
| tile_size | キャッシュ タイルの幅と高さ(ピクセル単位)。デフォルトは 256 x 256 です。パフォーマンスと管理容易性の最適なバランスを得るには、256 x 256 または 512 x 512 の標準幅から外れないようにしてください。 | Long | 
| predefined_tiling_scheme (オプション) | 定義済みタイル スキーマ ファイル(ファイル名は通常 conf.xml)へのパス。 | File | 
| tile_origin (オプション) | ソース マップ ドキュメントの空間参照座標での、タイル スキーマの原点(左上隅)。ソース マップ ドキュメントの範囲は、この原点の内側であることが条件となります(ただし、この領域と一致している必要はありません)。 | Point | 
| scales [scales,...] (オプション) | 利用可能なキャッシュの縮尺レベル。これらは分数としては表されません。代わりに、500 を使用して 1:500 などの目盛を表します。 | Value Table | 
| cache_tile_format (オプション) | キャッシュ内のタイル用に PNG、PNG8、PNG24、PNG32、JPEG、または MIXED のいずれかのファイル形式を選択します。PNG8 がデフォルトです。 
 | String | 
| tile_compression_quality (オプション) | JPEG 圧縮品質を得るには、値を 1 ~ 100 の範囲で入力します。JPEG タイル フォーマットのデフォルト値は 75 で、他のフォーマットのデフォルト値は 0(ゼロ)です。 圧縮は JPEG 形式だけでサポートされます。高い値を選択すると、作成されるファイルのサイズは大きくなり、画像の品質は向上します。低い値を選択すると、作成されるファイルのサイズは小さくなり、画像の品質は低下します。 | Long | 
| storage_format (オプション) | タイルの格納形式を決定します。 
 | String | 
コードのサンプル
この例では、STANDARD タイプの縮尺を使って、マップ キャッシュを作成します。
# Name: CreateMapServerCache.py
# Description: The following stand-alone script demonstrates how to create map
#               using standard tiling schema 
# 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
serviceCacheDirectory = "C:\\arcgisserver\\arcgiscache\\"
tilingSchemeType = "NEW"
scalesType = "STANDARD"
numOfScales = "4"
scales = ""
dotsPerInch = "96"
tileOrigin = ""
scales = ""
tileSize = "256 x 256"
cacheTileFormat = "PNG32"
tileCompressionQuality = ""
storageFormat = "COMPACT"
predefinedTilingScheme = ""
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.CreateMapServerCache_server(inputService,
                                               serviceCacheDirectory,
                                               tilingSchemeType, scalesType,
                                               numOfScales, dotsPerInch,
                                               tileSize, predefinedTilingScheme,
                                               tileOrigin, scales,
                                               cacheTileFormat,
                                               tileCompressionQuality,
                                               storageFormat)
                                              
    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 schema with 4 scales & default properties for"
    serviceName + " 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 "Executed creation of Map server Cache schema "
report.close()
この例では、CUSTOM 縮尺を使って、マップ キャッシュを作成します。
# Name: CreateMapServerCache.py
# Description: The following stand-alone script demonstrates how to create map
#              using Custom scales & jpg image format.
# 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, string, datetime, traceback
# 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
serviceCacheDirectory = "C:\\arcgisserver\\arcgiscache"
tilingSchemeType = "NEW"
scalesType = "CUSTOM"
numOfScales = "4"
dotsPerInch = "96"
tileSize = "256 x 256"
predefinedTilingScheme = ""
tileOrigin = ""
scales = "600265;350200;225400;44000"
cacheTileFormat = "JPEG"
tileCompressionQuality = "75"
storageFormat = "COMPACT"
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.CreateMapServerCache_server(inputService,
                                               serviceCacheDirectory,
                                               tilingSchemeType, scalesType,
                                               numOfScales, dotsPerInch,
                                               tileSize, predefinedTilingScheme,
                                               tileOrigin, scales, 
                                               cacheTileFormat,
                                               tileCompressionQuality,
                                               storageFormat)
    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 schema with custom scales successfully for "
    serviceName + " 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 "Executed creation of map server Cache schema using custom scales"
report.close()
この例では、定義済みタイル スキーマを使って、マップ キャッシュを作成します。
# Name: CreateMapServerCache.py
# Description: The following stand-alone script demonstrates how to create map
#               using existing predefined schema
# 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
connectionFile = r"C:\Users\<username>\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog"
server = "arcgis on MyServer_6080 (publisher)"
serviceName = "Rainfall.MapServer"
inputService = connectionFile + "\\" + server + "\\" + serviceName
serviceCacheDirectory = "C:\\arcgisserver\\directories\\arcgiscache"
tilingSchemeType = "PREDEFINED"
scalesType = ""
tileOrigin = ""
scalesType = ""
numOfScales = ""
scales = ""
dotsPerInch = "96"
tileSize = "256 x 256"
cacheTileFormat = "MIXED"
tileCompressionQuality = "75"
storageFormat = "COMPACT"
predefinedTilingScheme = "C:/data/TilingSchemes/ArcGIS_Online_Bing_Maps_Google_Maps.xml"
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.CreateMapServerCache_server (inputService,
                                                serviceCacheDirectory,
                                                tilingSchemeType, scalesType,
                                                numOfScales, dotsPerInch,
                                                tileSize, predefinedTilingScheme,
                                                tileOrigin, scales,
                                                cacheTileFormat,
                                                tileCompressionQuality,
                                                storageFormat)
    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 schema using predefined tiling schema for "
    serviceName + " 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 "Executed creation of map server Cache schema using tiling scheme"
report.close()