public photoAnalysis(string InputDir, string PolygonPath, string OutPutCSV, extensionType Extension = extensionType.jpg, esriUtil.Forms.RunningProcess.frmRunningProcessDialog rpd = null) { photoDir = InputDir; polyPath = PolygonPath; outCSV = OutPutCSV; ext = Extension; frmRpd = rpd; }
public zonalHelper() { rsUtil = new rasterUtil(); tempWksStr = rsUtil.TempConvDir; rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.TopMost = true; rd.Show(); }
private void button1_Click(object sender, EventArgs e) { string ftrNm = cmbSampleFeatureClass.Text; if (ftrNm == "" || ftrNm == null) { MessageBox.Show("You must have a sampling layer selected"); return; } if (!System.IO.File.Exists(plrR.SasOutputFile)) { MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int paramLength = plrR.OutParameters.Length; int rsBndsCnt = lstRasterBands.Items.Count; int bCnt = 0; for (int i = 0; i < rsBndsCnt; i++) { bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count; } if (bCnt < 1 || (paramLength - 1) != bCnt) { MessageBox.Show("Param = " + (paramLength - 1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnViewOrder.PerformClick(); return; } IRasterBandCollection rsBc = new RasterClass(); for (int i = 0; i < rsBndsCnt; i++) { IRaster rs = rstDic[lstRasterBands.Items[i].ToString()]; rsBc.AppendBands((IRasterBandCollection)rs); } this.Visible = false; plrR.InRaster = (IRaster)rsBc; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false); System.DateTime dt1 = System.DateTime.Now; rp.addMessage("Creating PLR Classification Raster."); rp.addMessage("Bands are organized as follows:\n\tBand1=MLC\n\tBand2=BaseCategory"); int bcCnt = 3; foreach (string c in plrR.Categories) { rp.addMessage("\tBand" + bcCnt.ToString() + "=" + c); bcCnt += 1; } rp.addMessage("This may take some time..."); rp.Show(); rp.TopMost = true; rp.stepPGBar(20); rp.Refresh(); IRaster rst = plrR.createModelRaster(seed); if (mp != null) { rp.addMessage("Adding Raster to map"); rp.Refresh(); IRasterLayer rsLyr1 = new RasterLayerClass(); rsLyr1.CreateFromRaster(rst); rsLyr1.Name = "PLR_OUT"; rsLyr1.Visible = false; mp.AddLayer(rsLyr1); } rp.stepPGBar(50); rp.addMessage("Finished creating raster"); rp.Refresh(); System.DateTime dt2 = System.DateTime.Now; System.TimeSpan ts = dt2.Subtract(dt1); string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds "; rp.addMessage(prcTime); rp.stepPGBar(100); rp.Refresh(); rp.enableClose(); this.Close(); return; }
public zonalHelper(rasterUtil rasterUtility, esriUtil.Forms.RunningProcess.frmRunningProcessDialog runningdialog) { rsUtil = rasterUtility; tempWksStr = rsUtil.TempConvDir; rd = runningdialog; }
public zonalHelper(rasterUtil rasterUtility,esriUtil.Forms.RunningProcess.frmRunningProcessDialog runningdialog) { rsUtil = rasterUtility; tempWksStr = rsUtil.TempConvDir; rd = runningdialog; }
private void button1_Click(object sender, EventArgs e) { string ftrNm = cmbSampleFeatureClass.Text; if (ftrNm == "" || ftrNm == null) { MessageBox.Show("You must have a sampling layer selected"); return; } if (!System.IO.File.Exists(plrR.SasOutputFile)) { MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int paramLength = plrR.OutParameters.Length; int rsBndsCnt = lstRasterBands.Items.Count; int bCnt = 0; for (int i = 0; i < rsBndsCnt; i++) { bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count; } if (bCnt < 1||(paramLength-1)!=bCnt) { MessageBox.Show("Param = " + (paramLength-1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnViewOrder.PerformClick(); return; } IRasterBandCollection rsBc = new RasterClass(); for (int i = 0; i < rsBndsCnt; i++) { IRaster rs = rstDic[lstRasterBands.Items[i].ToString()]; rsBc.AppendBands((IRasterBandCollection)rs); } this.Visible = false; plrR.InRaster = (IRaster)rsBc; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false); System.DateTime dt1 = System.DateTime.Now; rp.addMessage("Creating PLR Classification Raster."); rp.addMessage("Bands are organized as follows:\n\tBand1=MLC\n\tBand2=BaseCategory"); int bcCnt = 3; foreach (string c in plrR.Categories) { rp.addMessage("\tBand" + bcCnt.ToString() + "=" + c); bcCnt += 1; } rp.addMessage("This may take some time..."); rp.Show(); rp.TopMost = true; rp.stepPGBar(20); rp.Refresh(); IRaster rst = plrR.createModelRaster(seed); if (mp != null) { rp.addMessage("Adding Raster to map"); rp.Refresh(); IRasterLayer rsLyr1 = new RasterLayerClass(); rsLyr1.CreateFromRaster(rst); rsLyr1.Name = "PLR_OUT"; rsLyr1.Visible = false; mp.AddLayer(rsLyr1); } rp.stepPGBar(50); rp.addMessage("Finished creating raster"); rp.Refresh(); System.DateTime dt2 = System.DateTime.Now; System.TimeSpan ts = dt2.Subtract(dt1); string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds "; rp.addMessage(prcTime); rp.stepPGBar(100); rp.Refresh(); rp.enableClose(); this.Close(); return; }
private void button1_Click(object sender, EventArgs e) { string ftrNm = cmbSampleFeatureClass.Text; string sasDir = cmbModelDir.Text; if (ftrNm == "" || ftrNm == null) { MessageBox.Show("You must have a Workspace selected"); return; } if (sasDir == "" || sasDir == null) { MessageBox.Show("You must have a SAS modeled directory selected"); return; } if (!System.IO.File.Exists(rR.SasOutputFile)) { MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int paramLength = rR.OutParameters.Length; int rsBndsCnt = lstRasterBands.Items.Count; int bCnt = 0; for (int i = 0; i < rsBndsCnt; i++) { bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count; } if (bCnt < 1 || (paramLength - 1) != bCnt) { MessageBox.Show("Param = " + (paramLength - 1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnViewOrder.PerformClick(); return; } IRasterBandCollection rsBc = new RasterClass(); for (int i = 0; i < rsBndsCnt; i++) { IRaster rs = rstDic[lstRasterBands.Items[i].ToString()]; rsBc.AppendBands((IRasterBandCollection)rs); } this.Visible = false; rR.InRaster = (IRaster)rsBc; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false); System.DateTime dt1 = System.DateTime.Now; rp.addMessage("Creating Regression Raster."); rp.addMessage("Name of the out raster = " + sasDir + ". Bands are in the order of dependent variables"); int bcnt = 1; foreach (string s in rR.Categories) { rp.addMessage("\tBand_" + bcnt.ToString() + " = " + s); bcnt++; } rp.addMessage("This may take some time..."); rp.Show(); rp.TopMost = true; rp.stepPGBar(20); rp.Refresh(); try { outraster = rR.createModelRaster(); outrastername = sasDir; if (mp != null && addToMap) { rp.addMessage("Adding Rasters to map"); rp.Refresh(); IRasterLayer rsLyr1 = new RasterLayerClass(); rsLyr1.Name = outrastername; rsLyr1.CreateFromRaster(outraster); rsLyr1.Visible = false; mp.AddLayer(rsLyr1); } this.DialogResult = DialogResult.OK; } catch (Exception exc) { rp.addMessage(exc.ToString()); } finally { rp.stepPGBar(50); rp.addMessage("Finished creating raster"); rp.Refresh(); System.DateTime dt2 = System.DateTime.Now; System.TimeSpan ts = dt2.Subtract(dt1); string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds "; rp.addMessage(prcTime); rp.stepPGBar(100); rp.Refresh(); rp.enableClose(); this.Close(); } return; }
public batchCalculations(rasterUtil rasterUtility, esriUtil.Forms.RunningProcess.frmRunningProcessDialog runningDialog) { rsUtil = rasterUtility; if (rp != null) rp = runningDialog; }
private void button1_Click(object sender, EventArgs e) { string ftrNm = cmbSampleFeatureClass.Text; string sasDir = cmbModelDir.Text; if (ftrNm == "" || ftrNm == null) { MessageBox.Show("You must have a Workspace selected"); return; } if (sasDir == "" || sasDir == null) { MessageBox.Show("You must have a SAS modeled directory selected"); return; } if (!System.IO.File.Exists(rR.SasOutputFile)) { MessageBox.Show("Could not find the sas estimate file. You either needed to first create the classificaiton model or select a feature dataset that has been used to create the model!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int paramLength = rR.OutParameters.Length; int rsBndsCnt = lstRasterBands.Items.Count; int bCnt = 0; for (int i = 0; i < rsBndsCnt; i++) { bCnt = bCnt + ((IRasterBandCollection)rstDic[lstRasterBands.Items[i].ToString()]).Count; } if (bCnt < 1 || (paramLength - 1) != bCnt) { MessageBox.Show("Param = " + (paramLength - 1).ToString() + " BandCount = " + bCnt.ToString() + "\nYou must have the same number of rasters selected in the same order as parameter estimates", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnViewOrder.PerformClick(); return; } IRasterBandCollection rsBc = new RasterClass(); for (int i = 0; i < rsBndsCnt; i++) { IRaster rs = rstDic[lstRasterBands.Items[i].ToString()]; rsBc.AppendBands((IRasterBandCollection)rs); } this.Visible = false; rR.InRaster = (IRaster)rsBc; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(false); System.DateTime dt1 = System.DateTime.Now; rp.addMessage("Creating Regression Raster."); rp.addMessage("Name of the out raster = " + sasDir + ". Bands are in the order of dependent variables"); int bcnt = 1; foreach (string s in rR.Categories) { rp.addMessage("\tBand_" + bcnt.ToString() + " = " + s); bcnt++; } rp.addMessage("This may take some time..."); rp.Show(); rp.TopMost = true; rp.stepPGBar(20); rp.Refresh(); try { outraster = rR.createModelRaster(); outrastername = sasDir; if (mp != null && addToMap) { rp.addMessage("Adding Rasters to map"); rp.Refresh(); IRasterLayer rsLyr1 = new RasterLayerClass(); rsLyr1.Name = outrastername; rsLyr1.CreateFromRaster(outraster); rsLyr1.Visible = false; mp.AddLayer(rsLyr1); } this.DialogResult = DialogResult.OK; } catch (Exception exc) { rp.addMessage(exc.ToString()); } finally { rp.stepPGBar(50); rp.addMessage("Finished creating raster"); rp.Refresh(); System.DateTime dt2 = System.DateTime.Now; System.TimeSpan ts = dt2.Subtract(dt1); string prcTime = "Time to complete process:\n" + ts.Days.ToString() + " Days " + ts.Hours.ToString() + " Hours " + ts.Minutes.ToString() + " Minutes " + ts.Seconds.ToString() + " Seconds "; rp.addMessage(prcTime); rp.stepPGBar(100); rp.Refresh(); rp.enableClose(); this.Close(); } return; }
/// <summary> /// Fills in the features that need updating /// </summary> /// <param name="sFlt">filter</param> /// <param name="serviceConnection">connection</param> /// <param name="service">service</param> /// <param name="lyrID">layerid</param> /// <returns>any messages from the updating processes</returns> public string fillDbFtrClasses(ISpatialFilter sFlt, string serviceConnection, string service, Dictionary<string,int> lyrID) { esriUtil.Forms.RunningProcess.frmRunningProcessDialog rpd = new esriUtil.Forms.RunningProcess.frmRunningProcessDialog(true); rpd.showInSepperateProcess(); rpd.Show(); //rpd.addMessage("Downloading data for " + service + " Map Service"); bool lyrTblNeedsUpdating = false; StringBuilder msg = new StringBuilder(); IWorkspace2 wks2 = (IWorkspace2)servWks; string svID = getServiceOID(serviceConnection,service); IAGSServerConnection2 conn = getServiceConnection(serviceConnection); IAGSServerObjectName3 sobj3 = getServiceObject(conn,service,"MapServer"); IMapServer2 ms2 = getMapService(sobj3); if (ms2 == null) { msg.AppendLine("Could not get map service "+service); rpd.addMessage("Could not get map service "+service); updateServiceTable(serviceConnection); rpd.enableClose(); return msg.ToString(); } IQueryFilter qryFl = new QueryFilterClass(); string mName = ms2.DefaultMapName; IWorkspaceEdit wksE = (IWorkspaceEdit)servWks; bool weEdit = false; if (!wksE.IsBeingEdited()) { wksE.StartEditing(false); weEdit = true; } wksE.StartEditOperation(); IFeatureClass ftrCls; try { int stp = 100 / lyrID.Count; foreach (KeyValuePair<string, int> kvp in lyrID) { string lyrName = kvp.Key; int lyrId = kvp.Value; if (!checkServerLayer(ms2, lyrId, lyrName)) { lyrTblNeedsUpdating = true; msg.AppendLine("Could not find " + lyrName + ". Moving to the next Layer and updating tables."); continue; } else { string x = "Updating records for " + lyrName; rpd.addMessage(x); rpd.stepPGBar(stp); msg.AppendLine(x); } string ftrClassName = lyrName + "_" + svID + "_" + lyrId.ToString(); string fFtrClassName = geoDatabaseUtility.parsName(ftrClassName); int drcd = 1; bool ftrExists = wks2.get_NameExists(esriDatasetType.esriDTFeatureClass, fFtrClassName); if (!ftrExists) { ftrCls = createFtrClass(ms2, lyrId, fFtrClassName); ISchemaLock sLock = (ISchemaLock)ftrCls; try { sLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock); IClassSchemaEdit3 cSchEdit3 = (IClassSchemaEdit3)ftrCls; cSchEdit3.AlterAliasName(lyrName); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { sLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); } } else { ftrCls = fWks.OpenFeatureClass(fFtrClassName); } IGeoDataset geoDSet = (IGeoDataset)ftrCls; ISpatialReference spRf = geoDSet.SpatialReference; ISpatialReference filtSpRf = sFlt.Geometry.SpatialReference; if (spRf.FactoryCode != filtSpRf.FactoryCode) { rpd.addMessage("Transforming extent from " + filtSpRf.Name + " to " + spRf.Name); sFlt = transformCoordinates(sFlt, spRf); } string oidName = ftrCls.OIDFieldName; int maxRecords = getMaxRecords(ms2); List<string> fIdLst = new List<string>(); IFIDSet2 idSet = (IFIDSet2)ms2.QueryFeatureIDs(mName, lyrId, sFlt); rpd.addMessage("Attempting to download " + idSet.Count().ToString() + " records..."); rpd.Refresh(); idSet.Reset(); IFeatureCursor fCur = ftrCls.Search(sFlt, false); IFeature ftr = fCur.NextFeature(); while (ftr != null) { ftr.Delete(); ftr = fCur.NextFeature(); } int fId; int rc = 1; idSet.Next(out fId); while (fId > -1) { if (drcd > maxRecords) { rpd.addMessage("\tDownloading Index " + rc.ToString()); rc+=1; qryFl.WhereClause = String.Join(" or ", fIdLst.ToArray()); IRecordSet rSet = ms2.QueryFeatureData(mName, lyrId, qryFl); IFields rFlds = rSet.Fields; ICursor sCur = rSet.get_Cursor(false); IRow sRow = sCur.NextRow(); while (sRow != null) { fCur = ftrCls.Insert(true); IFeatureBuffer ftrBuff = ftrCls.CreateFeatureBuffer(); for (int f = 0; f < rFlds.FieldCount; f++) { IField rFld = rFlds.get_Field(f); int fIndex = ftrBuff.Fields.FindField(rFld.Name); if (fIndex > -1) { try { ftrBuff.set_Value(fIndex, sRow.get_Value(f)); } catch (Exception e) { Console.WriteLine(e.ToString()); } } } fCur.InsertFeature(ftrBuff); fCur.Flush(); sRow = sCur.NextRow(); } drcd = 1; fIdLst.Clear(); } else { fIdLst.Add(oidName + " = '" + fId.ToString() + "'"); drcd += 1; } idSet.Next(out fId); } if (fIdLst.Count > 0) { rpd.addMessage("\tDownloading Index " + rc.ToString()); qryFl.WhereClause = String.Join(" or ", fIdLst.ToArray()); IRecordSet rSet = ms2.QueryFeatureData(mName, lyrId, qryFl); IFields rFlds = rSet.Fields; ICursor sCur = rSet.get_Cursor(false); IRow sRow = sCur.NextRow(); while (sRow != null) { fCur = ftrCls.Insert(true); IFeatureBuffer ftrBuff = ftrCls.CreateFeatureBuffer(); for (int f = 0; f < rFlds.FieldCount; f++) { IField rFld = rFlds.get_Field(f); if (rFld.Editable) { int fIndex = ftrBuff.Fields.FindField(rFld.Name); if (fIndex > -1) { try { ftrBuff.set_Value(fIndex, sRow.get_Value(f)); } catch (Exception e) { Console.WriteLine(e.ToString()); } } } } fCur.InsertFeature(ftrBuff); fCur.Flush(); sRow = sCur.NextRow(); } } drcd = 1; fIdLst.Clear(); } if (lyrTblNeedsUpdating) { Dictionary<string,int> dic = getLayers(ms2); updateLayerTable(dic,serviceConnection, service); } } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { wksE.StopEditOperation(); if (weEdit) { wksE.StopEditing(true); } rpd.stepPGBar(100); rpd.TopMost = false; rpd.enableClose(); } return msg.ToString(); }