本文整理汇总了C#中IFeature.set_Value方法的典型用法代码示例。如果您正苦于以下问题:C# IFeature.set_Value方法的具体用法?C# IFeature.set_Value怎么用?C# IFeature.set_Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFeature
的用法示例。
在下文中一共展示了IFeature.set_Value方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addFeature
/**
* Performs edits to the geodatabase powering the map service that this SOE
* extends
*
* @param feature
* @param featureJSON
* @throws Exception
*/
private byte[] addFeature(JsonObject featureJSON, out IFeature feature)
{
feature = null;
IDataset fsDataset = (IDataset)this.fc;
IWorkspace ws = fsDataset.Workspace;
IWorkspaceEdit wsEdit = (IWorkspaceEdit)ws;
try
{
// start an edit transaction to add a new feature to feature class
wsEdit.StartEditing(false);
wsEdit.StartEditOperation();
feature = fc.CreateFeature();
// set attributes
if (this.editLayerInfo == null)
{
this.editLayerInfo = this.layerInfos.get_Element(this.layerId);
if (!this.editLayerInfo.IsFeatureLayer)
{
return createErrorObject(
403,
"The layerId property of this SOE currently points to a layer (id: "
+ this.layerId
+ ") that is not a feature layer.",
new String[] {
"Only feature layers can be edited by this SOE.",
"Modify SOE's layerId property using ArcGIS Manager or ArcGIS Desktop's Service Editor." });
}
}
IFields fields = this.editLayerInfo.Fields;
JsonObject attributesJSON = null;
featureJSON.TryGetJsonObject("attributes", out attributesJSON);
System.Collections.IEnumerator itKeys = attributesJSON.GetEnumerator();
while (itKeys.MoveNext())
{
KeyValuePair<string, object> kv = (KeyValuePair<string, object>)itKeys.Current;
String key = kv.Key;
int fieldId = fields.FindField(key);
IField field = fields.get_Field(fieldId);
object fieldValue = null;
if (field.Editable)
{
//not using specific types based on field type, since can't assign value of any type to C# object
attributesJSON.TryGetObject(key, out fieldValue);
// set attribute field value
feature.set_Value(fieldId, fieldValue);
}
}
// retrieve geometry as json and convert it to ArcObject geometry
JsonObject geometryJSON = null;
featureJSON.TryGetJsonObject("geometry", out geometryJSON);
IJSONConverterGeometry iConverter = new JSONConverterGeometryClass();
IJSONObject obj = new JSONObjectClass();
obj.ParseString(geometryJSON.ToJson());
IGeometry geometry = null;
switch (this.fc.ShapeType)
{
case esriGeometryType.esriGeometryPoint:
geometry = iConverter.ToPoint(obj);
break;
case esriGeometryType.esriGeometryMultipoint:
geometry = iConverter.ToMultipoint(obj, false, false);
break;
case esriGeometryType.esriGeometryPolyline:
geometry = iConverter.ToPolyline(obj, false, false);
break;
case esriGeometryType.esriGeometryPolygon:
geometry = iConverter.ToPolygon(obj, false, false);
break;
}
// set geometry
feature.Shape = geometry;
// store feature in feature class
feature.Store();
// end edit transaction
wsEdit.StopEditOperation();
wsEdit.StopEditing(true);
//.........这里部分代码省略.........
示例2: StorePipeInfoPointFeature
private static void StorePipeInfoPointFeature(IFeature lineFeature, IFeature pointFeature, FromToField[] fromToPairs, bool store)
{
try
{
if (fromToPairs == null)
{
return;
}
if (fromToPairs.Length == 0)
{
return;
}
if (pointFeature == null)
{
MessageBox.Show("The Point Along feature class was not found");
return;
}
foreach (FromToField frmTo in fromToPairs)
{
int pointFieldToCalc = pointFeature.Fields.FindField(frmTo.TargetField);
int matchFieldForCalc = lineFeature.Fields.FindField(frmTo.SourceField);
if (pointFieldToCalc > -1 && matchFieldForCalc > -1)
{
if (pointFeature.Fields.get_Field(pointFieldToCalc).Type == esriFieldType.esriFieldTypeString)
pointFeature.set_Value(pointFieldToCalc, frmTo.Prefix + lineFeature.get_Value(matchFieldForCalc).ToString());
else
pointFeature.set_Value(pointFieldToCalc, lineFeature.get_Value(matchFieldForCalc));
}
}
if (store)
{
pointFeature.Store();
}
}
catch (Exception ex)
{
MessageBox.Show("Error trying to store the ID of the pipe on the feature\r\n" + ex.Message);
}
}
示例3: StorePipeInfoPointFeature
private static void StorePipeInfoPointFeature(IFeature lineFeature, IFeature pointFeature, FromToField[] fromToPairs, bool store)
{
try
{
if (fromToPairs == null)
{
return;
}
if (fromToPairs.Length == 0)
{
return;
}
if (pointFeature == null)
{
MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_8"));
return;
}
foreach (FromToField frmTo in fromToPairs)
{
int pointFieldToCalc = pointFeature.Fields.FindField(frmTo.TargetField);
int matchFieldForCalc = lineFeature.Fields.FindField(frmTo.SourceField);
if (pointFieldToCalc > -1 && matchFieldForCalc > -1)
{
if (pointFeature.Fields.get_Field(pointFieldToCalc).Type == esriFieldType.esriFieldTypeString)
pointFeature.set_Value(pointFieldToCalc, frmTo.Prefix + lineFeature.get_Value(matchFieldForCalc).ToString());
else
pointFeature.set_Value(pointFieldToCalc, lineFeature.get_Value(matchFieldForCalc));
}
}
if (store)
{
pointFeature.Store();
}
}
catch (Exception ex)
{
MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ConstructionToolsError_9") + ex.Message);
}
}
示例4: EditFeature
public static bool EditFeature(Dictionary<string, string> FieldValDict, Dictionary<string, int> FieldIndexDict, IFeature Feature)
{
IField tempField = null;
int Index = 0;
int val1 = 0;
double val2 = 0.0;
string temp = string.Empty;
foreach (var field in FieldValDict.Keys)
{
if (FieldIndexDict.ContainsKey(field))
{
Index = FieldIndexDict[field];
tempField = Feature.Fields.get_Field(Index);
temp = FieldValDict[field];
switch (tempField.Type)
{
case esriFieldType.esriFieldTypeString:
Feature.set_Value(Index, temp);
break;
case esriFieldType.esriFieldTypeDouble:
if (double.TryParse(temp, out val2))
{
Feature.set_Value(Index, val2);
}
break;
case esriFieldType.esriFieldTypeInteger:
if (int.TryParse(temp, out val1))
{
Feature.set_Value(Index, val1);
}
break;
default:
try
{
Feature.set_Value(Index, temp);
}
catch
{
}
break;
}
}
}
Feature.Store();
return false;
}
示例5: WriteToFeature
private void WriteToFeature(DataQualityError error, IFeature feature, string operationalDSName)
{
// Shape
feature.Shape = error.Location;
// Attributes
int idx;
idx = feature.Fields.FindField("ATTACHMENT");
feature.set_Value(idx, error.ExtendedData);
idx = feature.Fields.FindField("DESCRIPTION");
feature.set_Value(idx, error.Description);
idx = feature.Fields.FindField("DATA_EXCEPTION_STATUS");
feature.set_Value(idx, error.Status);
idx = feature.Fields.FindField("LATITUDE");
feature.set_Value(idx, error.Location.Y);
idx = feature.Fields.FindField("LONGITUDE");
feature.set_Value(idx, error.Location.X);
idx = feature.Fields.FindField("OPERATIONAL_DATASET_NAME");
feature.set_Value(idx, operationalDSName);
idx = feature.Fields.FindField("QA_TEST_NAME");
feature.set_Value(idx, error.ErrorType);
idx = feature.Fields.FindField("SEVERITY");
feature.set_Value(idx, error.Severity);
idx = feature.Fields.FindField("CAN_DEFER");
feature.set_Value(idx, error.CanDefer ? "YES" : "NO");
idx = feature.Fields.FindField("CAN_EXCEPT");
feature.set_Value(idx, error.CanExcept ? "YES" : "NO");
feature.Store();
}
示例6: populate
private void populate(IFeature src, IFeature dest, IRelationshipClass rc, string[] fnames)
{
// the rc is 1-1
ISet st = rc.GetObjectsRelatedToObject(src);
if(st.Count!=1)
{
Logger.Write("Join not found for "+((IDataset)rc).Name);
return;
}
IRow row = (IRow)st.Next();
// extract the fields
for(int i=0;i<fnames.Length;i++)
{
int index = dest.Fields.FindField(fnames[i]);
int index2 = row.Fields.FindField(fnames[i]);
if(index > -1 && index2 > -1)
{
dest.set_Value(index,row.get_Value(index2));
}
}
}
示例7: clone
internal static void clone(IFeature src, IFeature dest, ISpatialReference destSR)
{
for(int i=0;i<dest.Fields.FieldCount;i++)
{
IField fld = dest.Fields.get_Field(i);
if(fld != null){
switch(fld.Type)
{
case esriFieldType.esriFieldTypeOID:
// do nothing
break;
case esriFieldType.esriFieldTypeGeometry:
IGeometry geom = src.ShapeCopy;
//// likely different srid
if (geom != null)
{
if (geom.SpatialReference.FactoryCode != destSR.FactoryCode)
{
if (geom is ITopologicalOperator2)
{
ITopologicalOperator2 geomtopo = (ITopologicalOperator2)geom;
geomtopo.IsKnownSimple_2 = false;
try
{
geomtopo.Simplify();
}
catch (Exception e)
{
Logger.Warn(e);
}
}
// need to reproject here!
geom.Project(destSR);
geom.SnapToSpatialReference();
}
dest.Shape = geom;
}
break;
default:
string fname =fld.Name;
// 2/15/08 - Check for editability of destination field.
if (fld.Editable)
{
int index = src.Fields.FindField(fname);
if (index > -1)
{
object o = src.get_Value(index);
if (o != null)
{
try
{
dest.set_Value(i, o);
}
catch (Exception e)
{
Logger.Write(e);
}
}
}
else
{
Logger.Write(fname + " not found in src");
}
}
break;
}
}
}
}
示例8: SetDynamicValues
//.........这里部分代码省略.........
fCursor = sourceLayer.FeatureClass.Search(sFilter, false);
sourceFeature = fCursor.NextFeature();
nearestFeature = null;
proxOp = (IProximityOperator)inFeature.Shape;
lastDistance = searchDistance;
if (sourceFeature != null)
{
AAState.WriteLine(" Features Found, looping for closest");
while (sourceFeature != null)
{
distance = proxOp.ReturnDistance(sourceFeature.Shape);
if (distance <= lastDistance)
{
nearestFeature = sourceFeature;
lastDistance = distance;
}
sourceFeature = fCursor.NextFeature();
}
}
if (nearestFeature != null)
{
AAState.WriteLine(" Closest Feature is " + lastDistance + " Away with OID of " + nearestFeature.OID);
for (int i = 0; i < sourceFieldNums.Length; i++)
{
try
{
AAState.WriteLine(" Trying to copy " + sourceFieldNums[i] + " to " + destFieldNums[i]);
inObject.set_Value(destFieldNums[i], nearestFeature.get_Value(sourceFieldNums[i]));
}
catch
{
AAState.WriteLine(" ERROR: copying " + sourceFieldNums[i] + " to " + destFieldNums[i]);
}
}
}
else
{
AAState.WriteLine(" No Feature was found, default fields");
for (int i = 0; i < destFieldNums.Length; i++)
{
IField field = inObject.Fields.get_Field(destFieldNums[i]);
object newval = field.DefaultValue;
if (newval == null)
{
if (field.IsNullable)
{
inObject.set_Value(destFieldNums[i], null);
}
}
else
{
inObject.set_Value(destFieldNums[i], newval);
}
}
}
}
else
{
示例9: CopyFeature
public static void CopyFeature(IFeature pSrcFea, IFeature pDestFea, bool pOverwrite)
{
try
{
IFeatureClass class2 = pSrcFea.Table as IFeatureClass;
IFeatureClass class3 = pDestFea.Table as IFeatureClass;
int num = pSrcFea.Fields.FieldCount;
for (int i = 0; i < num; i++)
{
IField field = class2.Fields.get_Field(i);
if ((((field.Type != esriFieldType.esriFieldTypeOID) &&
(field.Type != esriFieldType.esriFieldTypeGeometry))
&& (field != class2.LengthField)) && (field != class2.AreaField))
{
string str = field.Name.ToUpper();
int num3 = class3.Fields.FindField(str);
if (num3 >= 0)
{
IField field2 = class3.Fields.get_Field(num3);
if ((((field2.Type != esriFieldType.esriFieldTypeOID) &&
(field2.Type != esriFieldType.esriFieldTypeGeometry))
&& (field2 != class3.LengthField)) && (field2 != class3.AreaField))
{
object obj2 = pSrcFea.get_Value(i);
if (pOverwrite)
{
if ((obj2 == null) || (obj2 is DBNull))
{
obj2 = null;
}
if (field2.CheckValue(obj2))
{
try
{
pDestFea.set_Value(num3, obj2);
}
catch
{
}
}
}
else
{
object obj3 = pDestFea.get_Value(num3);
if ((obj3 == null) || (obj3 is DBNull))
{
if ((obj2 == null) || (obj2 is DBNull))
{
obj2 = null;
}
if (field2.CheckValue(obj2))
{
try
{
pDestFea.set_Value(num3, obj2);
}
catch
{
}
}
}
}
}
}
}
}
pDestFea.Store();
}
catch (Exception)
{
}
}
示例10: CopyAttributes
private void CopyAttributes(IFeature pSourceFeature, IFeature pDestinationFeature)
{
IField pField;
IFields pFields;
//IRow pRow;
int pCount=0;
int i;
int pindex;
bool bGet;
try
{
pFields = pDestinationFeature.Fields;
if (pSourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
pCount = 1;
else if (pSourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
pCount = 2;
else if (pSourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
pCount = 3;
for (i = 0; i < pDestinationFeature.Fields.FieldCount; i++)
{
pField = pFields.get_Field(i);
if (pField.Name.ToUpper ()!= "OBJECTID" && pField.Name.ToUpper () != "FID" && pField.Name.ToUpper () != "SHAPE")
{
bGet = false;
for (int j = 0; j < pSourceFeature.Fields.FieldCount - pCount; j++)
{
if (pSourceFeature.Fields.get_Field(j).AliasName == pField.Name)
{
if (pSourceFeature.get_Value(j) != null)
{
pDestinationFeature.set_Value (i, pSourceFeature.get_Value(j));
}
bGet = true;
}
}
if (!bGet)
{
if (pField.Name == "SHAPE_Length")
{
pindex = pSourceFeature.Fields.FindField("SHAPE_Length");
pDestinationFeature.set_Value(i, pSourceFeature.get_Value(pindex));
}
else if (pField.Name == "SHAPE_Area")
{
pindex = pSourceFeature.Fields.FindField("SHAPE_Area");
pDestinationFeature.set_Value(i, pSourceFeature.get_Value(pindex));
}
}
}
}
}
catch
{
}
pField = null;
pFields = null;
// pRow = null;
}
示例11: FillNewRecord
private void FillNewRecord(IRow pRow, IFeature pFeatureTarg)
{
try
{
if (pRow != null)
{
IFields pFields = pRow.Fields;
for (int i = 0; i < pFields.FieldCount; i++)
{
if (pFields.get_Field(i).Type != esriFieldType.esriFieldTypeOID &&
pFields.get_Field(i).Type != esriFieldType.esriFieldTypeGeometry &&
pFields.get_Field(i).Type != esriFieldType.esriFieldTypeRaster &&
pFields.get_Field(i).Type != esriFieldType.esriFieldTypeBlob &&
pFields.get_Field(i).Type != esriFieldType.esriFieldTypeGUID)
{
pFeatureTarg.set_Value(pFeatureTarg.Fields.FindFieldByAliasName(pFields.get_Field(i).AliasName), pRow.get_Value(i));
}
}
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
util.Logger.Write(" Descrip : Fills the SID list view with results from a successful SID validation query." +
"\n Message : " + ex.Message +
"\n StackTrc : " + ex.StackTrace, util.Logger.LogLevel.Debug);
}
}
示例12: UpdateFeature
/// <summary>
/// 更新数据
/// </summary>
/// <params name="lyr">图层</params>
/// <params name="fea">要素对象</params>
/// <params name="attributes">属性集合</params>
/// <params name="pGeo">空间对象</params>
/// <returns>成功失败标志</returns>
public bool UpdateFeature(IFeatureLayer lyr, IFeature fea, Dictionary<string, string> attributes, IGeometry pGeo)
{
bool bres = false;
try
{
IFeatureClass Featureclass = lyr.FeatureClass;
IWorkspaceEdit workspace = (IWorkspaceEdit)(Featureclass as IDataset).Workspace;
workspace.StartEditing(false);
workspace.StartEditOperation();
int index = Featureclass.Fields.FindField(GIS_Const.FIELD_SHAPE);
IGeometryDef geometryDef = fea.Fields.get_Field(index).GeometryDef as IGeometryDef;
if (geometryDef.HasZ)
{
IZAware pZAware = (IZAware)pGeo;
pZAware.ZAware = true;
fea.Shape = pGeo;
foreach (string key in attributes.Keys)
{
int findex = fea.Fields.FindField(key);
if (findex != -1)
{
fea.set_Value(findex, attributes[key]);
}
}
fea.Store();
}
else
{
fea.Shape = pGeo;
foreach (string key in attributes.Keys)
{
int findex = fea.Fields.FindField(key);
if (findex != -1)
{
fea.set_Value(findex, attributes[key]);
}
}
fea.Store();
}
workspace.StopEditOperation();
workspace.StopEditing(true);
bres = true;
}
catch (Exception ei)
{
Log.Debug("[GIS] Update Feature: " + ei.ToString());
}
return bres;
}
示例13: SetFields
private void SetFields(IFeature pFeat, string[,] sVar)
{
IField pField;
int iValue;
double dValue;
string sFieldName;
for (int i = 0; i <= sVar.GetUpperBound(0); i++)
{
Logger.WriteLine("Field:" + sVar[i, 0]);
sFieldName = sVar[i, 0].ToUpper();
sFieldName = sFieldName.Trim();
int iFld = pFeat.Fields.FindField(sFieldName);
if (iFld > -1)
{
pField = pFeat.Fields.Field[iFld];
switch (pField.Type)
{
case esriFieldType.esriFieldTypeInteger:
iValue = Convert.ToInt32(sVar[i, 1]);
pFeat.set_Value(iFld, iValue);
break;
case esriFieldType.esriFieldTypeDouble:
dValue = Convert.ToDouble(sVar[i, 1]);
pFeat.set_Value(iFld, dValue);
break;
case esriFieldType.esriFieldTypeString:
pFeat.set_Value(iFld, sVar[i, 1]);
break;
}
}
else
{
Logger.WriteLine("Field not found:" + sVar[i, 0]);
}
}
}