当前位置: 首页>>代码示例>>C#>>正文


C# IFeature.Store方法代码示例

本文整理汇总了C#中IFeature.Store方法的典型用法代码示例。如果您正苦于以下问题:C# IFeature.Store方法的具体用法?C# IFeature.Store怎么用?C# IFeature.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFeature的用法示例。


在下文中一共展示了IFeature.Store方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:101,代码来源:NetEditFeaturesRESTSOE.cs

示例2: Append3DFile

        public static bool Append3DFile(string str3DFile, IFeatureClass fClassTarget , string strSpatialRef, ref IFeature feature3D)
        {
            try
            {

                string strTempPath=System.IO.Path.GetPathRoot(System.Environment.SystemDirectory);
                string strOutputTemp = System.IO.Path.Combine(strTempPath, "temp.shp");

                if (System.IO.File.Exists(strOutputTemp) && !DeleteDataset(strOutputTemp))
                {
                    ErrorMessage = "无法使用临时文件";
                    return false;
                }

                if (!Import3DFile(str3DFile, strOutputTemp, strSpatialRef))
                {
                    return false;
                }

                IWorkspace wsTemp =Hy.Esri.Utility.WorkspaceHelper.OpenWorkspace(Hy.Esri.Utility.enumWorkspaceType.File, strTempPath);
                IFeatureClass fClassTemp = (wsTemp as IFeatureWorkspace).OpenFeatureClass("temp");
                IFeatureCursor fCursorTemp = fClassTemp.Search(null, false);
                IFeature fTemp = fCursorTemp.NextFeature();
                if (fTemp == null)
                {
                    ErrorMessage = "追加的中转过程出错!";
                    return false;
                }
                IGeometry geo3D = (fTemp.Shape as IClone).Clone() as IGeometry;

                //IFeatureClass fClass = (wsTarget as IFeatureWorkspace).OpenFeatureClass(featureClassName);
                //feature3D = fClass.CreateFeature();
                feature3D = fClassTarget.CreateFeature();
                feature3D.Shape = geo3D;
                feature3D.Store();

                System.Runtime.InteropServices.Marshal.ReleaseComObject(fTemp);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(fCursorTemp);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(fClassTemp);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(wsTemp);

                return true;

                //string outPut = WorkspaceHelper.GetGpString(wsTarget, featrueDatasetName, featureClassName);
                //IFeature newFeature = null;
                //Append gpAppend = new Append();
                //gpAppend.inputs = strOutputTemp;
                //gpAppend.output = newFeature;
                //gpAppend.target = outPut;

                //Geoprocessor geoProcessor = new Geoprocessor();
                //geoProcessor.OverwriteOutput = true;
                //IGeoProcessorResult gpResult = geoProcessor.Execute(gpAppend, null) as IGeoProcessorResult;

                //return gpResult.Status == esriJobStatus.esriJobSucceeded;
            }
            catch(Exception exp)
            {
                ErrorMessage = exp.Message;
                return false;
            }
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:62,代码来源:GpTool.cs

示例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("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);

            }
        }
开发者ID:jorik041,项目名称:local-government-desktop-addins,代码行数:50,代码来源:ConstructionTools.cs

示例4: 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);

            }
        }
开发者ID:tuyndv,项目名称:local-government-desktop-addins,代码行数:50,代码来源:ConstructionTools.cs

示例5: 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;
        }
开发者ID:LooWooTech,项目名称:Traffic,代码行数:50,代码来源:SDEManager.cs

示例6: 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();
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:30,代码来源:QAErrorStorage.cs

示例7: UpdateFeature

        //�޸�Ҫ�غ󣬸���Ҫ��
        private void UpdateFeature(IFeature pFeature, IGeometry pGeometry)
        {
            //����Ƿ��ڱ༭������
            IDataset pDataset = (IDataset)pFeature.Class;
            IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDataset.Workspace;

            //���浱ǰ�༭��Ҫ��
            pWorkspaceEdit.StartEditOperation();
            pFeature.Shape = pGeometry;
            pFeature.Store();
               pWorkspaceEdit.StopEditOperation();
        }
