本文整理汇总了C#中QueryFilterClass.AddField方法的典型用法代码示例。如果您正苦于以下问题:C# QueryFilterClass.AddField方法的具体用法?C# QueryFilterClass.AddField怎么用?C# QueryFilterClass.AddField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryFilterClass
的用法示例。
在下文中一共展示了QueryFilterClass.AddField方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpecialPointRenderer
/// <summary>
/// ����Ҫ�ط��Ż�
/// </summary>
/// <params name="layer"></params>
/// <params name="field"></params>
/// <params name="value"></params>
/// <params name="pBitmap"></params>
public static void SpecialPointRenderer(ILayer layer, string field, string value, Bitmap pBitmap)
{
IGeoFeatureLayer geoFeaLayer;
IFeatureRenderer featureRenderer;
ISymbol defaultSymbol;
IUniqueValueRenderer uniValueRender;
geoFeaLayer = layer as IGeoFeatureLayer;
featureRenderer = geoFeaLayer.Renderer;
uniValueRender = new UniqueValueRenderer();
///ѡ��ij���ֶ���Ϊ��Ⱦ����ֵ
IQueryFilter2 queryFilter = new QueryFilterClass();
int fieldIndex;
uniValueRender.FieldCount = 1;
uniValueRender.Field[0] = field;
queryFilter.AddField(field);
fieldIndex = geoFeaLayer.FeatureClass.Fields.FindField(field);//����ֶε�index
///��ȡ�Զ������
ISymbol customSymbol;
IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
pictureMarkerSymbol.Size = 55;
string strFilePath = Application.StartupPath.ToString() + "\\temp.bmp";
pBitmap.Save(strFilePath);
pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG,
strFilePath);
customSymbol = (ISymbol)pictureMarkerSymbol;
///������Ⱦ���Ž�����Ⱦ
string sValue;
IFeature feature = null;
IFeatureCursor featureCursor;
featureCursor = geoFeaLayer.FeatureClass.Search(queryFilter, true);
feature = featureCursor.NextFeature();
while (feature != null)
{
sValue = Convert.ToString(feature.get_Value(fieldIndex));
if (sValue == value)
{
uniValueRender.AddValue(sValue, "", customSymbol);
}
else
{
///�ǵ�ǰ��ѡҪ�أ�����ű��ֲ���
defaultSymbol = geoFeaLayer.Renderer.get_SymbolByFeature(feature);
uniValueRender.AddValue(sValue, "", defaultSymbol);
}
feature = featureCursor.NextFeature();
}
if (featureCursor != null)
{
featureCursor = null;
ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(featureCursor);
}
geoFeaLayer.Renderer = uniValueRender as IFeatureRenderer;
}
示例2: PieRender
public PieRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, string pFieldName1, string pFieldName2)
{
IGeoFeatureLayer pGeoFeaLayer = (IGeoFeatureLayer)pFtLayer;
IChartRenderer pChartRenderer = new ChartRendererClass();
// Set up the field to draw charts
IRendererFields pRenderFields = (IRendererFields)pChartRenderer;
pRenderFields.AddField(pFieldName1, pFieldName1);
pRenderFields.AddField(pFieldName2, pFieldName2);
IPieChartRenderer pPieChartRender = (IPieChartRenderer)pChartRenderer;
//计算最大值部分有待补充////////////////////////////////////
//Calculate the max value of the data field to scale the chart
//ICursor pCursor = new CursorClass();
IQueryFilter pQueryFilter = new QueryFilterClass();
//IRowBuffer pRow = new RowBufferClass();
ITable pTable = (ITable)pGeoFeaLayer;
pQueryFilter.AddField(pFieldName1);
ICursor pCursor = pTable.Search(pQueryFilter, true);
IDataStatistics pDataStat = new DataStatisticsClass();
IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);
pDataStat.Cursor = pFtCursor as ICursor;
pDataStat.Field = pFieldName1;
double pMax = pDataStat.Statistics.Maximum;
IPieChartSymbol pPiechartSymbol = new PieChartSymbolClass();
IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
IChartSymbol pChartSymbol = (IChartSymbol)pPiechartSymbol;
pPiechartSymbol.Clockwise = true;
pPiechartSymbol.UseOutline = true;
ILineSymbol pOutLine = new SimpleLineSymbolClass();
pOutLine.Color = GetRGBColor(255, 0, 255);
pOutLine.Width = 1;
pPiechartSymbol.Outline = pOutLine;
IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)pPiechartSymbol;
//finally
pChartSymbol.MaxValue = pMax;
pMarkerSymbol.Size = 16;
//像符号数组中添加 添加符号
ISymbolArray pSymbolArray = (ISymbolArray)pPiechartSymbol;
pFillSymbol.Color = GetRGBColor(213, 212, 252);
pFillSymbol.Outline = pOutLine;
pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
//////////////////////////
pFillSymbol.Color = GetRGBColor(183, 242, 122);
pFillSymbol.Outline = pOutLine;
pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
//set up the background
pFillSymbol.Color = GetRGBColor(239, 228, 190);
pChartRenderer.BaseSymbol = (ISymbol)pFillSymbol;
pChartRenderer.UseOverposter = false;
pPieChartRender.MinSize = 1;
pPieChartRender.MinValue = pDataStat.Statistics.Minimum;
pPieChartRender.FlanneryCompensation = false;
pPieChartRender.ProportionalBySum = true;
pChartRenderer.ChartSymbol = (IChartSymbol)pPiechartSymbol;
pChartRenderer.CreateLegend();
pGeoFeaLayer.Renderer = (IFeatureRenderer)pChartRenderer;
pMapcontrol.ActiveView.Refresh();
}
示例3: SpecialLineRenderer2
public static void SpecialLineRenderer2(ILayer layer, string field, string value, ILineSymbol lineSymbol)
{
var geoFeaLayer = layer as IGeoFeatureLayer;
IUniqueValueRenderer uniValueRender = new UniqueValueRenderer();
IQueryFilter2 queryFilter = new QueryFilterClass();
uniValueRender.FieldCount = 1;
uniValueRender.Field[0] = field;
queryFilter.AddField(field);
if (geoFeaLayer != null)
{
var fieldIndex = geoFeaLayer.FeatureClass.Fields.FindField(field);
var customSymbol = (ISymbol)lineSymbol;
var featureCursor = geoFeaLayer.FeatureClass.Search(queryFilter, true);
var feature = featureCursor.NextFeature();
while (feature != null)
{
var sValue = Convert.ToString(feature.Value[fieldIndex]);
if (sValue == value)
{
uniValueRender.AddValue(sValue, "", customSymbol);
}
else
{
var defaultSymbol = geoFeaLayer.Renderer.SymbolByFeature[feature];
uniValueRender.AddValue(sValue, "", defaultSymbol);
}
feature = featureCursor.NextFeature();
}
}
ComReleaser.ReleaseCOMObject(null);
//System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor); //释放指针
if (geoFeaLayer != null) geoFeaLayer.Renderer = uniValueRender as IFeatureRenderer;
}
示例4: btnProportionalSymbolRender_Click
private void btnProportionalSymbolRender_Click(object sender, EventArgs e)
{
IGeoFeatureLayer pGeoFeatLyr = (IGeoFeatureLayer)this.mainMapControl.get_Layer(0);
ITable pTable = pGeoFeatLyr as ITable;
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.AddField("GDP_1999(");
pQueryFilter.WhereClause = "";
ICursor pCursor;//DataStatistic对象统计需要用一个Cursor
pCursor = pTable.Search(pQueryFilter, true);
IDataStatistics pDataStatistics = new DataStatisticsClass();//用于统计字段信息,需要一个Cursor
pDataStatistics.Cursor = pCursor;
pDataStatistics.Field = "GDP_1999(";
IStatisticsResults pStatisticsResults;//字段统计结果
pStatisticsResults = pDataStatistics.Statistics;
ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();//用于背景
pSimpleFillSymbol.Color = this.getHsvColor(60, 120, 60);
ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();//标注符号(最小),注意size属性
pSimpleMarkerSymbol.Color = this.getHsvColor(120, 100, 75);
pSimpleMarkerSymbol.Size = 0.5;
//以下创建并设置着色对象
IProportionalSymbolRenderer pProportionalSymbolRenderer = new ProportionalSymbolRendererClass();
pProportionalSymbolRenderer.ValueUnit = esriUnits.esriUnknownUnits;
pProportionalSymbolRenderer.Field = "GDP_1999(";
pProportionalSymbolRenderer.FlanneryCompensation = false;
pProportionalSymbolRenderer.MinDataValue = 1;//为什么用pStatisticsResults.Minimum会出错??????????
pProportionalSymbolRenderer.MaxDataValue = pStatisticsResults.Maximum;
pProportionalSymbolRenderer.BackgroundSymbol = pSimpleFillSymbol as IFillSymbol;
pProportionalSymbolRenderer.MinSymbol = pSimpleMarkerSymbol as ISymbol;//最小值的符号,关键!!!!!!!
pProportionalSymbolRenderer.LegendSymbolCount = 3;
pProportionalSymbolRenderer.CreateLegendSymbols();
pGeoFeatLyr.Renderer = pProportionalSymbolRenderer as IFeatureRenderer;
this.mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
this.axTOCControl.Update();
}
示例5: UniqueValueRender_Click
private void UniqueValueRender_Click(object sender, EventArgs e)
{
//
ITable pTable= (ITable)this.mainMapControl.get_Layer(0);
int fieldIndex = pTable.FindField("NAME");//取得"NAME"字段的index,关键
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = "";
pQueryFilter.AddField("NAME");
//IFeatureCursor pFeatureCursor = pTable.Search(pQueryFilter, false);
int rowCount = pTable.RowCount(pQueryFilter);//取得"NAME"字段有值得行的数目,关键!!!!!
//以下代码创建并设置随机颜色带对象,并生成颜色
IRandomColorRamp pColorRamp = new RandomColorRampClass();
pColorRamp.StartHue = 0;
pColorRamp.MinValue = 99;
pColorRamp.MinSaturation = 15;
pColorRamp.EndHue = 360;
pColorRamp.MaxValue = 100;
pColorRamp.MaxSaturation = 30;
pColorRamp.Size = rowCount;
bool ok = true;
pColorRamp.CreateRamp(out ok);//产生颜色
if (ok)
{
IEnumColors pEnumColors = pColorRamp.Colors;
ISimpleFillSymbol pSimpleFillSymbol;
IRowBuffer pRowBuffer;
IColor pColor;
string value;
IUniqueValueRenderer pUniqueValueRenderer = new UniqueValueRendererClass();//创建着色对象
pUniqueValueRenderer.FieldCount = 1;//设置只对一个字段进行着色
pUniqueValueRenderer.set_Field(0, "NAME");
for (int i = 0; i < rowCount; i++)
{
pRowBuffer = (IRowBuffer)pTable.GetRow(i);//关键,用于取得字段值
value = pRowBuffer.get_Value(fieldIndex).ToString();
pColor = pEnumColors.Next();
pSimpleFillSymbol = new SimpleFillSymbolClass();
pSimpleFillSymbol.Color = pColor;
pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
pUniqueValueRenderer.AddValue(value, "", (ISymbol)pSimpleFillSymbol);//为每个唯一值设置Symbol,关键!!!!!!
}
//ITransparencyRenderer pTransparencyRenderer = pUniqueValueRenderer as ITransparencyRenderer;
//pTransparencyRenderer.TransparencyField = "";
((IGeoFeatureLayer)pTable).Renderer = pUniqueValueRenderer as IFeatureRenderer;
this.mainMapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
//this.axTOCControl.SetBuddyControl(this.mainMapControl.Object);
this.axTOCControl.Update();
}
}
示例6: btnAddAllValues_Click
private void btnAddAllValues_Click(object sender, EventArgs e)
{
//��ʼ���ͼ��ı����ֶε���Ϣ
IFillSymbol pSymbol;
IColor pColor;
IColor pNextUniqueColor;
IEnumColors pEnumRamp;
IQueryFilter pQueryFilter;
ICursor pCursor;
IRow pNextRow;
IRowBuffer pNextRowBuffer;
object objTempValue="";
object objCodeValue;
ITable pTable = pFeatLayer as ITable;
IRandomColorRamp pColorRamp = new RandomColorRampClass();
m_colValues=new ArrayClass();
if (comboBoxUnique.Text != "")
{
int iFieldNo = pTable.FindField(comboBoxUnique.Text);
if (iFieldNo != -1)
{
for (int i = 0; i <= 2; i++)
{
if (comboBoxEx1.SelectedIndex == i)
{
pColorRamp.StartHue = m_intColorRampArray[i, 0];
pColorRamp.EndHue = m_intColorRampArray[i, 1];
pColorRamp.MinValue = m_intColorRampArray[i, 2];
pColorRamp.MaxValue = m_intColorRampArray[i, 3];
pColorRamp.MinSaturation = m_intColorRampArray[i, 4];
pColorRamp.MaxSaturation = m_intColorRampArray[i, 5];
}
}
pColorRamp.Size = 100;
bool ok=true;
pColorRamp.CreateRamp(out ok);
pEnumRamp = pColorRamp.Colors;
pQueryFilter = new QueryFilterClass();
pQueryFilter.AddField(comboBoxUnique.Text);
pCursor = pTable.Search(pQueryFilter, true);
pNextRow = pCursor.NextRow();
m_intSymbolsNum = 0;
//�����״ͼ��
if (m_strShapeType == "Fill Symbols")
{
IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
m_pSymbolsArray = new ESRI.ArcGIS.esriSystem.ArrayClass();
while (pNextRow != null)
{
pNextRowBuffer = pNextRow as IRowBuffer;
objCodeValue=pNextRowBuffer.get_Value(iFieldNo);
if ((objTempValue != objCodeValue) || (m_intSymbolsNum == 0))
{
pNextUniqueColor = pEnumRamp.Next();
if (pNextUniqueColor == null)
{
pEnumRamp.Reset();
pNextUniqueColor = pEnumRamp.Next();
}
pFillSymbol.Color = pNextUniqueColor;
m_pSymbolsArray.Add(pFillSymbol);
m_colValues.Add(objCodeValue);
m_intSymbolsNum += 1;
objTempValue = objCodeValue;
pFillSymbol = null;
}
pNextRow = pCursor.NextRow();
}
}
//��ͼ��
if (m_strShapeType == "Line Symbols")
{
ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
m_pSymbolsArray.RemoveAll();
while (pNextRow != null)
{
pNextRowBuffer = pNextRow as IRowBuffer;
objCodeValue = pNextRowBuffer.get_Value(iFieldNo);
if ((objTempValue != objCodeValue) || (m_intSymbolsNum == 0))
{
pNextUniqueColor = pEnumRamp.Next();
if (pNextUniqueColor == null)
{
pEnumRamp.Reset();
pNextUniqueColor = pEnumRamp.Next();
}
pLineSymbol.Color = pNextUniqueColor;
m_pSymbolsArray.Add(pLineSymbol);
m_colValues.Add(objCodeValue);
m_intSymbolsNum += 1;
objTempValue = objCodeValue;
pLineSymbol = null;
}
pNextRow = pCursor.NextRow();
}
}
//��ͼ��
if (m_strShapeType == "Marker Symbols")
//.........这里部分代码省略.........
示例7: btnUniValueAddAllValues_Click
/// <summary>
/// 按下"添加所有值"按钮后,让table按当前字段的值进行排序,并把信息添加到listView里面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnUniValueAddAllValues_Click(object sender, EventArgs e)
{
try
{
string currentFieldName = this.cbbUniValueField.Text;//当前字段名
string currentFieldType = this.lsvFields.FindItemWithText(currentFieldName).SubItems[2].Text;//当前字段类型
bool currentTypeIsNumeric = false;//判断当前字段类型是否为数字类型
if (currentFieldType == "Short Integer" || currentFieldType == "Long Integer" || currentFieldType == "Float" || currentFieldType == "Double")
{
currentTypeIsNumeric = true;
}
this.lsvUniqueValue.Items.Clear();
//对Table中当前字段进行排序,把结果赋给Cursor
ITable pTable = this.pLayer as ITable;
ITableSort pTableSort = new TableSortClass();
pTableSort.Table = pTable;
pTableSort.Fields = currentFieldName;
pTableSort.set_Ascending(currentFieldName, true);
pTableSort.set_CaseSensitive(currentFieldName, true);
pTableSort.Sort(null);//排序
ICursor pCursor = pTableSort.Rows;
//字段统计
IDataStatistics pDataStatistics = new DataStatisticsClass();
pDataStatistics.Cursor = pCursor;
pDataStatistics.Field = currentFieldName;
System.Collections.IEnumerator pEnumeratorUniqueValues = pDataStatistics.UniqueValues;//唯一值枚举
int uniqueValueCount = pDataStatistics.UniqueValueCount;//唯一值的个数
//table中当前字段有值(不为null)的row的个数,并把信息添加到listView的第一行
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.AddField(currentFieldName);
int valueSum = pTable.RowCount(pQueryFilter);
this.lsvUniqueValue.Items.Add(currentFieldName);
this.lsvUniqueValue.Items[0].SubItems.Add(currentFieldName);
this.lsvUniqueValue.Items[0].SubItems.Add(valueSum.ToString());
//循环把信息添加到listView里
int i = 1;//注意!是从1开始,因为第一行已经被占用
string currentValue = null;//指示当前的值
//IDataStatistics pUniValueStatistics = new DataStatisticsClass();
int currentValueCount;
for (pEnumeratorUniqueValues.Reset(); pEnumeratorUniqueValues.MoveNext(); i++)
{
currentValue = pEnumeratorUniqueValues.Current.ToString();//当前值
this.lsvUniqueValue.Items.Add(currentValue);
this.lsvUniqueValue.Items[i].SubItems.Add(currentValue);
//需要这个if的原因是SQL语句中数字和非数字的写法不一样
if (currentTypeIsNumeric)
{
pQueryFilter.WhereClause = "\"" + currentFieldName + "\"" + " = " + currentValue;
}
else
{
pQueryFilter.WhereClause = "\"" + currentFieldName + "\"" + " = " + "'" + currentValue + "'";
}
currentValueCount = pTable.RowCount(pQueryFilter);//table中该字段是当前值的row的个数
this.lsvUniqueValue.Items[i].SubItems.Add(currentValueCount.ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例8: UniqueValueRenderer
//进行唯一值渲染
private void UniqueValueRenderer(IFeatureLayer featureLayer, string FieldName)
{
int FieldIndex = featureLayer.FeatureClass.Fields.FindField(FieldName);
IUniqueValueRenderer uniqueValueRenderer = new UniqueValueRendererClass();
uniqueValueRenderer.FieldCount = 1;
uniqueValueRenderer.set_Field(0, FieldName);
IRandomColorRamp randomColorRamp = new RandomColorRampClass();
randomColorRamp.StartHue = 0;
randomColorRamp.MinValue = 0;
randomColorRamp.MinSaturation = 15;
randomColorRamp.EndHue = 360;
randomColorRamp.MaxValue = 100;
randomColorRamp.MaxSaturation = 30;
IQueryFilter queryFilter = new QueryFilterClass();
randomColorRamp.Size = featureLayer.FeatureClass.FeatureCount(queryFilter);
bool flag = false;
randomColorRamp.CreateRamp(out flag);
IEnumColors enumColors = randomColorRamp.Colors;
IColor color = null;
object codeValue = null;
queryFilter = new QueryFilterClass();
queryFilter.AddField(FieldName);
IFeatureCursor featureCursor= featureLayer.FeatureClass.Search(queryFilter, true);
IFeature feature = featureCursor.NextFeature();
while (feature != null)
{
codeValue = feature.get_Value(FieldIndex);
color = enumColors.Next();
if (color == null)
{
enumColors.Reset();
color = enumColors.Next();
}
ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
simpleLineSymbol.Color = color;
uniqueValueRenderer.AddValue(codeValue.ToString(), "", simpleLineSymbol as ISymbol);
feature = featureCursor.NextFeature();
}
IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer;
geoFeatureLayer.Renderer = uniqueValueRenderer as IFeatureRenderer;
System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
axMapControl1.Refresh();
axMapControl1.Update();
}