2
3 private void GPTiles() {
4 //设置参数
5 // 切图比例列表
6 string levels = "64000000;32000000;16000000;8000000;4000000;2000000;1000000;500000";
7 // 地图服务中的图层列表
8 string layers = "LakesAnno;State_BoundariesAnno;Provinces;State Boundaries;Lakes;County Population;State Population;State Background";
9 CreateMapServerCache createCache = new CreateMapServerCache();
10 createCache.server_name = "192.168.0.96";
11 createCache.object_name = "mexico";
12 createCache.data_frame = "Layers";
13 createCache.out_folder = @"d:\arcgisserver\arcgiscache\";// 缓存输出位置
14 createCache.tiling_schema = "NEW";
15 createCache.tiling_scheme_type = "NEW";
16 createCache.scales_type = "STANDARD";
17 createCache.num_of_scales = 8; // 设置切图级数
18 createCache.tile_width = 512;
19 createCache.tile_height = 512;
20 createCache.dpi = 96;
21 createCache.cache_format = "PNG24";
22 createCache.tile_compression_quality = 0;
23 createCache.map_or_layers = "FUSED";
24 createCache.Antialiasing = "ANTIALIASING";
25 createCache.levels = levels;// 需做缓存的比例列表
26 createCache.Layer = layers;// 图层列表
27 RunTool(createCache);
28
29 ManageMapServerCacheTiles serverCacheTilse = new ManageMapServerCacheTiles();
30 serverCacheTilse.server_name = "192.168.0.96";// 服务器名称
31 serverCacheTilse.object_name = "mexico";// 地图服务名称
32 serverCacheTilse.data_frame = "Layers";// data frame名称
33 serverCacheTilse.Layer = layers;//
34 serverCacheTilse.levels = levels;
35 serverCacheTilse.update_mode = "Recreate All Tiles";
36 serverCacheTilse.thread_count = 5;
37 serverCacheTilse.Antialiasing = "ANTIALIASING";
38
39 RunTool(serverCacheTilse);
40 MessageBox.Show("Done!");
41 }
42
43 private void RunTool(IGPProcess process) {
44 //构造Geoprocessor
45 Geoprocessor geoprocessor = new Geoprocessor();
46 // Set the overwrite output option to true
47 geoprocessor.OverwriteOutput = true;
48 try {
49 geoprocessor.Execute(process, null);
50 ReturnMessages(geoprocessor);
51 } catch (Exception err) {
52 Console.WriteLine(err.Message);
53 ReturnMessages(geoprocessor);
54 }
55 }
56
57
58 // Function for returning the tool messages.
59 private void ReturnMessages(Geoprocessor gp) {
60 string ms = "";
61 if (gp.MessageCount > 0) {
62 for (int Count = 0; Count <= gp.MessageCount - 1; Count++) {
63 ms += gp.GetMessage(Count);
64 }
65 }
66 }
转载于:https://www.cnblogs.com/xgyb12458/archive/2010/06/03/1750497.html