开发者ID:chinasio,项目名称:minegis,代码行数:13,代码来源:ModifyShape+.cs

示例8: UpdateFeature

        /// <summary>
        /// ��ͼ���и����µĵ�ͼ���󣬲�ʹ֮����ѡ��״̬
        /// </summary>
        /// <param name="pFeature"></param>
        /// <param name="pGeometry"></param>
        private void UpdateFeature(IFeature pFeature, IGeometry pGeometry)
        {
            try
            {
                IDataset pDataset =(IDataset) pFeature.Class;
                IWorkspaceEdit pWorkspaceEdit =(IWorkspaceEdit) pDataset.Workspace;
                if (!pWorkspaceEdit.IsBeingEdited())
                {
                    MessageBox.Show("��ǰͼ�㲻�ɱ༭");
                    return ;
                }

                pWorkspaceEdit.StartEditOperation();
                pFeature.Shape = pGeometry;
                pFeature.Store();
                pWorkspaceEdit.StopEditOperation();
            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message.ToString());
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:27,代码来源:AoEditor.cs

示例9: CreateFeature


//.........这里部分代码省略.........

            DatabaseUtil.SetDefaultValues(_newFeature); //set default values
            string guid = Utilities.GenerateGUID(true);
            DatabaseUtil.SetFieldValue(_newFeature, ExtensionInfo.netUtil.ntInfo.guidName, guid);

            if (ExtensionInfo.netUtil.ntInfo.networkClassIds.ContainsValue(_currentTargetLayer.FeatureClass.ObjectClassID))
            {
                EditObject eObj = new EditObject()
                {
                    ClassName = Associated_FeatureClassName,
                    CLSID = _currentTargetLayer.FeatureClass.ObjectClassID,
                    Connectivity = eoConn,
                    ElementType = (geometry.GeometryType == esriGeometryType.esriGeometryPoint) ? ElementType.Node : ElementType.Section,
                    OID = _newFeature.OID,
                    Partner = null, //Partner is only for split
                    Type = EditType.Add,
                    UID = guid,
                    shape = geometry
                };//TODO

                ExtensionInfo.EditQueue.Add(eObj);
                //inherit from parent
                int engPh = 128;
                string constPhase = "UnKnown";
                if (eoConn != null && eoConn.parentFeature != null)
                {
                    engPh = eoConn.phaseCode;
                    constPhase = Utilities.BitgatePhaseToStringPhase(eoConn.constructedPhaseCode);
                    IFeature parent = DatabaseUtil.GetReadOnlyFeature(ExtensionInfo.Editor.EditWorkspace, eoConn.parentFeature.classID, eoConn.parentFeature.oid);
                    if (parent != null)
                    {
                        InheritElectricAttributesFromParent(_newFeature, parent);
                        if(eObj.ElementType == ElementType.Section && eoConn.constructedPhaseCode != eoConn.parentFeature.phaseCode)
                        {
                            //TODO
                        }
                    }
                }

                //update PhaseCode, ConstPhase
                DatabaseUtil.SetFieldValue(_newFeature, ExtensionInfo.netUtil.ntInfo.phaseCodeField, engPh);

                DatabaseUtil.SetFieldValue(_newFeature, ExtensionInfo.netUtil.ntInfo.constructedPhaseField, constPhase);

                //check if it is source
                if (ExtensionInfo.netUtil.ntInfo.Source != null && ExtensionInfo.netUtil.ntInfo.Source.ClassID == _currentTargetLayer.FeatureClass.ObjectClassID)
                {
                    if (string.IsNullOrEmpty(ExtensionInfo.netUtil.ntInfo.Source.FieldName) ||
                        string.Compare(ExtensionInfo.netUtil.ntInfo.Source.FieldValue, DatabaseUtil.ToText(DatabaseUtil.GetFieldValue(_newFeature, ExtensionInfo.netUtil.ntInfo.Source.FieldName)), true) == 0)
                        eObj.IsSource = true;
                }

                //check if it is network protector
                if (ExtensionInfo.netUtil.ntInfo.NTProtector != null && ExtensionInfo.netUtil.ntInfo.NTProtector.ClassID == _currentTargetLayer.FeatureClass.ObjectClassID)
                {
                    if (string.IsNullOrEmpty(ExtensionInfo.netUtil.ntInfo.NTProtector.FieldName) ||
                        string.Compare(ExtensionInfo.netUtil.ntInfo.NTProtector.FieldValue, DatabaseUtil.ToText(DatabaseUtil.GetFieldValue(_newFeature, ExtensionInfo.netUtil.ntInfo.NTProtector.FieldName)), true) == 0)
                        eObj.IsNetworkProtector = true;
                }

                //check if it is YD transformer
                if (ExtensionInfo.netUtil.ntInfo.YDTransformer != null && ExtensionInfo.netUtil.ntInfo.YDTransformer.ClassID == _currentTargetLayer.FeatureClass.ObjectClassID)
                {
                    if (string.IsNullOrEmpty(ExtensionInfo.netUtil.ntInfo.YDTransformer.FieldName) ||
                        string.Compare(ExtensionInfo.netUtil.ntInfo.YDTransformer.FieldValue, DatabaseUtil.ToText(DatabaseUtil.GetFieldValue(_newFeature, ExtensionInfo.netUtil.ntInfo.YDTransformer.FieldName)), true) == 0)
                        eObj.IsYDTransformer = true;
                }
            }

            _newFeature.Store(); //this will fire OnCreate event

            ExtensionInfo.InternalEdit = false;

                //if (DataElement.DoesFieldExist(_newFeature, GISFieldNames.Structure_Guid_FieldName))
                //{
                //    ElectricDataElement.AssociateOrCreateStructure(_newFeature as IFeature, false);
                //    _newFeature.Store();
                //}

                GISApplication.StopEditOperation(_workspace);

                ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, _newFeature, ArcMap.Document.ActiveView.Extent);
            }
            catch(Exception ex)
            {
                if (_operationStarted)
                {
                    GISApplication.AbortEditOperation(_workspace);
                    _operationStarted = false;
                }
                DeactivateCurrentTool();
            }
            finally
            {
                _operationStarted = false;
            }

            if (alreadyInEditOperation)
                GISApplication.StartEditOperation(_workspace);
        }
