private int method_7(string string_3, ITable itable_0) { try { ITableHistogram tableHistogram = new BasicTableHistogram() as ITableHistogram; tableHistogram.Table = itable_0; tableHistogram.Field = string_3; ITableHistogram histogram = tableHistogram as ITableHistogram; if ((histogram as IStatisticsResults).Count == 0) { return(0); } return((int)(histogram as IStatisticsResults).Maximum); } catch (Exception exception) { Logger.Current.Error("", exception, ""); } return(1); }
/// <summary> /// Retorna o objectid com valor no campo passado /// </summary> /// <param name="className">Nome da classe (Table ou FeatureClass)</param> /// <param name="fieldName">Nome do campo</param> /// <param name="condicaoExtra">Caso haja uma condição extra posicionar nesta variável</param> /// <returns>Objectid o registro que atende a máxima condição em relação ao fieldName passado</returns> public static int GetLastObjectID(string className, string fieldName, string condicaoExtra) { if (string.IsNullOrEmpty(className) && string.IsNullOrEmpty(fieldName)) throw new Exception("Parâmetros não preenchidos"); IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)ws; (featureWorkspace as IVersion).RefreshVersion(); ITable table = featureWorkspace.OpenTable(className); if (table == null) throw new Exception("Classe não existe"); // ESRI.ArcGIS.Carto.ITableHistogram tableHistogram = new BasicTableHistogram bh = new BasicTableHistogram(); ITableHistogram th = bh as ITableHistogram; th.Table = table; th.Field = fieldName; IStatisticsResults statisticResult = th as IStatisticsResults; IQueryFilter qf = new QueryFilterClass(); DateTime dateTime = DateTime.FromOADate(statisticResult.Maximum); string extraCondition = String.Empty; if (condicaoExtra != String.Empty) extraCondition = " AND " + condicaoExtra; qf.SubFields = "*"; qf.WhereClause = fieldName + "=" + "timestamp '" + dateTime.ToString(TimestampFormat) + "'" + extraCondition; ICursor cursor = table.Search(qf, false); IRow row = cursor.NextRow(); if (row != null) { return Convert.ToInt32(row.OID); } else { throw new Exception("Tabela sem registros"); } }
public static void UsingRasterClassifyRendered(IRasterLayer irasterLayer_0, int int_0, string string_0) { try { bool flag; IRaster raster = irasterLayer_0.Raster; IRasterBand band = (raster as IRasterBandCollection).Item(0); band.HasTable(out flag); if (flag) { int num2; bool flag2; IRasterClassifyColorRampRenderer renderer = new RasterClassifyColorRampRenderer(); IRasterRenderer renderer2 = renderer as IRasterRenderer; renderer2.Raster = raster; ITable attributeTable = band.AttributeTable; ITableHistogram tableHistogram = new BasicTableHistogram() as ITableHistogram; tableHistogram.Field = string_0; tableHistogram.Table = attributeTable; ITableHistogram histogram = tableHistogram as ITableHistogram; double maximum = (histogram as IStatisticsResults).Maximum; IClassify classify = new EqualInterval() as IClassify; (classify as IClassifyMinMax).Minimum = (histogram as IStatisticsResults).Minimum; (classify as IClassifyMinMax).Maximum = (histogram as IStatisticsResults).Maximum; int_0--; classify.Classify(ref int_0); object classBreaks = classify.ClassBreaks; UID classID = classify.ClassID; IRasterClassifyUIProperties properties = renderer as IRasterClassifyUIProperties; properties.ClassificationMethod = classID; renderer.ClassCount = int_0; renderer.ClassField = string_0; for (num2 = 0; num2 < int_0; num2++) { renderer.set_Break(num2, ((double[])classBreaks)[num2]); } IColorRamp ramp = ColorManage.CreateColorRamp(); ramp.Size = int_0; ramp.CreateRamp(out flag2); IFillSymbol symbol = new SimpleFillSymbol(); for (num2 = 0; num2 < renderer.ClassCount; num2++) { double num4; symbol.Color = ramp.get_Color(num2); renderer.set_Symbol(num2, symbol as ISymbol); double num3 = ((double[])classBreaks)[num2]; if (num2 == (renderer.ClassCount - 1)) { num4 = maximum; } else { num4 = ((double[])classBreaks)[num2 + 1]; } renderer.set_Label(num2, num3.ToString() + "-" + num4.ToString()); } renderer2.Update(); irasterLayer_0.Renderer = renderer as IRasterRenderer; } else { UsingRasterClassifyRendered1(irasterLayer_0, int_0, string_0); } } catch (Exception exception) { CErrorLog.writeErrorLog(null, exception, "栅格渲染"); } }