本文整理汇总了C#中FieldClass类的典型用法代码示例。如果您正苦于以下问题:C# FieldClass类的具体用法?C# FieldClass怎么用?C# FieldClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldClass类属于命名空间,在下文中一共展示了FieldClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InMemoryWorkspaceFactoryClass
private void 添加点型图层ToolStripMenuItem_Click(object sender, EventArgs e)
{
//创建要素类
#region 创建新的内存工作空间
IWorkspaceFactory pWSF = new InMemoryWorkspaceFactoryClass();
IWorkspaceName pWSName = pWSF.Create("", "Temp", null, 0);
IName pName = (IName)pWSName;
IWorkspace pMemoryWS = (IWorkspace)pName.Open();
#endregion
IField oField = new FieldClass();
IFields oFields = new FieldsClass();
IFieldsEdit oFieldsEdit = null;
IFieldEdit oFieldEdit = null;
IFeatureClass oFeatureClass = null;
IFeatureLayer oFeatureLayer = null;
oFieldsEdit = oFields as IFieldsEdit;
oFieldEdit = oField as IFieldEdit;
oFieldEdit.Name_2 = "OBJECTID";
oFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
oFieldEdit.IsNullable_2 = false;
oFieldEdit.Required_2 = false;
oFieldsEdit.AddField(oField);
oField = new FieldClass();
oFieldEdit = oField as IFieldEdit;
IGeometryDef pGeoDef = new GeometryDefClass();
IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
pGeoDefEdit.AvgNumPoints_2 = 5;
pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
pGeoDefEdit.GridCount_2 = 1;
pGeoDefEdit.HasM_2 = false;
pGeoDefEdit.HasZ_2 = false;
pGeoDefEdit.SpatialReference_2 = axMapControl1.SpatialReference;
oFieldEdit.Name_2 = "SHAPE";
oFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
oFieldEdit.GeometryDef_2 = pGeoDef;
oFieldEdit.IsNullable_2 = true;
oFieldEdit.Required_2 = true;
oFieldsEdit.AddField(oField);
oField = new FieldClass();
oFieldEdit = oField as IFieldEdit;
oFieldEdit.Name_2 = "Code";
oFieldEdit.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
//oFieldEdit.Length = 10;
oFieldEdit.IsNullable_2 = true;
oFieldsEdit.AddField(oField);
//创建要素类
oFeatureClass = (pMemoryWS as IFeatureWorkspace).CreateFeatureClass("Temp", oFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
oFeatureLayer = new FeatureLayerClass();
oFeatureLayer.Name = "PointLayer";
oFeatureLayer.FeatureClass = oFeatureClass;
//创建唯一值符号化对象
IUniqueValueRenderer pURender = new UniqueValueRendererClass();
pURender.FieldCount = 1;
pURender.set_Field(0, "Code");
pURender.UseDefaultSymbol = false;
//创建SimpleMarkerSymbolClass对象
ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
//创建RgbColorClass对象为pSimpleMarkerSymbol设置颜色
IRgbColor pRgbColor = new RgbColorClass();
pRgbColor.Red = 255;
pSimpleMarkerSymbol.Color = pRgbColor as IColor;
//设置pSimpleMarkerSymbol对象的符号类型,选择钻石
pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;
//设置pSimpleMarkerSymbol对象大小,设置为5
pSimpleMarkerSymbol.Size = 5;
//显示外框线
pSimpleMarkerSymbol.Outline = true;
//为外框线设置颜色
IRgbColor pLineRgbColor = new RgbColorClass();
pLineRgbColor.Green = 255;
pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor;
//设置外框线的宽度
pSimpleMarkerSymbol.OutlineSize = 1;
//半透明颜色
pURender.AddValue("1", "", pSimpleMarkerSymbol as ISymbol);
//唯一值符号化内存图层
(oFeatureLayer as IGeoFeatureLayer).Renderer = pURender as IFeatureRenderer;
ILayerEffects pLyrEffect = oFeatureLayer as ILayerEffects;
//透明度
pLyrEffect.Transparency = 0;
oFeatureLayer.Visible = true;
this.axMapControl1.AddLayer(oFeatureLayer,axMapControl1.LayerCount);
insertpoint = true;
}
示例2: CreateFeatureClass
//http://resources.esri.com/help/9.3/arcgisengine/arcobjects/esriGeoDatabase/IFeatureWorkspace.CreateFeatureClass_Example.htm
static IFeatureClass CreateFeatureClass(string name, IFeatureWorkspace ftrSpc, esriGeometryType type, int epsg, List<dynamic> extraFields)
{
IFeatureClass ftrc = null;
if(null != ftrSpc && null != name)
{
IFieldsEdit flds = new FieldsClass();
flds.FieldCount_2 = 2 + (extraFields == null ? 0 : extraFields.Count);
IFieldEdit fld = new FieldClass();
fld.Name_2 = OBJECT_ID;
fld.Type_2 = esriFieldType.esriFieldTypeOID;
flds.Field_2[0] = fld;
fld = new FieldClass();
fld.Name_2 = SHP_NAME;
fld.Type_2 = esriFieldType.esriFieldTypeGeometry;
fld.GeometryDef_2 = CreateGeometryDef(type, epsg);
flds.Field_2[1] = fld;
int eidx = 2;
foreach(var efld in extraFields)
{
fld = new FieldClass();
fld.Name_2 = efld.Name;
fld.Type_2 = efld.Type;
flds.Field_2[eidx++] = fld;
}
ftrc = ftrSpc.CreateFeatureClass(name, flds, null, null, esriFeatureType.esriFTSimple, SHP_NAME, null);
}
return ftrc;
}
示例3: addScoreToolStripMenuItem_Click
private void addScoreToolStripMenuItem_Click(object sender, EventArgs e)
{
IFeatureLayer fealyr = axMapControl1.get_Layer(0) as IFeatureLayer;
IFeatureClass feacls = fealyr.FeatureClass;
IField field = new FieldClass();
IFieldEdit2 fe = field as IFieldEdit2;
fe.Name_2 = "FinalScore";
fe.Type_2 = esriFieldType.esriFieldTypeDouble;
feacls.AddField(field);
int index = feacls.FindField("FinalScore");
object obj = null;
Random rand = new Random();
using (ComReleaser com = new ComReleaser())
{
IFeatureCursor cursor = feacls.Search(null, true);
com.ManageLifetime(cursor);
IFeature fea = cursor.NextFeature();
while (fea != null)
{
obj = rand.NextDouble() * 100;
fea.set_Value(index, obj);
fea.Store();
fea = cursor.NextFeature();
}
}
}
示例4: CreateFClassInPDB
public static IFeatureClass CreateFClassInPDB(IWorkspace accessworkspace, string feaDSname, string FCname, esriGeometryType esriGeometryType,ISpatialReference sprf)
{
try
{
IFeatureDataset featureDataset = ((IFeatureWorkspace)accessworkspace).OpenFeatureDataset(feaDSname);
//IGeoDataset geoDataset = featureDataset as IGeoDataset;
IFields pFields = new FieldsClass();
IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
IField pField = new FieldClass();
IFieldEdit pFieldEdit = pField as IFieldEdit;
pFieldEdit.Name_2 = "SHAPE";
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
IGeometryDef pGeometryDef = new GeometryDefClass();
IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
pFieldEdit.GeometryDef_2 = pGeometryDef;
pFieldsEdit.AddField(pField);
IFeatureClass fc = featureDataset.CreateFeatureClass(FCname, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
return fc;
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString());
return null;
}
}
示例5: CreateFeatureClass
static IFeatureClass CreateFeatureClass(IFeatureWorkspace workspace, string name, ISpatialReference outSR)
{
IFieldsEdit fields = new FieldsClass();
IFieldEdit field = new FieldClass();
field.Type_2 = esriFieldType.esriFieldTypeOID;
field.Name_2 = "OBJECTID";
field.AliasName_2 = "OBJECTID";
fields.AddField(field);
IGeometryDefEdit geom = new GeometryDefClass();
geom.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
geom.SpatialReference_2 = outSR;
geom.HasM_2 = true;
geom.HasZ_2 = false;
field = new FieldClass();
field.Name_2 = "SHAPE";
field.AliasName_2 = "SHAPE";
field.Type_2 = esriFieldType.esriFieldTypeGeometry;
field.GeometryDef_2 = geom;
fields.AddField(field);
return workspace.CreateFeatureClass(name, fields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
}
示例6: AddField
public static void AddField(this IFields fields, string name, esriFieldType type)
{
IFieldEdit fe = new FieldClass();
fe.Name_2 = name;
fe.Type_2 = type;
((IFieldsEdit)fields).AddField((IField)fe);
}
示例7: CreatePointLayer
/// <summary>
/// �½���ͼ��
/// </summary>
public void CreatePointLayer()
{
SaveFileDialog sfdPoint = new SaveFileDialog();
sfdPoint.Title = "��ѡ���ͼ��Ĵ洢λ��";
sfdPoint.Filter = "Shapefile(*.shp)|*.shp|All files(*.*)|*.*";
sfdPoint.RestoreDirectory = true;
if (sfdPoint.ShowDialog() == DialogResult.OK)
{
LocalFilePath = sfdPoint.FileName;
FilePath = System.IO.Path.GetDirectoryName(LocalFilePath);
FileName = System.IO.Path.GetFileName(LocalFilePath);
IFields pFields = new FieldsClass();
IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
IField pField = new FieldClass();
IFieldEdit pFieldEdit = pField as IFieldEdit;
pFieldEdit.Name_2 = "SHAPE";
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
IGeometryDef pGeometryDef = new GeometryDefClass();
IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
pFieldEdit.GeometryDef_2 = pGeometryDef;
pFieldsEdit.AddField(pField);
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
IFeatureWorkspace pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(FilePath, 0) as IFeatureWorkspace;
pFeatureWorkspace.CreateFeatureClass(FileName, pFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
m_mapControl.AddShapeFile(FilePath, FileName);
m_mapControl.ActiveView.Refresh();
}
}
示例8: RunGPFieldMapping
private static void RunGPFieldMapping()
{
// Initialize the Geoprocessor
ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
GP.OverwriteOutput = true;
// Create the GPUtilites object
IGPUtilities gputilities = new GPUtilitiesClass();
// Create a DETable data element object
IDETable inputTableA = (IDETable)gputilities.MakeDataElement(@"C:\data\citiblocks.gdb\census", null, null);
// Create an array of input tables
IArray inputtables = new ArrayClass();
inputtables.Add(inputTableA);
// Initialize the GPFieldMapping
IGPFieldMapping fieldmapping = new GPFieldMappingClass();
fieldmapping.Initialize(inputtables, null);
// Create a new output field
IFieldEdit trackidfield = new FieldClass();
trackidfield.Name_2 = "TRACTID";
trackidfield.Type_2 = esriFieldType.esriFieldTypeString;
trackidfield.Length_2 = 50;
// Create a new FieldMap
IGPFieldMap trackid = new GPFieldMapClass();
trackid.OutputField = trackidfield;
// Find field map "STFID" containing the input field "STFID". Add input field to the new field map.
int fieldmap_index = fieldmapping.FindFieldMap("STFID");
IGPFieldMap stfid_fieldmap = fieldmapping.GetFieldMap(fieldmap_index);
int field_index = stfid_fieldmap.FindInputField(inputTableA, "STFID");
IField inputField = stfid_fieldmap.GetField(field_index);
trackid.AddInputField(inputTableA, inputField, 5, 10);
// Add the new field map to the field mapping
fieldmapping.AddFieldMap(trackid);
// Execute Table to Table tool using the FieldMapping
TableToTable tblTotbl = new TableToTable();
tblTotbl.in_rows = inputTableA;
tblTotbl.out_path = @"C:\data\citiblocks.gdb";
tblTotbl.out_name = "census_out";
tblTotbl.field_mapping = fieldmapping;
object sev = null;
try
{
GP.Execute(tblTotbl, null);
System.Windows.Forms.MessageBox.Show(GP.GetMessages(ref sev));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
System.Windows.Forms.MessageBox.Show(GP.GetMessages(ref sev));
}
}
示例9: OnClick
protected override void OnClick()
{
string tablePath = Path.Combine(DataPath, @"Geodatabase\ManhattanKS.gdb\ParcelIDs");
string tableName = Path.GetFileName(tablePath);
const string searchField = "PID";
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
IWorkspace workspace = workspaceFactory.OpenFromFile(Path.GetDirectoryName(tablePath), 0);
IObjectClassDescription objClassDesc = new ObjectClassDescriptionClass();
IFields fields = objClassDesc.RequiredFields;
IFieldsEdit fieldsEdit = (IFieldsEdit) fields;
IField field = new FieldClass();
IFieldEdit fieldEdit = (IFieldEdit) field;
fieldEdit.Name_2 = searchField;
fieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
fieldEdit.IsNullable_2 = true;
fieldEdit.AliasName_2 = searchField;
fieldEdit.Editable_2 = true;
fieldEdit.Length_2 = 250;
fieldsEdit.AddField(field);
fields = fieldsEdit;
ITable table = CreateTable((IWorkspace2) workspace, tableName, fields);
using (ComReleaser releaser = new ComReleaser())
{
ICursor cursor = table.Insert(true);
releaser.ManageLifetime(cursor);
string txtPath = Path.Combine(DataPath, "UniqueValues.txt");
int searchFieldIndex = table.FindField(searchField);
IRowBuffer buffer = table.CreateRowBuffer();
using (StreamReader reader = new StreamReader(txtPath))
{
string line;
while ((line = reader.ReadLine()) != null)
{
string id = line.Split(new[] {'.', ' '}, StringSplitOptions.RemoveEmptyEntries)[1];
buffer.Value[searchFieldIndex] = id;
cursor.InsertRow(buffer);
}
cursor.Flush();
}
}
((ITableCollection) ArcMap.Document.FocusMap).AddTable(table);
ArcMap.Document.UpdateContents();
Marshal.FinalReleaseComObject(table);
}
示例10: CreateIntField
public static IField CreateIntField(string pFieldName, int pFieldLen)
{
FieldClass class2 = new FieldClass();
IFieldEdit edit = class2;
edit.Name_2 = pFieldName;
edit.Precision_2 = pFieldLen;
edit.Type_2 = esriFieldType.esriFieldTypeInteger;
return class2;
}
示例11: CreateFeatureClassOutput
/// <summary>
/// create feature class of output
/// </summary>
/// <param name="workspace">object workspace</param>
/// <param name="spatialReference">spatial reference of feature class of output</param>
/// <param name="nameFeatureClass">name of feature class</param>
/// <returns>object feature class</returns>
private static IFeatureClass CreateFeatureClassOutput(IWorkspace workspace, ISpatialReference spatialReference, string nameFeatureClass)
{
IFeatureClassDescription featureClassDescription = new FeatureClassDescriptionClass();
IObjectClassDescription objectClassDescription = (IObjectClassDescription)featureClassDescription;
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
// Create the fields collection.
IFields fields = new FieldsClass();
IFieldsEdit fieldsEdit = (IFieldsEdit)fields;
IField oidField = new FieldClass();
IFieldEdit oidFieldEdit = (IFieldEdit)oidField;
oidFieldEdit.Name_2 = "OBJECTID";
oidFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
fieldsEdit.AddField(oidField);
// Create the Shape field.
IField shapeField = new Field();
IFieldEdit shapeFieldEdit = (IFieldEdit)shapeField;
// Set up the geometry definition for the Shape field.
IGeometryDef geometryDef = new GeometryDefClass();
IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
// By setting the grid size to 0, you're allowing ArcGIS to determine the appropriate grid sizes for the feature class.
// If in a personal geodatabase, the grid size will be 1000. If in a file or ArcSDE geodatabase, the grid size
// will be based on the initial loading or inserting of features.
geometryDefEdit.HasM_2 = false;
geometryDefEdit.HasZ_2 = false;
geometryDefEdit.SpatialReference_2 = spatialReference;
// Set standard field properties.
shapeFieldEdit.Name_2 = featureClassDescription.ShapeFieldName;
shapeFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
shapeFieldEdit.GeometryDef_2 = geometryDef;
shapeFieldEdit.IsNullable_2 = true;
shapeFieldEdit.Required_2 = true;
fieldsEdit.AddField(shapeField);
IField idField = new FieldClass();
IFieldEdit idIsolaFieldEdit = (IFieldEdit)idField;
idIsolaFieldEdit.Name_2 = Program.nameFieldIdOutput;
idIsolaFieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger;
fieldsEdit.AddField(idField);
// Use IFieldChecker to create a validated fields collection.
IFieldChecker fieldChecker = new FieldCheckerClass();
IEnumFieldError enumFieldError = null;
IFields validatedFields = null;
fieldChecker.ValidateWorkspace = workspace;
fieldChecker.Validate(fields, out enumFieldError, out validatedFields);
return featureWorkspace.CreateFeatureClass(nameFeatureClass, fields, objectClassDescription.InstanceCLSID, objectClassDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, featureClassDescription.ShapeFieldName, string.Empty);
}
示例12: CreateDoubleField
// Methods
public static IField CreateDoubleField(string pFieldName, int pFieldLen, int pFieldScale)
{
FieldClass class2 = new FieldClass();
IFieldEdit edit = class2;
edit.Name_2 = pFieldName;
edit.Type_2 = esriFieldType.esriFieldTypeDouble;
edit.Precision_2 = pFieldLen;
edit.Scale_2 = pFieldScale;
return class2;
}
示例13: AddField
public void AddField(IFeatureClass pFeatureClass,string fieldName,esriFieldType fieldType)
{
//如果存在不必添加字段,直接返回
if (pFeatureClass.FieldExistCheck(fieldName)) return;
var pField = new FieldClass();
var pFieldEdit = (IFieldEdit)pField;
pFieldEdit.Name_2 = fieldName;
pFieldEdit.Type_2 = fieldType;
pFeatureClass.AddField(pFieldEdit);
}
示例14: CreatePolygonFile
public IFeatureClass CreatePolygonFile(String strFolder, String filename, IEnvelope pEnvBorder, ISpatialReference pSR)
{
// Open the folder to contain the shapefile as a workspace
IWorkspaceFactory pWF = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
IFeatureWorkspace pfws = (IFeatureWorkspace)pWF.OpenFromFile(strFolder, 0);
//Set up a simple fields collection
IField pField = new FieldClass();
IFieldEdit pFieldEdit = (IFieldEdit)pField;
IFields pFields = new FieldsClass();
IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;
// Make the shape field
//it will need a geometry definition, with a spatial reference
pFieldEdit.Name_2 = "Shape";
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
IGeometryDef pGeomDef = new GeometryDef();
IGeometryDefEdit pGeomDefEdit = (IGeometryDefEdit)pGeomDef;
pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
pGeomDefEdit.SpatialReference_2 = pSR;
pFieldEdit.GeometryDef_2 = pGeomDef;
pFieldsEdit.AddField(pField);
// Add ID field
IField pFieldOID = new Field();
pFieldEdit = (IFieldEdit)pFieldOID;
pFieldEdit.Name_2 = "OBJECTID";
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
pFieldEdit.IsNullable_2 = false;
pFieldsEdit.AddField(pFieldOID);
//EulerPoleReFrmgwn eulerfrm=new EulerPoleReFrmgwn();
if (File.Exists(strFolder + filename + ".shp") == true)
{
DialogResult result = MessageBox.Show("There is a shapefile have the same name in this foler, do you want to overwrite it?", "", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK)
{
File.Delete(strFolder + filename);
}
else
{
return null;
}
}
IFeatureClass pFeatclass = pfws.CreateFeatureClass(filename, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
return pFeatclass;
}
示例15: AddField
//添加字段并赋值
private void AddField()
{
//添加温度字段
string HighTemp = "HighTemperature";
string LowTemp = "LowTemperature";
IFeatureLayer lyrProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IFeatureLayer;
IFeatureClass ProClass = lyrProVince.FeatureClass; ;
if (ProClass.Fields.FindField(HighTemp) < 0)
{
IField pField = new FieldClass();
IFieldEdit pFieldEdit = pField as IFieldEdit;
pFieldEdit.Name_2 = HighTemp;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
IClass pClass = ProClass as IClass;
pClass.AddField(pFieldEdit);
}
if (ProClass.Fields.FindField(LowTemp) < 0)
{
IField pField = new FieldClass();
IFieldEdit pFieldEdit = pField as IFieldEdit;
pFieldEdit.Name_2 = LowTemp;
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
IClass pClass = ProClass as IClass;
pClass.AddField(pFieldEdit);
}
//为字段赋值
string[] provinces = new string[] { "黑龙江省", "内蒙古自治区", "新疆维吾尔自治区", "吉林省", "甘肃省", "河北省", "北京市", "山西省", "天津市", "陕西省", "宁夏回族自治区", "青海省", "辽宁省", "山东省", "西藏自治区", "河南省", "江苏省", "安徽省", "四川省", "湖北省", "重庆市", "上海市", "浙江省", "湖南省", "江西省", "云南省", "贵州省", "广西壮族自治区", "福建省", "台湾省", "海南省", "广东省", "香港特别行政区", "澳门" };
TomorrowWeatherInfo weath;
IFeatureCursor featCursor = null;
IQueryFilter queryFilter = new QueryFilterClass();
for (int i = 0; i < provinces.Length; i++)
{
string selCity = provinces[i];
string whereClause = "[NAME] = '" + selCity + "'";
queryFilter.WhereClause = whereClause;
featCursor = ProClass.Search(queryFilter, false);
IFeature pFeature = featCursor.NextFeature();
string pcity = Utilities.getCity(selCity);
weath = new TomorrowWeatherInfo(pcity);
Random random=new Random();//测试用随机数产生器
if (pFeature != null)
{
pFeature.set_Value(pFeature.Fields.FindField("HighTemperature"), random.Next(20,40));
pFeature.set_Value(pFeature.Fields.FindField("LowTemperature"), random.Next(1,20));
pFeature.Store();
}
}
IGeoFeatureLayer geoProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IGeoFeatureLayer;
setColor(geoProVince);
}