用gp工具CreateMapTilePackage执行后为何只有一级(设置的是15)切片?

第一步:保存mxd
public static bool SaveTempMxd(string mxdfile, IRasterLayer rasterLayer,ISpatialReference tSRef, ref string error)
{
IMapControlDefault m_pMapCtrl = new MapControlClass();
try
{
m_pMapCtrl.Map.SpatialReference = tSRef;
m_pMapCtrl.AddLayer(rasterLayer as ILayer, 0);

IMxdContents pMxdC = (IMxdContents)m_pMapCtrl.Map;
IMapDocument pMapDocument = new MapDocumentClass();
pMapDocument.New(mxdfile);
IActiveView pActiveView = m_pMapCtrl.Map as IActiveView;
pMapDocument.ReplaceContents(pMxdC);
(pMapDocument as IDocumentInfo).Comments = "栅格数据导出到tpk";
pMapDocument.Save(false, true);
return true;
}
catch (Exception ex)
{
error = ex.Message;
return false;
}
finally
{
m_pMapCtrl.ClearLayers();
if (m_pMapCtrl != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(m_pMapCtrl);
m_pMapCtrl = null;
}
}

}

第二步:调gp生成tpk
public static bool CreateMapTilePack(string mxdfile, string tpkfile, string format_type, int curLevel, ref string error)
{
Geoprocessor gp = new Geoprocessor { OverwriteOutput = true };
try
{
CreateMapTilePackage gptool = new CreateMapTilePackage();
gptool.in_map = mxdfile;
gptool.output_file = tpkfile;
gptool.format_type = format_type;
gptool.level_of_detail = curLevel;
gptool.service_type = "ONLINE";
gptool.summary = "栅格转tpk";
gptool.tags = "栅格转tpk";
IGeoProcessorResult2 result = gp.Execute(gptool, null) as IGeoProcessorResult2;
if (result != null && result.Status == esriJobStatus.esriJobSucceeded)
{
return true;
}
else
{
for (int i = 0; i < gp.MessageCount; i++)
{
error += gp.GetMessage(i) + Environment.NewLine;
}
return false;
}
}
catch(Exception ex)
{
error = ex.Message;
return false;
}
}
 
生成过程没有报错,但是tpk中的切片只有L0级别,在地图中打开是空的
已邀请:

陈辰 - The wisest is she who knows she does not know

赞同来自:

CreateMapTilePackage这个类有设置最大节点数的属性么?这个值可能会影响生成的切片包的级别数量。

朱新颖

赞同来自:

那你检测一下你代码生成的mxd,用ArcMap的GP工具生成tpk是否正常吧,排除一下是哪一部分的问题。

要回复问题请先登录注册