开发者ID:Ramakrishnapv,项目名称:FuturaNetwork,代码行数:101,代码来源:InsertionTool.cs

示例10: deleteFeature

        //IFeatureLayer m_FeatureLayer
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="m_Feature"></param>
        public bool deleteFeature(int x, int y)
        {
            //IGeometryCollection pGeomColn ;
            //IPointCollection pPointColn;
            IObjectClass pObjectClass;
            IFeature pFeature;
            IGeometry pGeom;

            //IPath pPath ;
            IPoint pHitPoint = null;
            IPoint pPoint = null;
            Double hitDist = 0.0;
            double tol;
            int vertexIndex = 0;
            //int numVertices;
            int partIndex = 0;
            bool vertex = false;
            try
            {
                m_pMap.ClearSelection();
                // 取得鼠标击中的第一个对象
                SelectMouseDown(x, y);
                IEnumFeature pSelected = (IEnumFeature)m_pMap.FeatureSelection;
                pFeature = pSelected.Next();
                if (pFeature == null) return false;
                IActiveView pActiveView = (IActiveView)m_pMap;
                pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                // 节点空间查询容差
                tol = ConvertPixelsToMapUnits(pActiveView, 4.0);
                pGeom = pFeature.Shape;
                pObjectClass = pFeature.Class;
                m_pEditFeature = pFeature;
                object objNull = Missing.Value;
                //object objBefore, objAfter;

                IPointCollection pointCollection;
                if (m_pEditFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline & TestGeometryHit(tol, pPoint, pFeature, pHitPoint, hitDist, out partIndex, out vertexIndex, out vertex))
                {
                    pointCollection = new PolylineClass();
                    IPolyline polyline = m_pEditFeature.Shape as IPolyline;
                    pointCollection = polyline as IPointCollection;
                    //如果点个数少于两个就无法构成线
                    if (pointCollection.PointCount > 2)
                    {
                        //移除指定的节点
                        pointCollection.RemovePoints(vertexIndex, 1);
                    }
                    else
                    {
                        MessageBox.Show("此先已经少于两个点,不能在删除");
                    }
                }
                else if (m_pEditFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon & TestGeometryHit(tol, pPoint, pFeature, pHitPoint, hitDist, out partIndex, out vertexIndex, out vertex))
                {
                    pointCollection = new PolygonClass();
                    IPolygon polygon = m_pEditFeature.Shape as IPolygon;
                    pointCollection = polygon as IPointCollection;
                    //点数少于三个就不能能构成面
                    if (pointCollection.PointCount > 3)
                    {
                        //移除指点的节点
                        pointCollection.RemovePoints(vertexIndex, 1);
                    }
                    else
                    {
                        MessageBox.Show("此先已经少于三个点,不能在删除");
                    }
                }
                IWorkspaceEdit workspaceEdit;
                IWorkspace workspace;
                IFeatureLayer pFeatureLayer = (IFeatureLayer)m_pCurrentLayer;
                IDataset dataset = pFeatureLayer.FeatureClass as IDataset;
                workspace = dataset.Workspace;
                workspaceEdit = workspace as IWorkspaceEdit;
                //开始编辑
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
                //保存数据
                m_pEditFeature.Store();
                //结束编辑
                workspaceEdit.StopEditOperation();
                workspaceEdit.StopEditing(true);
                pActiveView = (IActiveView)m_pMap;
                pActiveView.Refresh();
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                return false;
            }
        }
