private void AddToDictionaryAndWizardPages(DataGridViewRow item) { EnterpoleGrid fieldGrid = new EnterpoleGrid(); FieldLayerObject fieldLayerObject = new FieldLayerObject(); foreach (EnterpoleField layerField in AppSingleton.Instance().EnterpoleFieldListesi) { if (layerField.LayerObject.layer.Name == item.Cells[0].Value.ToString()) { fieldLayerObject.LayerObject = layerField.LayerObject; fieldGrid.FieldLayerObject = fieldLayerObject; fieldGrid.FieldName = layerField.FieldName; fieldGrid.EnterpoleMethod = layerField.EnterpoleMetodu; fieldGrid.Hedef = layerField.Hedef; break; } } int itemCount = AppSingleton.Instance().EnterpoleItemCount + 1; fieldGrid.GridID = itemCount; AppSingleton.Instance().EnterpoleItemCount = itemCount; IFeatureLayer fLayer = fieldGrid.FieldLayerObject.LayerObject.layer as IFeatureLayer; AppSingleton.Instance().EnterpoleGridDict.Add(fLayer.Name, fieldGrid); UpdateFieldList(fieldGrid.Hedef, fLayer.Name);//UtilMethods.CountUniques((ITable)fLayer.FeatureClass, fieldGrid.FieldName); fieldGrid.SetLabel(fLayer.Name); AppSingleton.Instance().wizardHost.WizardPages.Add(itemCount, fieldGrid); }
private void AddToDictionary(DataGridViewRow item) { LayerType fieldGrid = new LayerType(); FieldLayerObject fieldLayerObject = new FieldLayerObject(); foreach (LayerType layerType in AppSingleton.Instance().TumKatmanlarListesi) { if (layerType.LayerObject.layer.Name == item.Cells[0].Value.ToString()) { fieldLayerObject.LayerObject = layerType.LayerObject; fieldGrid.Metod = item.Cells[1].Value.ToString(); fieldGrid.LayerObject = layerType.LayerObject; break; } } int itemCount = AppSingleton.Instance().PolyItemCount + 1; IFeatureLayer fLayer = fieldGrid.LayerObject.layer as IFeatureLayer; AppSingleton.Instance().AllLayersDict.Add(fLayer.Name, fieldGrid); }
private void FillPoligonUniqueValues(List <LayerField> poligonListesi) { if (AppSingleton.Instance().ReclassList == null) { AppSingleton.Instance().ReclassList = new List <FieldLayerObject>(); } foreach (var item in poligonListesi) { FieldLayerObject fLayerObject = new FieldLayerObject(); fLayerObject.LayerObject = item.LayerObject; fLayerObject.FieldName = item.FieldName; var dict = UtilMethods.CountUniques((ITable)(item.LayerObject.layer as IFeatureLayer).FeatureClass, item.FieldName); var counter = 0; for (int i = dict.Count - 1; i >= 0; i--) { counter++; KeyValuePair <string, string> pair = dict.ElementAt(i); dict[pair.Key] = counter.ToString(); } fLayerObject.FieldList = dict; AppSingleton.Instance().ReclassList.Add(fLayerObject); } }
private void host_WizardCompleted() { AppSingleton.Instance().CreateWorkspacePath(); if (AppSingleton.Instance().SettingsControl == null) { SettingsControl control = new SettingsControl(); control.Load(); control.CheckForm(); } lastControl.SetRichTextBoxLabel("Veriler çalışma alanı sınırlarına göre kesiliyor..."); foreach (var item in AppSingleton.Instance().allLayers) { if (!ClipLayers(item.layer)) { MessageBox.Show("Hata Kodu :1103 . Lütfen yöneticiniz ile görüşünüz."); return; } } lastControl.SetRichTextBoxLabel("İşlem tamamlandı..."); foreach (var item in AppSingleton.Instance().PolygonLayerList) { FieldLayerObject fieldLayerObject = GetFieldLayerObject(item.layer.Name); if (fieldLayerObject == null) { MessageBox.Show("Hata Kodu :1110 . Lütfen yöneticiniz ile görüşünüz."); return; } lastControl.SetRichTextBoxLabel(item.layer.Name + " katmanı için raster dönüşüm yapılıyor..."); if (!PolygonToRaster(item.layer, "Clip_", fieldLayerObject.FieldName, "")) { MessageBox.Show("Hata Kodu :1111 . Lütfen yöneticiniz ile görüşünüz."); return; } lastControl.SetRichTextBoxLabel("İşlem tamamlandı..."); Dictionary <string, string> myDict = fieldLayerObject.FieldList; string reclassifyList = ""; foreach (var pair in myDict) { var key = pair.Key; if (key.Contains(" ")) { key = "'" + key + "'"; } if (reclassifyList == "") { reclassifyList = key + " " + pair.Value + ";"; } else { reclassifyList = reclassifyList + key + " " + pair.Value + ";"; } } reclassifyList = reclassifyList + "NODATA " + AppSingleton.Instance().NodataValue; lastControl.SetRichTextBoxLabel(item.layer.Name + " katmanı yeniden sınıflandırılıyor..."); IFeatureClass fclass = (AppSingleton.Instance().PersonalWorkspace as IFeatureWorkspace).OpenFeatureClass("Poly_Raster_" + item.layer.Name); Type factoryType = Type.GetTypeFromProgID( "esriDataSourcesGDB.AccessWorkspaceFactory"); IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance (factoryType); IRasterWorkspaceEx rasterWorkspaceEx = workspaceFactory.OpenFromFile(AppSingleton.Instance().WorkspacePath, 0) as IRasterWorkspaceEx; //IRasterWorkspace rasterWorkspace = AppSingleton.Instance().PersonalWorkspace as IRasterWorkspace; IRasterDataset rasterDataset = rasterWorkspaceEx.OpenRasterDataset("Poly_Raster_" + item.layer.Name); IRasterDatasetEdit2 raster = (IRasterDatasetEdit2)rasterDataset; ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset = (ESRI.ArcGIS.Geodatabase.IGeoDataset)rasterDataset; raster.BuildAttributeTable(); ITable vat = (raster as IRasterBandCollection).Item(0).AttributeTable; //Check if field Exists var check = false; for (int j = 0; j < vat.Fields.FieldCount; j++) { IField field = vat.Fields.get_Field(j); if (field.Name == fieldLayerObject.FieldName) { check = true; } } if (!check) { lastControl.SetRichTextBoxLabel("Eksik kolonlar ekleniyor..."); if (!JoinField(vat, "Value", item.layer.Name, fieldLayerObject.FieldName, fieldLayerObject.FieldName)) { MessageBox.Show("Hata Kodu :5614 . Lütfen yöneticiniz ile görüşünüz."); return; } } string returnStr = SetFieldToValue(vat, fieldLayerObject.FieldName); bool aragecis = true; if (!Reclassify(item.layer, "Value", returnStr, "Poly_Raster_", "TempReclass_")) { aragecis = false; } if (aragecis == true) { if (!Reclassify(item.layer, "Value", reclassifyList, "TempReclass_", "Reclassified_")) { MessageBox.Show("Hata Kodu :1112 . Lütfen yöneticiniz ile görüşünüz."); return; } } else { if (!Reclassify(item.layer, fieldLayerObject.FieldName, reclassifyList, "Poly_Raster_", "Reclassified_")) { MessageBox.Show("Hata Kodu :1112 . Lütfen yöneticiniz ile görüşünüz."); return; } } IRasterDataset reclassedDataset = rasterWorkspaceEx.OpenRasterDataset("Reclassified_" + item.layer.Name); IRasterDatasetEdit2 reclassed = (IRasterDatasetEdit2)reclassedDataset; ESRI.ArcGIS.Geodatabase.IGeoDataset reclassedGeoDataset = (ESRI.ArcGIS.Geodatabase.IGeoDataset)reclassedDataset; reclassed.BuildAttributeTable(); ITable vatReclass = (reclassed as IRasterBandCollection).Item(0).AttributeTable; //Check if field Exists var checkReclass = false; for (int j = 0; j < vatReclass.Fields.FieldCount; j++) { IField field = vatReclass.Fields.get_Field(j); if (field.Name == fieldLayerObject.FieldName) { checkReclass = true; } } if (!checkReclass) { if (!JoinField(vatReclass, "Value", item.layer.Name, fieldLayerObject.FieldName, fieldLayerObject.FieldName)) { MessageBox.Show("Hata Kodu :5614 . Lütfen yöneticiniz ile görüşünüz."); return; } } lastControl.SetRichTextBoxLabel("İşlem tamamlandı..."); } string rasterString = string.Empty; foreach (var item in reclassList) { if (rasterString == string.Empty) { rasterString = item; } else { rasterString = rasterString + ";" + item; } } foreach (var item in AppSingleton.Instance().RasterLayerList) { if (rasterString == string.Empty) { rasterString = item.Name; } else { rasterString = rasterString + ";" + item.Name; } } lastControl.SetRichTextBoxLabel("Tüm raster katmanlar birleştiriliyor..."); if (!Combine(rasterString)) { MessageBox.Show("Hata Kodu :2639. Lütfen yöneticiniz ile görüşünüz."); return; } //Combine işlemleri Type factoryType2 = Type.GetTypeFromProgID( "esriDataSourcesGDB.AccessWorkspaceFactory"); IWorkspaceFactory workspaceFactory2 = (IWorkspaceFactory)Activator.CreateInstance (factoryType2); IRasterWorkspaceEx rasterWorkspaceEx2 = workspaceFactory2.OpenFromFile(AppSingleton.Instance().WorkspacePath, 0) as IRasterWorkspaceEx; //IRasterWorkspace rasterWorkspace = PersonalWorkspace as IRasterWorkspace; IRasterDataset rasterDataset2 = rasterWorkspaceEx2.OpenRasterDataset("Ekolojik_Sit_Alani"); IRasterDatasetEdit2 raster2 = (IRasterDatasetEdit2)rasterDataset2; ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset2 = (ESRI.ArcGIS.Geodatabase.IGeoDataset)rasterDataset2; raster2.BuildAttributeTable(); ITable vat2 = (raster2 as IRasterBandCollection).Item(0).AttributeTable; List <string> fieldList = new List <string>(); for (int j = 0; j < vat2.Fields.FieldCount; j++) { IField field = vat2.Fields.get_Field(j); if (field.Name.ToUpper() != "OID" && field.Name.ToUpper() != "VALUE" && field.Name.ToUpper() != "COUNT") { fieldList.Add(field.Name); } } lastControl.SetRichTextBoxLabel("Final katmanında eksik kolonlar tanımlanıyor..."); for (int i = 0; i < AppSingleton.Instance().PolygonLayerList.Count; i++) { var item = AppSingleton.Instance().PolygonLayerList[i]; FieldLayerObject fieldLayerObject = GetFieldLayerObject(item.layer.Name); var reclassifiedlayername = AppSingleton.Instance().WorkspacePath + "\\Reclassified_" + item.layer.Name; if (!JoinField(vat2, fieldList[i], reclassifiedlayername, "Value", fieldLayerObject.FieldName)) { MessageBox.Show("Hata Kodu :5614 . Lütfen yöneticiniz ile görüşünüz."); return; } } //foreach (var item in reclassList) //{ // IFeatureClass fclass = (AppSingleton.Instance().PersonalWorkspace as IFeatureWorkspace).OpenFeatureClass(item); // Type factoryType = Type.GetTypeFromProgID( // "esriDataSourcesGDB.AccessWorkspaceFactory"); // string guid = Guid.NewGuid().ToString(); // IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance // (factoryType); // IRasterWorkspaceEx rasterWorkspaceEx = workspaceFactory.OpenFromFile(AppSingleton.Instance().WorkspacePath, 0) as IRasterWorkspaceEx; // //IRasterWorkspace rasterWorkspace = AppSingleton.Instance().PersonalWorkspace as IRasterWorkspace; // IRasterDataset rasterDataset = rasterWorkspaceEx.OpenRasterDataset(item); // IRasterDatasetEdit2 raster = (IRasterDatasetEdit2)rasterDataset; // ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset = (ESRI.ArcGIS.Geodatabase.IGeoDataset)rasterDataset; // raster.BuildAttributeTable(); // ITable vat = (raster as IRasterBandCollection).Item(0).AttributeTable; // //IFeatureClass fclass= (AppSingleton.Instance().PersonalWorkspace as IFeatureWorkspace).OpenFeatureClass(item); // List<double> valueList = GetUniques(vat as ITable, "Value"); // double max = FindMaxValue(valueList); // double min = FindMinValue(valueList); // IFeatureLayer fLayer = new FeatureLayerClass(); // fLayer.Name = item; // fLayer.FeatureClass = fclass; // lastControl.SetRichTextBoxLabel("Öznitelik ekleniyor..."); // AddField(fLayer, "Normal", ""); // lastControl.SetRichTextBoxLabel("İşlem tamamlandı..."); // lastControl.SetRichTextBoxLabel("Normalleştirme işlemi yapılıyor..."); // foreach (var myLayer in AppSingleton.Instance().AllLayersDict) // { // string layerName = myLayer.Key; // if ("Reclassified_" + layerName == item) // { // LayerType lType = myLayer.Value; // switch (lType.Metod) // { // case "x/Maks": // SetFirstNormal(vat, max); // break; // case "1-(x/Maks)": // SetSecondNormal(vat, max); // break; // case "(x-Min)/(Maks-Min)": // SetThirdNormal(vat, max, min); // break; // case "(Maks-x)/(Maks-Min)": // SetFourthNormal(vat, max, min); // break; // default: // Console.WriteLine("Invalid selection. Please select 1, 2, or 3."); // break; // } // } // } // lastControl.SetRichTextBoxLabel("İşlem tamamlandı..."); //} lastControl.SetRichTextBoxLabel("İşlem tamamlandı..."); //this.Dispose(); //MessageBox.Show("Done!"); //obviously you'd do something else in a real app... }