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


C# IFeatureClass.CreateFeatureBuffer方法代码示例

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


在下文中一共展示了IFeatureClass.CreateFeatureBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RasDSToCatalogWithTime

        public void RasDSToCatalogWithTime(IRasterDataset pRasterDs, IFeatureClass pCatalog, string DataField, string strData, IRasterStorageDef pRasStoreDef)
        {
            //IRasterCatalogItem pCatalogFeature;

            IFeatureCursor pCursor;
            IFeatureBuffer pRow;

            pCursor = pCatalog.Insert(false);
            IRasterCatalog pCat = pCatalog as IRasterCatalog;

            IDataset pDs;

            // loop through all the datasets and load
            if (pRasterDs != null)
            {
                pDs = pRasterDs as IDataset;
                pRow = pCatalog.CreateFeatureBuffer();
                pRow.set_Value(pCat.RasterFieldIndex, createRasterValue(pRasterDs, pRasStoreDef));
                pRow.set_Value(pCatalog.FindField(DataField), Convert.ToDateTime(strData));
                pCursor.InsertFeature(pRow);
            }

            pRasterDs = null;
        }
开发者ID:chinasio,项目名称:minegis,代码行数:24,代码来源:LoadRasterToSDE.cs

示例2: UpdateCircularArcValues

        private bool UpdateCircularArcValues(IFeatureClass LineTable, IQueryFilter QueryFilter, bool Unversioned, IDictionary<int, InferredCurve> CurveLookup, myProgessor progressor, Dictionary<int, int> MaxSequenceCache)
        {
            IFeature pLineFeat = null;
            IFeatureBuffer buffer = null;
            IFeatureCursor pLineCurs = null;
            IFeatureCursor pRadialCur = null;
            IFeatureCursor maxCursor = null;
            IDataStatistics dataStatistics = null;

            IGeometryFactory3 geometryFactory = new GeometryEnvironmentClass();
            IGeometry geometry = new PolylineClass();
            geometryFactory.CreateEmptyGeometryByType(LineTable.ShapeType, out geometry);

            IGeometryDef geometryDef = LineTable.Fields.get_Field(LineTable.FindField(LineTable.ShapeFieldName)).GeometryDef;

            if (geometryDef.HasZ)
            {
                IZAware zAware = (IZAware)(geometry);
                zAware.ZAware = true;
            }
            if (geometryDef.HasM)
            {
                IMAware mAware = (IMAware)(geometry);
                mAware.MAware = true;
            }


            try
            {
                CurveByInferenceSettings.FieldPositions positions = new CurveByInferenceSettings.FieldPositions((ITable)LineTable);

                buffer = LineTable.CreateFeatureBuffer();
                pLineCurs = LineTable.Update(QueryFilter, false);
                pRadialCur = LineTable.Insert(false);

                while ((pLineFeat = pLineCurs.NextFeature()) != null)
                {
                    //loop through all of the given lines, and update centerpoint ids, radius, and arc length values
                    if (!progressor.Continue())
                        return false;
                    progressor.Step();

                    InferredCurve curveInfo = CurveLookup[pLineFeat.OID];

                    pLineFeat.set_Value(positions.RadiusFieldIdx, curveInfo.InferredRadius);
                    pLineFeat.set_Value(positions.CenterpointIDFieldIdx, curveInfo.InferredCenterpointID);
                    IFeature feature = pLineFeat as IFeature;
                    double length = 0;
                    if (feature != null)
                    {
                        IPolyline polyline = feature.ShapeCopy as IPolyline;
                        if (polyline != null)
                        {
                            length = ((IProximityOperator)polyline.FromPoint).ReturnDistance(polyline.ToPoint);
                            pLineFeat.set_Value(positions.ArcLengthFieldIdx, length);
                            Marshal.ReleaseComObject(polyline);
                        }
                    }

                    if (Unversioned)
                        pLineCurs.UpdateFeature(pLineFeat);
                    else
                        pLineFeat.Store();

                    //fine the max sequence value 
                    int maxSequence = -1;
                    if (MaxSequenceCache.ContainsKey(curveInfo.Parcel))
                    {
                        maxSequence = MaxSequenceCache[curveInfo.Parcel];
                    }
                    else
                    {
                        maxCursor = LineTable.Search(new QueryFilter() {
                            SubFields = String.Format("{0}, {1}, {2}", LineTable.OIDFieldName, CurveByInferenceSettings.Instance.SequenceFieldName, CurveByInferenceSettings.Instance.ParcelIDFieldName),
                            WhereClause = String.Format("{0} = {1}", CurveByInferenceSettings.Instance.ParcelIDFieldName, curveInfo.Parcel) }, true);

                        int seqenceIdx = maxCursor.Fields.FindField(CurveByInferenceSettings.Instance.SequenceFieldName);

                        IRow maxFeat = null;
                        while ((maxFeat = maxCursor.NextFeature()) != null)
                        {
                            maxSequence = Math.Max((int)maxFeat.get_Value(seqenceIdx), maxSequence);
                            Marshal.ReleaseComObject(maxFeat);
                        }
                        Marshal.ReleaseComObject(maxCursor);

                        MaxSequenceCache.Add(curveInfo.Parcel, maxSequence);
                        dataStatistics = null;
                        maxCursor = null;                        
                    }
                    if (maxSequence <= 0)
                        throw new Exception("Failed to find max sequence value");

                    //the chord bearing
                    double featureBearing = (double)pLineFeat.get_Value(positions.BearingFieldIdx);

                    //half the delta of the proposed curve would be:
                    double halfdelta = toDegrees(Math.Asin(length / 2 / curveInfo.InferredRadius.Value));

                    //perpendicular to the chord
//.........这里部分代码省略.........
开发者ID:travisval,项目名称:ParcelFabricCurveByInference,代码行数:101,代码来源:CurveByInference.cs

示例3: processFeatureClass

        private bool processFeatureClass(string rule, string geometry, IFeatureClass inputFeatureClass, IFeatureClass outputFeatureClass, string sidcFieldName)
        {
            repRulesWereAdded = false;

            // allows testing without writing the output to the feature
            const bool DEBUG_DONT_WRITE_OUTPUT = false; //  true;

            if ((mapper == null) || (inputFeatureClass == null) || (outputFeatureClass == null)
                || (militaryFeatures == null) || (symbolCreator == null)
                || (!mapper.Initialized) || (!militaryFeatures.Initialized))
                return false;

            bool success = false;

            int sicFieldIndex = inputFeatureClass.Fields.FindField(sidcFieldName);

            if (sicFieldIndex < 0)
            {
                Console.WriteLine("SIDC field not found: {0} - ABORTING", sidcFieldName);
                return false;
            }

            doFieldMapping(inputFeatureClass, outputFeatureClass, sidcFieldName);

            // Start Editing
            IWorkspaceEdit workspaceEdit = militaryFeatures.Workspace as IWorkspaceEdit;
            if (workspaceEdit == null) return false;
            workspaceEdit.StartEditing(false);
            workspaceEdit.StartEditOperation();

            IRepresentationClass repClass = militaryFeatures.GetRepresentationClassForFeatureClass(outputFeatureClass);
            if (repClass == null)
            {
                Console.WriteLine("RepresentationClass not found in output - ABORTING");
                return false;
            }

            // setup insert cursor
            IFeatureBuffer targetFeatureBuffer = outputFeatureClass.CreateFeatureBuffer();
            IFeatureCursor targetFeatureCursor = outputFeatureClass.Insert(true);

            IFeatureCursor featureCursor = inputFeatureClass.Search(null, true);
            IFeature currentFeature = featureCursor.NextFeature();

            int matchingFeatureCount = 0;

            while (currentFeature != null)
            {
                string sidc = currentFeature.get_Value(sicFieldIndex) as string;

                string matchingRule = mapper.RuleNameFromSymbolIdAndGeometry(sidc, geometry);

                if (matchingRule != rule)
                {
                    currentFeature = featureCursor.NextFeature();
                    continue;
                }

                matchingFeatureCount++;

                Console.WriteLine("Processing Matching Feature: #:{0}, SIDC:{1}, Rule:{2}", matchingFeatureCount, sidc, rule);

                try
                {
                    targetFeatureBuffer.Shape = currentFeature.Shape;
                }
                catch (System.Runtime.InteropServices.COMException ce)
                {
                    Console.WriteLine("-->Could not copy geometry - you may need to add Z-values or run Fix Geometry Tool, error code=" + ce.ErrorCode);
                }

                processFieldMapping(currentFeature, targetFeatureBuffer);

                processSidc(repClass, targetFeatureBuffer, sidc);

                processMiscellaneousFields(targetFeatureBuffer, sidc);

                if (!DEBUG_DONT_WRITE_OUTPUT)
                {
                    // insert new feature
                    targetFeatureCursor.InsertFeature(targetFeatureBuffer);
                }

                currentFeature = featureCursor.NextFeature();
            }

            if (!DEBUG_DONT_WRITE_OUTPUT)
            {
                targetFeatureCursor.Flush();
            }

            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            // Release the cursors to remove the lock on the data.
            System.Runtime.InteropServices.Marshal.ReleaseComObject(targetFeatureCursor);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
            targetFeatureCursor = null;
            featureCursor = null;

//.........这里部分代码省略.........
开发者ID:rkBiswal,项目名称:military-feature-toolbox,代码行数:101,代码来源:MilitaryFeatureAppender.cs

示例4: ExportInsertFeatures

        private void ExportInsertFeatures(IDisplayTable hluDisplayTable, IQueryFilter exportQueryFilter, 
            int exportRowCount, int[] exportFieldMap, bool isShp, object outWS, IFeatureClass outFeatureClass)
        {
            // Create a Cancel Tracker.
            ITrackCancel trackCancel = new CancelTrackerClass();

            // Create the Progress Dialog. This automatically displays the dialog.
            IProgressDialogFactory progressDlgFactory = new ProgressDialogFactoryClass();
            IProgressDialog2 progressDlg = progressDlgFactory.Create(trackCancel, _application.hWnd) as IProgressDialog2;

            // Set the properties of the Progress Dialog.
            progressDlg.CancelEnabled = true;
            progressDlg.Title = "Export Progress";
            progressDlg.Description = string.Format("Exporting HLU Features and Attributes\n({0} features)", exportRowCount.ToString());
            progressDlg.Animation = esriProgressAnimationTypes.esriNoAnimation;

            // Set the properties of the Step Progressor.
            IStepProgressor stepProgressor = progressDlg as IStepProgressor;
            stepProgressor.MinRange = 0;
            stepProgressor.MaxRange = exportRowCount;
            stepProgressor.StepValue = 1;
            stepProgressor.Message = "";

            // Set the continue progress to true.
            bool contProgress = true;

            IWorkspaceEdit workspaceEdit = null;
            IWorkspace wsOut = outWS as IWorkspace;
            bool restoreEditSession = InEditingSession;
            if (restoreEditSession) CloseEditSession(true);

            // If the workspace is remote then the data is being accessed
            // via ArcSDE.
            if (wsOut.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                Editor.StartEditing(wsOut);
                Editor.StartOperation();
            }
            // Otherwise, it must be a FileSystem (for shapefiles)
            // or LocalDatabase (for geodatabases) workspace.
            else
            {
                workspaceEdit = (IWorkspaceEdit)outWS;
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
            }
            
            IFeatureCursor exportFeatureCursor =
                (IFeatureCursor)hluDisplayTable.SearchDisplayTable(exportQueryFilter, true);
            IFeature exportFeature;

            IFeatureCursor insertCursor = outFeatureClass.Insert(true);
            IFeatureBuffer featureBuffer = outFeatureClass.CreateFeatureBuffer();

            bool calcGeometry = _hluFeatureClass.ShapeType == esriGeometryType.esriGeometryPoint || isShp;
            double geom1;
            double geom2;
            // The last two fields are always the geometry fields.
            int ixGeom1 = featureBuffer.Fields.FieldCount - 2;
            int ixGeom2 = featureBuffer.Fields.FieldCount - 1;

            try
            {
                object item;
                while ((exportFeature = exportFeatureCursor.NextFeature()) != null)
                {
                    featureBuffer.Shape = exportFeature.ShapeCopy;

                    for (int i = 2; i < exportFieldMap.Length; i++)
                    {
                        item = exportFeature.get_Value(exportFieldMap[i]);
                        if (item != DBNull.Value)
                            featureBuffer.set_Value(i, item);
                        //---------------------------------------------------------------------
                        // FIX: 036 Clear all missing fields when exporting features from ArcGIS.
                        else
                            featureBuffer.set_Value(i, null);
                        //---------------------------------------------------------------------
                    }

                    if (calcGeometry)
                    {
                        GetGeometryProperties(exportFeature, out geom1, out geom2);
                        if (geom1 != -1)
                            featureBuffer.set_Value(ixGeom1, geom1);
                        if (geom2 != -1)
                            featureBuffer.set_Value(ixGeom2, geom2);
                    }

                    try { insertCursor.InsertFeature(featureBuffer); }
                    catch { }

                    // Check if the cancel button was pressed. If so, stop the process.
                    contProgress = trackCancel.Continue();
                    if (!contProgress)
                        throw new Exception("Export cancelled by user.");
                }
                FlushCursor(false, ref insertCursor);

                if (workspaceEdit == null)
//.........这里部分代码省略.........
开发者ID:HabitatFramework,项目名称:HLUTool,代码行数:101,代码来源:HluArcMapExtension.cs

示例5: InsertPivoTableRowsToFeatureClass

        private void InsertPivoTableRowsToFeatureClass(
            IFeatureClass featureClass,
            PivotTable ptable,
            Dictionary<string, string> uniqueFieldNames)
        {
            // get the polygon of the geohash
            var insertCur = featureClass.Insert(true);
            this.pbarChangeDet.Maximum = ptable.Count;
            this.pbarChangeDet.Minimum = 0;
            this.pbarChangeDet.Value = 0;
            var fieldsInFc = new List<string>();
            for (var y = 0; y < featureClass.Fields.FieldCount; y++)
            {
                fieldsInFc.Add(featureClass.Fields.Field[y].Name);
            }

            var i = 0;
            foreach (var entry in ptable)
            {
                i++;
                this.UpdatePBar(i);

                var poly = this.GetGeoHashPoly(entry.RowKey);
                var buffer = featureClass.CreateFeatureBuffer();

                // Setup the features geometry.
                buffer.Shape = (IGeometry)poly;

                buffer.Value[featureClass.FindField("Geohash")] = entry.RowKey;
                foreach (var val in entry.Data.Keys)
                {
                    if (uniqueFieldNames.ContainsKey(val))
                    {
                        try
                        {
                            if (val.EndsWith("_str"))
                            {
                                var fieldName = "DG_" + uniqueFieldNames[val];
                                var field = featureClass.FindField(fieldName);
                                var value = entry.Label;

                                buffer.Value[field] = value;
                            }
                            else
                            {
                                var fieldName = "DG_" + uniqueFieldNames[val];
                                var field = featureClass.FindField(fieldName);
                                var value = entry.Data[val];

                                buffer.Value[field] = value;
                            }
                        }
                        catch (Exception error)
                        {
                            Jarvis.Logger.Error(error);
                        }
                    }
                }
                // Feature has been created so add to the feature class.
                insertCur.InsertFeature(buffer);
            }
            insertCur.Flush();
        }
开发者ID:DigitalGlobe,项目名称:DGConnect-ESRI,代码行数:63,代码来源:AggregationWindow.xaml.cs

示例6: AppendAnnoElements

        public void AppendAnnoElements(ILayer pSrcLayer, IFeatureClass pTargetFC,IActiveView activeview)
        {
            //首先从cad的注记层得到一个注记,然后得到他的Annotation,再赋给新建的要素
            //IQueryFilter queryfilter = new QueryFilterClass();
            //queryfilter.WhereClause = "Layer = '" + filter + "'";
            try
            {
                IFeatureLayer pSrcFLayer = pSrcLayer as IFeatureLayer;
                IFeatureClass pSrcFC = pSrcFLayer.FeatureClass;
                IFeature cadFeat;
                IElement featElement;
                IDataset pDataset;
                pDataset = pTargetFC as IDataset;
                IFDOGraphicsLayer pFDOGLayer;
                IFDOGraphicsLayerFactory pGLF = new FDOGraphicsLayerFactoryClass();
                ICoverageAnnotationLayer pCadAnnoLayer;
                pCadAnnoLayer = pSrcLayer as ICoverageAnnotationLayer;
                IWorkspace pWorkspace = pDataset.Workspace as IWorkspace;
                IWorkspaceEdit pWorkspaceEdit = pWorkspace as IWorkspaceEdit;

                IScreenDisplay screendis = activeview.ScreenDisplay;
                pFDOGLayer = pGLF.OpenGraphicsLayer((IFeatureWorkspace)pDataset.Workspace, pTargetFC.FeatureDataset, pDataset.Name) as IFDOGraphicsLayer;
                pCadAnnoLayer.StartGeneratingGraphics(null, screendis, false);
                pCadAnnoLayer.NextFeatureAndGraphic(out cadFeat, out featElement);
                //IFeature newFeature;
                IFeature cadFeature;
                IAnnotationFeature pAnnoFeature;
                IPolygon poly = new PolygonClass();
                //IEnvelope box;
                pWorkspaceEdit.StartEditing(false);
                pWorkspaceEdit.StartEditOperation();
                //int index;
                //pFDOGLayer.BeginAddElements();
                int count = 0;
                //pstepro.StepValue = 1;
                IFeatureBuffer featbuffer = pTargetFC.CreateFeatureBuffer();
                IFeatureCursor featCur = pTargetFC.Insert(true);

                while (cadFeat != null && featElement != null)
                {
                    //pFDOGLayer.DoAddFeature(cadFeat, featElement, 0);
                    //判断分在那一个层
                    count++;
                    //pstepro.Position = count;//进度条增加
                    cadFeature = pSrcFC.GetFeature(cadFeat.OID);
                    //if (cadFeature.get_Value(cadFeature.Fields.FindField("Layer")).ToString() != filter)
                    //{
                    //    pCadAnnoLayer.NextFeatureAndGraphic(out cadFeat, out featElement);
                    //    continue;
                    //}
                    //newFeature = pTargetFC.CreateFeature();
                    poly = cadFeat.ShapeCopy as IPolygon;
                    featbuffer.Shape = poly as IGeometry;
                    pAnnoFeature = featbuffer as IAnnotationFeature;
                    pAnnoFeature.Annotation = featElement;

                    int index1 = getLayerIndex(cadFeature.get_Value(cadFeature.Fields.FindField("Layer")).ToString());

                    featbuffer.set_Value(4, index1);
                    featCur.InsertFeature(featbuffer);
                    //newFeature.Store();
                    ///////////////
                    pCadAnnoLayer.NextFeatureAndGraphic(out cadFeat, out featElement);
                }
                featCur.Flush();
                //pFDOGLayer.EndAddElements();
                pWorkspaceEdit.StopEditOperation();
                pWorkspaceEdit.StopEditing(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:74,代码来源:GDBData.cs

示例7: MatchTable

        /// <summary>
        /// Geocodes a table of addresses
        /// </summary>
        /// <param name="addressTable">Input address table</param>
        /// <param name="addressFieldNames">Fields defined in the table</param>
        /// <param name="whereClause">Query filter where clause</param>
        /// <param name="outputFeatureClass">Output feature class for matched addresses</param>
        /// <param name="outputFieldNames">Output field names</param>
        /// <param name="fieldsToCopy"></param>
        /// <param name="cancelTracker"></param>
        public virtual void MatchTable(ITable addressTable, String addressFieldNames, String whereClause,
          IFeatureClass outputFeatureClass, String outputFieldNames, IPropertySet fieldsToCopy, ITrackCancel cancelTracker)
        {
            _log.Debug("IAddressGeocoding MatchTable");

              // Obtain the read and insert cursors
              IQueryFilter queryFilter = new QueryFilterClass();
              queryFilter.WhereClause = whereClause;
              ICursor readCursor = null;
              IFeatureCursor insertCursor = null;
              IFeatureCursor updateCursor = null;

              // m_needToUpdate will be True when a Rematch is being preformed
              if (m_needToUpdate)
              {
              // Create update cursor to update matched records
              updateCursor = outputFeatureClass.Update(queryFilter, false);
              if (isSameObject(addressTable, outputFeatureClass))
                  readCursor = updateCursor as ICursor;
              else
                  readCursor = addressTable.Search(queryFilter, true);
              }
              else
              {
              // Create insert cursor to add new records
              readCursor = addressTable.Search(queryFilter, true);
              insertCursor = outputFeatureClass.Insert(true);
              }

              int count = addressTable.RowCount(queryFilter);

              // Progress dialog setup
              IStepProgressor progressor = null;
              if (cancelTracker != null)
              progressor = cancelTracker.Progressor as IStepProgressor;
              IProgressStatistics progStats = cancelTracker as IProgressStatistics;
              if (progressor != null)
              {
              progressor.StepValue = 1;
              progressor.MaxRange = addressTable.RowCount(null);
              }

              // Separate the input field names
              string[] multilineFields = addressFieldNames.Split(',');

              // Read the first row and get the address field
              IRow row = readCursor.NextRow();

              Dictionary<int, string> addressFieldIndexes = new Dictionary<int, string>();

              // Get the index of each valid field
              for (int i = 0; i < multilineFields.Length; i++)
              {
              if (multilineFields[i].Trim().Length > 0)
                  addressFieldIndexes.Add(row.Fields.FindField(multilineFields[i].Trim()), multilineFields[i].Trim());
              }

              string address;
              IPropertySet addressProperties = new PropertySetClass();
              IPropertySet resultSet;
              IFeatureBuffer featureBuffer;
              object copyTo, copyFrom, key, value;

              // Get the name and value of all the properties in the property set
              fieldsToCopy.GetAllProperties(out copyTo, out copyFrom);
              string[] copyToArray = copyTo as string[];
              object[] copyFromArray = copyFrom as object[];
              string matchStatus = "U";

              // Populate the output feature class
              while (row != null)
              {
              featureBuffer = outputFeatureClass.CreateFeatureBuffer();
              foreach (KeyValuePair<int,string> entry in addressFieldIndexes)
              {
                  if (entry.Key != -1)
                      address = row.get_Value(entry.Key) as string;
                  else
                      address = row.get_Value(0) as string;

                  addressProperties.SetProperty(entry.Value, address);
              }

              resultSet = MatchAddress(addressProperties);

              // Get all of the fields and values of the result
              resultSet.GetAllProperties(out key, out value);
              string[] names = key as string[];
              object[] items = value as object[];

//.........这里部分代码省略.........
开发者ID:EsriUK,项目名称:dynamic-locator-sdk,代码行数:101,代码来源:LocatorWrapper.cs

示例8: using

        object ICopyFeatures.CopyBulkFeature(IFeature copiedFeature, IFeatureClass toFeatureClass)
        {
            // Create a ComReleaser for cursor management.
               using (ComReleaser comReleaser = new ComReleaser())
               {
               // Create and manage a feature buffer.
               IFeatureBuffer featureBuffer = toFeatureClass.CreateFeatureBuffer();
               comReleaser.ManageLifetime(featureBuffer);

               // Create and manage an insert cursor.
               IFeatureCursor featureCursor = toFeatureClass.Insert(true);
               comReleaser.ManageLifetime(featureCursor);
               featureBuffer.Shape = copiedFeature.ShapeCopy;
               featureCursor.InsertFeature(featureBuffer);
               // Attempt to flush the buffer.
               featureCursor.Flush();
               //MessageBox.Show(string.Format("line 529 DataManager \n{0}", featureBuffer.get_Value(0)));
               //return featureBuffer.get_Value(0);
               return 1;
               }
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:21,代码来源:DataManager.cs

示例9: catch

        object ICopyFeatures.CopyWithAllAttribute(IFeature copiedFeature, IFeatureClass toFeatureClass)
        {
            object id = 0;
               try
               {
               IFeatureCursor featureCursorInsert = toFeatureClass.Insert(true);
               IFeatureBuffer featureBufferInsert = toFeatureClass.CreateFeatureBuffer();
               //releaser.ManageLifetime(featureBufferInsert);
               //releaser.ManageLifetime(featureCursorInsert);
               // Add the original feature's geometry to the feature buffer.
               featureBufferInsert.Shape = copiedFeature.Shape;
               // Add all the original feature's fields to the feature buffer.
               //((ICopyFeatures)this).AddFields(featureBufferInsert, copiedFeature);
               // Insert the feature into the cursor.

               for (int i = 1; i < copiedFeature.Fields.FieldCount; i++)
               {
                   IFeatureClass sourceFeatureClass = (IFeatureClass)copiedFeature.Class;

                   string fieldName = copiedFeature.Fields.get_Field(i).Name;
                   bool bCondition1 = fieldName == sourceFeatureClass.ShapeFieldName;
                   bool bCondition2 = (sourceFeatureClass.LengthField != null &&
                                       fieldName == sourceFeatureClass.LengthField.Name);
                   bool bCondition3 = (sourceFeatureClass.AreaField != null &&
                                       fieldName == sourceFeatureClass.AreaField.Name);

                   if (!(bCondition1 || bCondition2 || bCondition3))
                   // Don't do shape fields
                   {
                       int myTargetFieldId = toFeatureClass.FindField(fieldName);
                       // Id of field in source feature
                       featureBufferInsert.set_Value(myTargetFieldId, copiedFeature.get_Value(i)); // Copy value

                   }
               }

               id = featureCursorInsert.InsertFeature(featureBufferInsert);
               featureCursorInsert.Flush();
               //_workspaceEdit.StopEditOperation();
               //_workspaceEdit.StopEditing(true);
               }
               catch (Exception ex)
               {
               //_workspaceEdit.AbortEditOperation();
               //_workspaceEdit.StopEditing(false);
               }
               return id;
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:48,代码来源:DataManager.cs

示例10: BoboDataGeneration

        private void BoboDataGeneration(IFeatureClass featureClass, IFeatureWorkspace featureWorkspace)
        {
            ((IWorkspaceEdit)featureWorkspace).StartEditing(true);
            ((IWorkspaceEdit)featureWorkspace).StartEditOperation();

            IFeatureCursor featureCursor = featureClass.Insert(false);
            int XCoord;
            int YCoord;
            int histValue;
            Random random = new Random();

            for(int i = 0; i < 1000; i++)
            {
                //Generate random values for points and for point values

                XCoord = random.Next(-179, 179);
                YCoord = random.Next(-89, 89);
                histValue = random.Next(1, 255);

                int histoGramData = featureCursor.Fields.FindField("HistoField");
                //Andrew Method
                //IFeature f = featureClass.CreateFeature();
                //f.Value[histoGramData] = histValue;
                //f.Shape = new Point() {X = XCoord, Y = YCoord};
                //f.Store();
                //Nohe method
                IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
                featureBuffer.Value[histoGramData] = histValue;
                featureBuffer.Shape = new Point() { X = XCoord, Y = YCoord };

                featureCursor.InsertFeature(featureBuffer);

            }
            //featureCursor.Flush();
            ((IWorkspaceEdit)featureWorkspace).StopEditOperation();
            ((IWorkspaceEdit) featureWorkspace).StopEditing(true);
        }
开发者ID:nohe427,项目名称:MyAddins,代码行数:37,代码来源:HistoClass.cs

示例11: InsertFeaturesBoun

        private static void InsertFeaturesBoun(IFeatureClass newFeatureClass, IFeatureCursor featureCursorSearch, IGeometry clipGeo)
        {
            int intFeatureCount = 0;

            IFeatureCursor featureCursorInsert = newFeatureClass.Insert(true);
            IFeatureBuffer featureBufferInsert = newFeatureClass.CreateFeatureBuffer();

            IFeature feature = featureCursorSearch.NextFeature();
            while (feature != null)
            {
                ITopologicalOperator topoOpe = feature.Shape as ITopologicalOperator;
                IGeometry intersect = topoOpe.Intersect(clipGeo, feature.Shape.Dimension);
                featureBufferInsert.Shape = intersect;

                AddFields(featureBufferInsert, feature);

                featureCursorInsert.InsertFeature(featureBufferInsert);

                if (++intFeatureCount == 100)
                {
                    featureCursorInsert.Flush();
                    intFeatureCount = 0;
                }

                feature = featureCursorSearch.NextFeature();
            }

            featureCursorInsert.Flush();
        }
开发者ID:oopsliu,项目名称:qixiangju,代码行数:29,代码来源:Form1.cs

示例12: SplitPolyline

        public static List<int> SplitPolyline(IPolyline srcLine, List<IPoint> pts, Dictionary<string, string> values, IFeatureClass fc, IFeatureClass districtFC, bool dropHead, bool dropTail)
        {
            var lines = SplitPolylineInner(srcLine, pts);
            var cursor = fc.Insert(true);
            var idIndex = cursor.FindField(IDField);
            var count = 0;
            var ret = new List<int>();
            var id = GetNewId(fc);
            var dIndex = cursor.FindField("DISTRICT");
            var dIndex2 = cursor.FindField("DISTRICTNO");
            foreach (var line in lines)
            {
                if ((dropHead == true && count == 0) || (dropTail == true && count == lines.Count - 1))
                {
                    count++;
                    continue;
                }

                var buff = fc.CreateFeatureBuffer();
                buff.Shape = line;
                CopyValues(buff, values);
                string d,dNO;
                GetDistrictInfo(line, districtFC, out d, out dNO);
                buff.set_Value(dIndex, d);
                if(string.IsNullOrEmpty(dNO))
                {
                    buff.set_Value(dIndex2, DBNull.Value);
                }
                else
                {
                    buff.set_Value(dIndex2, int.Parse(dNO));
                }

                buff.set_Value(idIndex, id);
                ret.Add(id);
                cursor.InsertFeature(buff);
                cursor.Flush();
                id++;
                count++;
            }

            Marshal.ReleaseComObject(cursor);
            return ret;
        }
开发者ID:LooWooTech,项目名称:Traffic,代码行数:44,代码来源:RoadHelper.cs

示例13: InsertNomarlError

        private bool InsertNomarlError(IFeatureClass destFClass)
        {
            try
            {
                string strSQL = @"
                            SELECT
                            b.CheckType,
                            a.TargetFeatClass1 as YSTC,
                            a.BSM as SourceBSM,
                            a.TargetFeatClass2 as MBTC,
                            a.BSM2 as BSM2,
                            '' as TopoLayerName,
                            a.ErrMsg as Description,
                            IIF(a.IsException,1,0) as IsException,
                            IIf(a.Remark is Null,'',a.Remark) as Remark,
                            b.GZBM,
                            a.OID as OID

                            from LR_ResAutoAttr as a, LR_ResultEntryRule as b where a.RuleInstID=b.RuleInstID";

                DataTable dtError = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.ResultConnection, strSQL);
                IFeatureCursor fCusorInsert = destFClass.Insert(false);
                Dictionary<string, IFeatureClass> dictFeatureClass = new Dictionary<string, IFeatureClass>();
                Dictionary<int, int> dictFieldIndex = new Dictionary<int, int>();
                for (int i = 0; i < m_FieldCaptions.Count; i++)
                {
                    dictFieldIndex.Add(i,destFClass.FindField(m_FieldCaptions[i]));
                }
                int xFieldIndex = destFClass.FindField("X����");
                int yFieldIndex = destFClass.FindField("Y����");

                for (int i = 0; i < dtError.Rows.Count; i++)
                {
                    DataRow rowError = dtError.Rows[i];
                    IFeatureClass curFClass;
                    string strFClassAlias = rowError["YSTC"] as string;
                    if (!dictFeatureClass.ContainsKey(strFClassAlias))
                    {
                        int standardID = SysDbHelper.GetStandardIDBySchemaID(this.SchemaID);
                        string strFClass = LayerReader.GetNameByAliasName(strFClassAlias, standardID);
                        IFeatureClass fClass = (this.BaseWorkspace as IFeatureWorkspace).OpenFeatureClass(strFClass);
                        dictFeatureClass.Add(strFClassAlias, fClass);
                        curFClass = fClass;
                    }
                    else
                    {
                        curFClass = dictFeatureClass[strFClassAlias];
                    }

                    if (curFClass == null)
                        continue;

                    object objOID = rowError["OID"];
                    if (objOID == null)
                        continue;

                    int oid = Convert.ToInt32(objOID);
                    IFeature srcFeature = curFClass.GetFeature(oid);
                    if (srcFeature == null)
                        continue;

                    IFeatureBuffer fNew = destFClass.CreateFeatureBuffer();
                    for (int j = 0; j < m_FieldCaptions.Count; j++)
                    {
                        int fIndex = dictFieldIndex[j];
                        if (fIndex < 0)
                            continue;

                        fNew.set_Value(fIndex, rowError[j]);
                    }
                    fNew.Shape = GetErrorGeometry(srcFeature);
                    IPoint point = fNew.Shape as IPoint;
                    fNew.set_Value(xFieldIndex, point.X);
                    fNew.set_Value(yFieldIndex, point.Y);

                    fCusorInsert.InsertFeature(fNew);

                    if (i % 2000 == 0)
                        fCusorInsert.Flush();
                }

                fCusorInsert.Flush();

                return true;
            }
            catch(Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return false;
            }
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:92,代码来源:ErrorExporter.cs

示例14: InsertFeaturesUsingCursor

    public void InsertFeaturesUsingCursor(IFeatureClass ipTargetFC, IFeatureCursor featuresToCopy, string sShakeMapID)
    {
      IFeatureCursor ipInsCursor = null;
      try
      {
        IFeatureBuffer ipFBuff = ipTargetFC.CreateFeatureBuffer();
        ipInsCursor = ipTargetFC.Insert(true);
        IFeature ipFeat;
        IFields ipTargetFields;
        IField ipTargetField;
        int featureOID;

        while ((ipFeat = featuresToCopy.NextFeature()) != null)
        {
          ipFBuff.Shape = ipFeat.ShapeCopy;

          ipTargetFields = ipTargetFC.Fields as IFields;
          for (int i = 0; i < ipTargetFields.FieldCount; i++)
          {
            ipTargetField = ipTargetFields.get_Field(i);

            //skip field that is not editable or is an OID field (OID field automatically being filled)
            if ((!ipTargetField.Editable) || (ipTargetField.Type == esriFieldType.esriFieldTypeOID)
                || ipTargetField.Type == ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry)
            {
              continue;
            }

            //not geometry column, not subtype, and not OID or other read-only type
            string sFieldName = ipTargetField.Name;
            int iIndex = ipFeat.Fields.FindField(sFieldName);

            object oValue = null;

            //if the field exists in the srcFeatureCls and the types match, copy the value over
            if ((iIndex != -1) && (ipFeat.Fields.get_Field(iIndex).Type == ipTargetField.Type))
            {
              oValue = ipFeat.get_Value(iIndex);

              if (ipTargetField.CheckValue(oValue) == false)
              {
                // Source feature's value for this field is invalid for destination field
                oValue = ipTargetField.DefaultValue;
              }
            }
            //if the field doesn't exist, set default value for the field
            else
            {
              // Check if sShakeMapID field to populate it.
              if (sFieldName == "ShakeMapID")
              {
                oValue = sShakeMapID;
              }
              else
              {
                oValue = ipTargetField.DefaultValue;
              }
            }

            // assign the value, unless it's null and the field is not nullable
            if (((oValue != null) && (oValue.ToString() != "")) || ipTargetField.IsNullable)
            {
              ipFBuff.set_Value(i, oValue);
            }
          }

          featureOID = (int)ipInsCursor.InsertFeature(ipFBuff);

        }

        ipInsCursor.Flush();
        
      }
      catch (Exception ex)
      {
        throw ex;
      }
      finally
      {
        if (ipInsCursor != null)
        {
          System.Runtime.InteropServices.Marshal.ReleaseComObject(ipInsCursor);
          ipInsCursor = null;
        }
      }
    }
开发者ID:leijiancd,项目名称:arcgis-osm-editor,代码行数:86,代码来源:ArcObjects.cs

示例15: InsertTopoError

        private bool InsertTopoError(IFeatureClass destFClass)
        {
            try
            {
                string strSQL = @"SELECT
                            b.CheckType,
                            IIF(b.TargetFeatClass1 is Null,'',b.TargetFeatClass1) as YSTC,
                            IIF(a.SourceBSM is Null,'',a.SourceBSM) as SourceBSM,
                            IIF(a.MBTC is Null,'',a.MBTC) as MBTC,
                            IIF(a.TargetBSM is Null,'',a.TargetBSM) as BSM2,
                            a.TPTC as TopoLayerName,
                            a.Reason as Description,
                            a.IsException as IsException,
                            IIf(a.Remark is Null,'',a.Remark) as Remark,
                            b.GZBM ,
                            a.ArcGisRule as ArcGisRule,
                            a.JHLX as JHLX,
                            a.SourceLayerID,
                            a.TargetLayerID,
                            a.SourceOID as OID,
                            a.TargetOID as OID2
                            from LR_ResAutoTopo as a, LR_ResultEntryRule as b where a.RuleInstID=b.RuleInstID
                            ";

                DataTable dtError = Hy.Common.Utility.Data.AdoDbHelper.GetDataTable(this.ResultConnection, strSQL);

                IFeatureCursor fCusorInsert = destFClass.Insert(false);
                Dictionary<int, int> dictFieldIndex = new Dictionary<int, int>();
                for (int i = 0; i < m_FieldCaptions.Count; i++)
                {
                    dictFieldIndex.Add(i,destFClass.FindField(m_FieldCaptions[i]));
                }
                int xFieldIndex = destFClass.FindField("X����");
                int yFieldIndex = destFClass.FindField("Y����");

                IErrorFeatureContainer errFeatureContainer = this.Topology as IErrorFeatureContainer;
                ISpatialReference spatialRef = (this.Topology as IGeoDataset).SpatialReference;
                for (int i = 0; i < dtError.Rows.Count; i++)
                {
                    DataRow rowError = dtError.Rows[i];
                    int fClassID = Convert.ToInt32(rowError["SourceLayerID"]);
                    int fClassID2 = Convert.ToInt32(rowError["TargetLayerID"]);
                    int oid = Convert.ToInt32(rowError["OID"]);
                    int oid2 = Convert.ToInt32(rowError["OID2"]);
                    esriGeometryType geoType = (esriGeometryType)Convert.ToInt32(rowError["JHLX"]);
                    esriTopologyRuleType ruleType = (esriTopologyRuleType)Convert.ToInt32(rowError["ArcGISRule"]);

                    IFeature srcFeature = errFeatureContainer.get_ErrorFeature(spatialRef, ruleType, geoType, fClassID, fClassID2, oid, oid2) as IFeature;

                    IFeatureBuffer fNew = destFClass.CreateFeatureBuffer();
                    for (int j = 0; j < m_FieldCaptions.Count; j++)
                    {
                        int fIndex = dictFieldIndex[j];
                        if (fIndex < 0)
                            continue;

                        fNew.set_Value(fIndex, rowError[j]);
                    }
                    fNew.Shape = GetErrorGeometry(srcFeature);
                    IPoint point = fNew.Shape as IPoint;
                    fNew.set_Value(xFieldIndex, point.X);
                    fNew.set_Value(yFieldIndex, point.Y);

                    fCusorInsert.InsertFeature(fNew);

                    if (i % 2000 == 0)
                        fCusorInsert.Flush();

                }

                fCusorInsert.Flush();

                return true;
            }
            catch(Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
                return false;
            }
        }
开发者ID:hy1314200,项目名称:HyDM,代码行数:80,代码来源:ErrorExporter.cs


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