开发者ID:609878415,项目名称:fff12138,代码行数:97,代码来源:AoEditor.cs

示例11: 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)
     {
     }
 }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:72,代码来源:FeatureHelper.cs

示例12: SetDynamicValues


//.........这里部分代码省略.........
                                                        MessageBox.Show("You are trying to add 50 places to your ID, this is not supported, please fix your dynamic value table");
                                                    }

                                                    //Check for sequence column in generate id table
                                                    sequenceColumnNum = AAState._gentab.FindField(sequenceColumnName);
                                                    if (AAState._gentab.FindField(sequenceColumnName) >= 0)
                                                    {
                                                        //get value of first row, increment it, and return incremented value
                                                        for (int j = 0; j < 51; j++)
                                                        {
                                                            row = AAState._gentab.Update(null, false).NextRow();
                                                            if (row == null)
                                                            {
                                                                break;
                                                            }
                                                            if (row.get_Value(sequenceColumnNum) == null)
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else
                                                                sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));

                                                            sequenceValue += 1;
                                                            // _editEvents.OnChangeFeature -= OnChangeFeature;
                                                            // _editEvents.OnCreateFeature -= OnCreateFeature;

                                                            row.set_Value(sequenceColumnNum, sequenceValue);
                                                            AAState.WriteLine("                  " + row.Fields.get_Field(sequenceColumnNum).AliasName + " changed to " + sequenceValue);

                                                            row.Store();
                                                            //  _editEvents.OnChangeFeature += OnChangeFeature;
                                                            //  _editEvents.OnCreateFeature += OnCreateFeature;
                                                            if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                                break;

                                                        }
                                                        if (sequenceValue == -1)
                                                        {
                                                            AAState.WriteLine("                  ERROR: GENERATE_ID: Sequence Not Found");
                                                        }

                                                        else
                                                        {
                                                            if (inObject.Fields.get_Field(fieldNum).Type == esriFieldType.esriFieldTypeString)
                                                                if (formatString == null || formatString == "" || formatString.ToLower().IndexOf("[seq]") == -1)
                                                                {
                                                                    string setVal = (sequenceValue.ToString("D" + sequencePadding) + sequencePostfix).ToString();

                                                                    if (inObject.Fields.get_Field(fieldNum).Length < setVal.Length && inObject.Fields.get_Field(fieldNum).Length != 0)
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: " + sequenceValue + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName);
                                                                    }
                                                                    else
                                                                    {
                                                                        inObject.set_Value(fieldNum, sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);
                                                                        AAState.WriteLine("                  " + inObject.Fields.get_Field(fieldNum).AliasName + " set to " + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);

                                                                    }

                                                                }
                                                                else
                                                                {
开发者ID:riordabr,项目名称:3d-cities-template,代码行数:67,代码来源:Copy+of+AttributeAssistantEditorExtension.cs

示例13: 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;
 }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:57,代码来源:CommonClass.cs

