Exemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="argument">格式"*#*"冒号前面部分表示文件名称,冒号后面部分表示所选投影坐标的Wkt格式字符串</param>
 public override void Execute(string argument)
 {
     try
     {
         string            fileName = "";
         ISpatialReference proj     = null;
         AOIItem[]         aois;
         fileName = TryGetInfoFromActiveView(out aois);
         proj     = SpatialReference.GetDefault();
         List <PrjEnvelopeItem> lstEnvelope = new List <PrjEnvelopeItem>();
         for (int i = 0; i < aois.Length; i++)
         {
             AOIItem aoi = aois[i];
             GeoDo.RSS.Core.DrawEngine.CoordEnvelope env = aoi.GeoEnvelope;
             if (env.IsEmpty())
             {
                 throw new Exception("获得的感兴趣区域是空值:" + aoi.ToString());
             }
             PrjEnvelope prjEnv = new PrjEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY);
             lstEnvelope.Add(new PrjEnvelopeItem("AOI", prjEnv));
         }
         if (string.IsNullOrWhiteSpace(fileName))
         {
             throw new Exception("无法从参数中解析出文件名:" + argument);
         }
         Project(fileName, proj, lstEnvelope == null || lstEnvelope.Count == 0 ? null : lstEnvelope.ToArray());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemplo n.º 2
0
 private PrjEnvelope TryGetFirstAOI()
 {
     GeoDo.RSS.Core.DrawEngine.CoordEnvelope env = TryGetInfoFromActiveView();
     if (env == null || env.IsEmpty())
     {
         return(null);
     }
     return(new PrjEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY));
 }
Exemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="argument">格式"*#*"冒号前面部分表示文件名称,冒号后面部分表示所选投影坐标的Wkt格式字符串</param>
 public override void Execute(string argument)
 {
     try
     {
         string            fileName = "";
         ISpatialReference proj     = null;
         GeoDo.RSS.Core.DrawEngine.CoordEnvelope[] envelopes;
         fileName = TryCheckArgsEnvironment(out envelopes);
         proj     = SpatialReference.GetDefault();
         List <PrjEnvelopeItem> lstEnvelope = new List <PrjEnvelopeItem>();
         for (int i = 0; i < envelopes.Length; i++)
         {
             GeoDo.RSS.Core.DrawEngine.CoordEnvelope env = envelopes[i];
             if (env.IsEmpty())
             {
                 throw new Exception("获得的感兴趣区域是空值:" + env.ToString());
             }
             PrjEnvelope prjEnv = new PrjEnvelope(env.MinX, env.MaxX, env.MinY, env.MaxY);
             lstEnvelope.Add(new PrjEnvelopeItem("AOI", prjEnv));
         }
         if (string.IsNullOrWhiteSpace(fileName))
         {
             throw new Exception("无法从参数中解析出文件名:" + argument);
         }
         string               errorMsg;
         string[]             outFiles        = null;
         IProgressMonitor     progressMonitor = null;
         Action <int, string> progress        = null;
         try
         {
             progressMonitor = _smartSession.ProgressMonitorManager.DefaultProgressMonitor;
             progress        = new Action <int, string>(
                 (int progerss, string text) =>
             {
                 if (progressMonitor != null)
                 {
                     progressMonitor.Boost(progerss, text);
                 }
             });
             if (progressMonitor != null)
             {
                 progressMonitor.Reset("", 100);
                 progressMonitor.Start(false);
                 progressMonitor.Boost(0, "准备文件");
             }
             string    outdir    = GetOutDirFromConfig(fileName);
             PrjOutArg prjOutArg = new PrjOutArg(proj, lstEnvelope.ToArray(), 0, 0, outdir);
             //添加对自定义感兴趣区的支持。
             ProjectionFactory quick = new ProjectionFactory();
             outFiles = quick.Project(fileName, prjOutArg, progress, out errorMsg);
         }
         finally
         {
             if (progressMonitor != null)
             {
                 progressMonitor.Finish();
             }
             progress = null;
         }
         if (outFiles != null && outFiles.Length != 0)
         {
             for (int i = 0; i < outFiles.Length; i++)
             {
                 if (!string.IsNullOrWhiteSpace(outFiles[i]))
                 {
                     OpenFileToWindows(outFiles[i]);
                 }
             }
         }
         if (errorMsg != null && errorMsg.Length != 0)
         {
             MsgBox.ShowInfo(errorMsg);
         }
     }
     catch (Exception ex)
     {
         MsgBox.ShowInfo(ex.Message);
     }
 }