/// <summary> /// 获取GP日志 /// </summary> /// <param name="pGeoprocessor"></param> /// <param name="strReport"></param> /// <returns></returns> public static bool ReturnErrMessage(ESRI.ArcGIS.Geoprocessor.Geoprocessor pGeoprocessor, ref string strReport) { ESRI.ArcGIS.Geodatabase.GPMessage pGPMessage = new ESRI.ArcGIS.Geodatabase.GPMessage(); ESRI.ArcGIS.Geodatabase.GPMessagesClass pGPMessages = new ESRI.ArcGIS.Geodatabase.GPMessagesClass(); try { int iNum = 0; for (int i = 0; i < pGeoprocessor.MessageCount; i++) { int ii = pGeoprocessor.GetReturnCode(i); if (ii != 0) { iNum = iNum + 1; } if (strReport == "") { strReport = pGeoprocessor.GetMessage(i); if (pGPMessages != null) { pGPMessage.Description = string.Format(strReport); pGPMessages.Add(pGPMessage); } } else { strReport = strReport + "\r\n" + pGeoprocessor.GetMessage(i); if (pGPMessages != null) { pGPMessage.Description = string.Format(strReport); pGPMessages.Add(pGPMessage); } } } if (iNum > 0) { return(false); } else { return(true); } } catch { return(false); } }
//调用gp工具创建泰森多边形 public static void CreateThiessenPolygons(IFeatureLayer in_features, string out_feature_class, string workspacename, string extent) { //IAoInitialize m_AoInitialize = new AoInitializeClass(); //esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable; //licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo); ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); gp.OverwriteOutput = true; gp.SetEnvironmentValue("workspace", workspacename); //gp.SetEnvironmentValue("extent", extent); ESRI.ArcGIS.AnalysisTools.CreateThiessenPolygons createthiessenpolygon = new CreateThiessenPolygons(); createthiessenpolygon.in_features = in_features; createthiessenpolygon.out_feature_class = out_feature_class; createthiessenpolygon.fields_to_copy = "ALL"; gp.Execute(createthiessenpolygon, null); string strMessage = ""; for (int i = 0; i < gp.MessageCount; i++) { strMessage += gp.GetMessage(i).ToString() + "\r\n"; } //MessageBox.Show(strMessage); }