示例14: CreatePolygonFromExistingGeometries

        /// 合并列表中所有多边形
        /// </summary>
        /// <params name="orifeature">保留源对象</params>
        /// <params name="geolist">图形列表</params>
        /// <returns></returns>
        public void CreatePolygonFromExistingGeometries(IFeatureLayer lyr, IFeature orifeature, List<IGeometry> geolist)
        {
            int i = 0;
            IGeometry geometry = null;
            IFeatureClass Featureclass = lyr.FeatureClass;
            IWorkspaceEdit workspace = (IWorkspaceEdit)(Featureclass as IDataset).Workspace;
            workspace.StartEditing(false);
            workspace.StartEditOperation();
            //合并图形
            ITopologicalOperator2 topologicalOperator2 = orifeature.ShapeCopy as ITopologicalOperator2;
            for (i = 0; i < geolist.Count; i++)
            {
                IGeometry geo = geolist[i];
                if (geometry != null)
                {
                    topologicalOperator2 = geometry as ITopologicalOperator2;
                }
                ITopologicalOperator opertor = geo as ITopologicalOperator;
                opertor.Simplify();
                topologicalOperator2.IsKnownSimple_2 = false;
                topologicalOperator2.Simplify();
                geometry = topologicalOperator2.Union(geo);
            }
            //更新图形对象
            IGeometry geoCombined = (IGeometry)geometry;
            orifeature.Shape = geoCombined as IGeometry;
            orifeature.Store();

            workspace.StopEditOperation();
            workspace.StopEditing(true);
        }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:36,代码来源:CommonClass.cs

示例15: ExtendLine

        /// <summary>
        /// ���ݲο���Ҫ�أ���ѡ�����Ҫ�ؽ�������
        /// </summary>
        /// <params name="featExtend">���������Ҫ��</params>
        /// <params name="featRef">�ο���Ҫ��</params>
        /// <returns>�ɹ�����True</returns>
        public bool ExtendLine(IFeature featExtend, IFeature featRef)
        {
            try
            {
                ISegmentCollection extendSegCol = featExtend.ShapeCopy as ISegmentCollection;
                ISegmentCollection refSegCol = featRef.Shape as ISegmentCollection;

                ICurve extendCurve = extendSegCol as ICurve;
                ICurve refCurve = refSegCol as ICurve;

                bool bExtensionPerformed = false;
                IConstructCurve constructCurve = new PolylineClass();
                constructCurve.ConstructExtended(extendCurve, refCurve, 0, ref bExtensionPerformed);

                if (bExtensionPerformed)   //����ɹ�
                {
                    IPolyline resultPolyline = constructCurve as IPolyline;
                    if (resultPolyline != null)
                    {
                        m_engineEditor.StartOperation();

                        featExtend.Shape = resultPolyline as IGeometry;
                        featExtend.Store();

                        m_engineEditor.StopOperation("Extend Features");
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, resultPolyline.Envelope);

                        return bExtensionPerformed;
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Extend Line");
                return false;
            }
        }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:45,代码来源:ExtendTool.cs


注:本文中的IFeature.Store方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。