マップ サービス キャッシュのインポート(Import Map Server Cache) (サーバ)
サマリ
タイルをディスク上のフォルダからマップ キャッシュにインポートします。ソース フォルダとして、登録済みサーバ キャッシュ ディレクトリの子を指定することも、あるいは以前にタイルをエクスポートしておいた他のフォルダを指定することもできます。ターゲット マップ サービスは、タイル スキーマおよび格納形式がマップ キャッシュと一致している必要があります。
使用法
-
[マップ サービス キャッシュのインポート(Import Map Server Cache)] ツールを使用して、キャッシュのすべてまたは一部を、フォルダから別のフォルダへインポートします。
構文
| パラメータ | 説明 | データ タイプ |
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"