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


C# ITable.Update方法代码示例

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


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

示例1: ajusterNaipfddm

        private void ajusterNaipfddm(ITable pTable)
        {
            // Error Handling
            const string functionName = "addField";

            IRow pRow;
            ICursor pCursor;
            IQueryFilter iQf = new QueryFilter();

            try
            {
                iQf.SubFields = "NAIF1_DDM, ET1_ESS1, ET1_PC1, ET1_ESS2, ET1_PC2, ET1_ESS3, ET1_PC3, ET1_ESS4, ET1_PC4, ET1_ESS5, ET1_PC5, ET1_ESS6, ET1_PC6, ET1_ESS7, ET1_PC7";
                iQf.WhereClause = "naif1_ddm = ''";

                pCursor = pTable.Update(iQf, false);
                pRow = pCursor.NextRow();

                string sFinal;
                int iPourc;

                while (pRow != null)
                {
                    sFinal = "";

                    for (int i = 1; i < SF10_clsBase.i_NAIPFMaxControls; i++)
                    {
                        if (pRow.Value[pRow.Fields.FindField("et1_ess" + i)].ToString().Trim().Length != 0)
                        {
                            iPourc = 100;
                            if (pRow.Value[pRow.Fields.FindField("et1_pc" + i)].ToString().Trim().Length != 0) { iPourc = valeurToPourc(pRow.Value[pRow.Fields.FindField("et1_pc" + i)].ToString().Trim()); }

                            sFinal += pRow.Value[pRow.Fields.FindField("et1_ess" + i)] + iPourc.ToString();
                        }
                    }

                    pRow.Value[pRow.Fields.FindField("NAIF1_DDM")] = sFinal;
                    pCursor.UpdateRow(pRow);
                    pRow = pCursor.NextRow();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(functionName + " :: " + e.Message, "SF10", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
            }
        }
开发者ID:GroupeDDM,项目名称:saisieforestiere10,代码行数:48,代码来源:SF10_frmCreerShapefileSaisie.cs

示例2: ResetPointAssociations

        private bool ResetPointAssociations(ITable PointTable, IQueryFilter QueryFilter, bool Unversioned, 
        IStepProgressor StepProgressor, ITrackCancel TrackCancel)
        {
            try
              {
            ITableWrite pTableWr = (ITableWrite)PointTable;//used for unversioned table
            IRow pPointFeat = null;
            ICursor pPtCurs = null;

            if (Unversioned)
              pPtCurs = pTableWr.UpdateRows(QueryFilter, false);
            else
              pPtCurs = PointTable.Update(QueryFilter, false);

            pPointFeat = pPtCurs.NextRow();

            if (StepProgressor != null)
            {
              if (StepProgressor.Position < StepProgressor.MaxRange)
            StepProgressor.Step();
            }

            Int32 iPointIDX = pPtCurs.Fields.FindField("NAME");
            bool bCont = true;
            while (pPointFeat != null)
            {//loop through all of the fabric points, and if any of the point id values are in the deleted set,
              //then remove the control name from the point's NAME field

              if (TrackCancel != null)
            bCont = TrackCancel.Continue();
              if (!bCont)
            break;

              pPointFeat.set_Value(iPointIDX, DBNull.Value);
              if (Unversioned)
            pPtCurs.UpdateRow(pPointFeat);
              else
            pPointFeat.Store();

              Marshal.ReleaseComObject(pPointFeat); //garbage collection
              pPointFeat = pPtCurs.NextRow();

              if (StepProgressor != null)
              {
            if (StepProgressor.Position < StepProgressor.MaxRange)
              StepProgressor.Step();
              }
            }
            Marshal.ReleaseComObject(pPtCurs); //garbage collection

            if (!bCont)
              return false;
            return true;

              }
              catch (COMException ex)
              {
            MessageBox.Show("Problem resetting point table's control association: " + Convert.ToString(ex.ErrorCode));
            return false;
              }
        }
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:61,代码来源:TruncateFabricTables.cs

示例3: UpdataTable

        public bool UpdataTable(ITable pTable, string pFromField, string pToField)
        {
            int pIndex = pTable.FindField(pFromField);

             int pIndex1 = pTable.FindField(pToField);

             try
             {
             if (pIndex != -1)
             {
                 if (pIndex1 != -1)
                 {
                     ICursor pCursor = pTable.Update(null, false);

                     IRow pRow = pCursor.NextRow();

                     while (pRow != null)
                     {
                         string[] pArr = pRow.get_Value(pIndex).ToString().Split('_');
                         //sevp_aoc_rdcp_sldas_ebref_achn_l88_pi_201212050010
                         string pFileName = pArr[pArr.Length - 1];

                         int pDay = Convert.ToInt16(pFileName.Substring(6, 2));
                         int pHour = Convert.ToInt16(pFileName.Substring(8, 2)) + 8;
                         if (pHour >= 24)
                         {
                             pDay = pDay + 1;

                             pHour = pHour - 24;
                         }
                         string pData = pFileName.Substring(0, 4) + "-" + pFileName.Substring(4, 2) + "-" + pDay.ToString("00") + " " + pHour.ToString() + ":" + pFileName.Substring(10, 2) + ":00";
                         pRow.set_Value(pIndex1, pData);

                         pCursor.UpdateRow(pRow);

                         pRow = pCursor.NextRow();

                     }

                 }

             }
             }
             catch (System.Exception ex)
             {
             return false;
             }

             return true;
        }
开发者ID:Krystal001025,项目名称:temp,代码行数:50,代码来源:ClassRasterOp.cs

示例4: FixBug

        public bool FixBug(ITable pTable, string pFromField, object pValue)
        {
            int pIndex = pTable.FindField(pFromField);

             try
             {
             if (pIndex != -1)
             {

                     ICursor pCursor = pTable.Update(null, false);

                     IRow pRow = pCursor.NextRow();

                     while (pRow != null)
                     {

                         //string pData = pFileName.Substring(0, 4) + "-" + pFileName.Substring(4, 2) + "-" + pDay.ToString("00") + " " + pHour.ToString() + ":" + pFileName.Substring(10, 2) + ":00";
                         pRow.set_Value(pIndex, pValue);

                         pCursor.UpdateRow(pRow);

                         pRow = pCursor.NextRow();

                 }

             }
             }
             catch (System.Exception ex)
             {
             return false;
             }

             return true;
        }
开发者ID:Krystal001025,项目名称:temp,代码行数:34,代码来源:ClassRasterOp.cs

示例5: DeleteByInClause

        public bool DeleteByInClause(IWorkspace TheWorkSpace, ITable inTable, IField QueryIntegerField,
      List<string> InClauseIDs, bool IsVersioned, IStepProgressor StepProgressor, ITrackCancel TrackCancel)
        {
            IMouseCursor pMouseCursor = new MouseCursorClass();
              pMouseCursor.SetCursor(2);

              IQueryFilter pQF = new QueryFilterClass();

              ISQLSyntax pSQLSyntax = (ISQLSyntax)TheWorkSpace;
              string sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
              string sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

              ICursor ipCursor = null;
              IRow pRow = null;
              //make sure that there are no more then 999 tokens for the in clause(ORA- query will otherwise error on an Oracle database)
              //this code assumes that InClauseIDs holds an arraylist of comma separated OIDs with no more than 995 id's per list item
              string sWhereClauseLHS = sPref + QueryIntegerField.Name + sSuff + " in (";

              try
              {
            ITableWrite pTableWr = (ITableWrite)inTable;
            bool bCont = true;

            Int32 count = InClauseIDs.Count - 1;
            for (int k = 0; k <= count; k++)
            {
              pQF.WhereClause = sWhereClauseLHS + InClauseIDs[k] + ")"; //left-hand side of the where clause
              if (pQF.WhereClause.Contains("()"))
            continue;
              if (!IsVersioned)
            ipCursor = pTableWr.UpdateRows(pQF, false);
              else
            ipCursor = inTable.Update(pQF, false);

              pRow = ipCursor.NextRow();
              while (pRow != null)
              {
            ipCursor.DeleteRow();
            Marshal.ReleaseComObject(pRow);
            if (StepProgressor != null)
            {
              //Check if the cancel button was pressed. If so, stop process
              if (TrackCancel != null)
                bCont = TrackCancel.Continue();
              if (!bCont)
                break;
              if (StepProgressor.Position < StepProgressor.MaxRange)
                StepProgressor.Step();
            }
            pRow = ipCursor.NextRow();
              }

              if (!bCont)
              {
            AbortEditing(TheWorkSpace);
            if (ipCursor != null)
              Marshal.ReleaseComObject(ipCursor);
            if (pRow != null)
              Marshal.ReleaseComObject(pRow);
            return false;
              }
              Marshal.ReleaseComObject(ipCursor);
            }
            return true;
              }

              catch (Exception ex)
              {
            if (ipCursor != null)
              Marshal.ReleaseComObject(ipCursor);
            if (pRow != null)
              Marshal.ReleaseComObject(pRow);
            MessageBox.Show(Convert.ToString(ex.Message));
            return false;
              }
        }
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:76,代码来源:Utilities.cs

示例6: renameField

        public void renameField(ITable inTable, string oldFldName, string newFldName)
        {
            IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)inTable;
            if (!objInfo2.CanBypassEditSession())
            {
                System.Windows.Forms.MessageBox.Show("Input Table participates in a composite relationship. Please export this table as a new table and try again!");
                return;
            }

            IWorkspace wks = ((IDataset)inTable).Workspace;
            IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
            if (wksE.IsBeingEdited())
            {
                wksE.StopEditing(true);
            }
            try
            {
                int inFldIndex = inTable.Fields.FindField(oldFldName);
                IField inFld = inTable.Fields.get_Field(inFldIndex);
                esriFieldType fType = inFld.Type;
                string outFldName = geoUtil.createField(inTable, newFldName, fType, false);
                IQueryFilter qf = new QueryFilterClass();
                ICursor cur = inTable.Update(qf, false);
                int outFldIndex = cur.FindField(outFldName);
                inFldIndex = cur.FindField(oldFldName);
                IRow rw = cur.NextRow();
                while (rw != null)
                {
                    rw.set_Value(outFldIndex, rw.get_Value(inFldIndex));
                    cur.UpdateRow(rw);
                    rw = cur.NextRow();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:39,代码来源:featureUtil.cs

示例7: updateSource

        private void updateSource(ITable sourceTable, string action, long oldOSMFeatureID, long newOSMFeatureID, string userName, int userID, int osmVersion, int changeSetID, Dictionary<long, long> nodeIDLookup, Dictionary<long, long> wayIDLookup, Dictionary<long, long> relationIDLookup, int extensionVersion)
        {
            IOSMClassExtension osmExtension = sourceTable.Extension as IOSMClassExtension;

            try
            {
                if (osmExtension != null)
                {
                    osmExtension.CanBypassChangeDetection = true;
                }

                // let's find all the matching row with the old osm feature ID
                IQueryFilter queryFilter = new QueryFilterClass();
                queryFilter.WhereClause = sourceTable.WhereClauseByExtensionVersion(oldOSMFeatureID, "osmID", extensionVersion);

                using (ComReleaser comReleaser = new ComReleaser())
                {
                    ICursor updateCursor = sourceTable.Update(queryFilter, false);
                    comReleaser.ManageLifetime(updateCursor);

                    IRow updateRow = updateCursor.NextRow();
                    comReleaser.ManageLifetime(updateRow);

                    int osmIDFieldIndex = sourceTable.Fields.FindField("osmID");
                    int osmUserFieldIndex = sourceTable.Fields.FindField("osmuser");
                    int osmUIDFieldIndex = sourceTable.Fields.FindField("osmuid");
                    int osmVersionFieldIndex = sourceTable.Fields.FindField("osmversion");
                    int osmVisibleFieldIndex = sourceTable.Fields.FindField("osmvisible");
                    int osmChangesetIDFieldIndex = sourceTable.Fields.FindField("osmchangeset");
                    int osmTimeStampFieldIndex = sourceTable.Fields.FindField("osmtimestamp");
                    int osmMembersFieldIndex = sourceTable.FindField("osmMembers");
                    int osmisMemberOfFieldIndex = sourceTable.FindField("osmMemberOf");
                    int trackChangesFieldIndex = sourceTable.FindField("osmTrackChanges");

                    if (updateRow != null)
                    {
                        if (osmIDFieldIndex > -1)
                        {
                            if (extensionVersion == 1)
                                updateRow.set_Value(osmIDFieldIndex, Convert.ToInt32(newOSMFeatureID));
                            else if (extensionVersion == 2)
                                updateRow.set_Value(osmIDFieldIndex, Convert.ToString(newOSMFeatureID));
                        }
                        if (osmUserFieldIndex > -1)
                        {
                            updateRow.set_Value(osmUserFieldIndex, userName);
                        }
                        if (osmUIDFieldIndex > -1)
                        {
                            updateRow.set_Value(osmUIDFieldIndex, userID);
                        }
                        if (osmVisibleFieldIndex > -1)
                        {
                            updateRow.set_Value(osmVisibleFieldIndex, "true");
                        }
                        if (osmChangesetIDFieldIndex > -1)
                        {
                            updateRow.set_Value(osmChangesetIDFieldIndex, changeSetID);
                        }
                        if (osmTimeStampFieldIndex > -1)
                        {
                            updateRow.set_Value(osmTimeStampFieldIndex, DateTime.Now.ToUniversalTime());
                        }
                        if (trackChangesFieldIndex > -1)
                        {
                            updateRow.set_Value(trackChangesFieldIndex, 1);
                        }

                        // if we are dealing with a row with a shape field (a feature), then change the IDs of the geometry as well
                        IFeature updateFeature = updateRow as IFeature;
                        if (updateFeature != null)
                        {
                            if (updateFeature.Shape.IsEmpty == false)
                            {
                                switch (updateFeature.Shape.GeometryType)
                                {
                                    case esriGeometryType.esriGeometryAny:
                                        break;
                                    case esriGeometryType.esriGeometryBag:
                                        break;
                                    case esriGeometryType.esriGeometryBezier3Curve:
                                        break;
                                    case esriGeometryType.esriGeometryCircularArc:
                                        break;
                                    case esriGeometryType.esriGeometryEllipticArc:
                                        break;
                                    case esriGeometryType.esriGeometryEnvelope:
                                        break;
                                    case esriGeometryType.esriGeometryLine:
                                        break;
                                    case esriGeometryType.esriGeometryMultiPatch:
                                        break;
                                    case esriGeometryType.esriGeometryMultipoint:
                                        break;
                                    case esriGeometryType.esriGeometryNull:
                                        break;
                                    case esriGeometryType.esriGeometryPath:
                                        break;
                                    case esriGeometryType.esriGeometryPoint:
                                        IPoint featurePoint = updateFeature.Shape as IPoint;
//.........这里部分代码省略.........
开发者ID:weepingdog,项目名称:arcgis-osm-editor,代码行数:101,代码来源:OSMGPUpload.cs

示例8: UpdateHistoryOnLines

        public bool UpdateHistoryOnLines(ITable pLinesTable, ITable pPointsTable,
         int iParcelCount, ICadastralFabric pCadFabric, List<string> sOIDList, 
      Dictionary<int, string> ParcelToHistory_DICT, IStepProgressor m_pStepProgressor, ITrackCancel m_pTrackCancel)
        {
            bool m_bShowProgressor = (iParcelCount > 10);
              sOIDList.Add("");
              int tokenLimit = 995;
              bool bCont = true;
              int j = 0;
              int iCounter = 0;
              ICadastralFabricSchemaEdit2 pSchemaEd = null;

              try
              {
            #region update line table history
            //Get the line table history fields
            //SystemStart, SystemEnd, LegalStart, LegalEnd, Historic
            int iParcelID = pLinesTable.FindField("parcelid");
            string sParcelID = pLinesTable.Fields.get_Field(iParcelID).Name;

            int iLineSysStartDate = pLinesTable.FindField("systemstartdate");
            string sLineSysStartDate = pLinesTable.Fields.get_Field(iLineSysStartDate).Name;

            int iLineSysEndDate = pLinesTable.FindField("systemenddate");
            string sLineSysEndDate = pLinesTable.Fields.get_Field(iLineSysEndDate).Name;

            int iLineLegalStartDate = pLinesTable.FindField("legalstartdate");
            string sLineLegalStartDate = pLinesTable.Fields.get_Field(iLineLegalStartDate).Name;

            int iLineLegalEndDate = pLinesTable.FindField("legalenddate");
            string sLineLegalEndDate = pLinesTable.Fields.get_Field(iLineLegalEndDate).Name;

            int iLineHistorical = pLinesTable.FindField("historical");
            string sLineHistorical = pLinesTable.Fields.get_Field(iLineHistorical).Name;

            int iFromPoint = pLinesTable.FindField("frompointid");
            string sFromPoint = pLinesTable.Fields.get_Field(iFromPoint).Name;

            int iToPoint = pLinesTable.FindField("topointid");
            string sToPoint = pLinesTable.Fields.get_Field(iToPoint).Name;

            IQueryFilter pQueryFilter = new QueryFilterClass();
            pQueryFilter.SubFields = pLinesTable.OIDFieldName + ", parcelid," + sLineSysStartDate +
              "," + sLineSysEndDate + "," + sLineLegalStartDate + "," + sLineLegalEndDate +
              "," + sLineHistorical + "," + sFromPoint + "," + sToPoint;

            pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric;
            pSchemaEd.ReleaseReadOnlyFields(pLinesTable, esriCadastralFabricTable.esriCFTLines); //release safety-catch

            Dictionary<int, string> PointToHistory_DICT = new Dictionary<int, string>(iParcelCount);

            List<string> sPointOIDList = new List<string>();
            List<int> iLinesOIDList = new List<int>();
            sPointOIDList.Add("");
            j = iCounter = 0;
            ICursor pCur = null;
            object obj = null;
            foreach (string sHistory in sOIDList)
            {
              if (sHistory.Trim() == "")
            continue;

              pQueryFilter.WhereClause = sParcelID + " IN (" + sHistory + ")";
              pCur = pLinesTable.Update(pQueryFilter, false);
              IRow pLine = pCur.NextRow();
              while (pLine != null)
              {
            //Check if the cancel button was pressed. If so, stop process
            if (m_bShowProgressor)
            {
              bCont = m_pTrackCancel.Continue();
              if (!bCont)
                break;
            }
            iLinesOIDList.Add(pLine.OID);
            string sParcHistory = "";
            if (ParcelToHistory_DICT.TryGetValue((int)pLine.get_Value(iParcelID), out sParcHistory))
            {
              string[] sHistoryItems = sParcHistory.Split(',');
              if (sHistoryItems[0].Trim() == "")
                obj = DBNull.Value;
              else
                obj = sHistoryItems[0];
              pLine.set_Value(iLineSysStartDate, obj);

              if (sHistoryItems[1].Trim() == "")
                obj = DBNull.Value;
              else
                obj = sHistoryItems[1];
              pLine.set_Value(iLineSysEndDate, obj);

              if (sHistoryItems[2].Trim() == "")
                obj = DBNull.Value;
              else
                obj = sHistoryItems[2];
              pLine.set_Value(iLineLegalStartDate, obj);

              if (sHistoryItems[3].Trim() == "")
                obj = DBNull.Value;
              else
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:101,代码来源:clsFabricUtils.cs

示例9: summarizeAcrossFields

        public void summarizeAcrossFields(ITable ftrCls, string[] fieldNames, esriUtil.rasterUtil.localType[] stats, string qWhere="", string prefix="")
        {
            int[] fldIndex = new int[fieldNames.Length];
            int[] updateFldsIndex =  new int[stats.Length];
            string[] updateNames = new string[stats.Length];
            for (int i = 0; i < fieldNames.Length; i++)
            {
                fldIndex[i]=ftrCls.FindField(fieldNames[i]);
            }
            for (int i = 0; i < stats.Length; i++)
            {
                string nm = stats[i].ToString();
                if(prefix!="" && prefix!=null) nm = prefix+"_"+nm;
                updateNames[i] = geoUtil.createField(ftrCls,nm,esriFieldType.esriFieldTypeDouble,false);
                updateFldsIndex[i] = ftrCls.FindField(updateNames[i]);
            }
            bool catStat = false;
            if(stats.Contains(rasterUtil.localType.ASM)||stats.Contains(rasterUtil.localType.ENTROPY)||stats.Contains(rasterUtil.localType.UNIQUE)||stats.Contains(rasterUtil.localType.MEDIAN)||stats.Contains(rasterUtil.localType.MODE)) catStat = true;
            //Console.WriteLine("Updating Categories = " + catStat.ToString());
            IQueryFilter qf = new QueryFilterClass();
            if (!String.IsNullOrEmpty(qWhere)) qf.WhereClause = qWhere;
            //qf.SubFields = String.Join(",", fieldNames)+","+String.Join(",",updateNames);
            ICursor uCur = ftrCls.Update(qf, true);
            IRow ftr = uCur.NextRow();
            while (ftr != null)
            {
                double[] vlArr = new double[10];//cnt, min, max, sum, sum2, minfield, maxfield, subtract, multiply, divide
                Dictionary<string, int> dic = new Dictionary<string,int>();
                vlArr[1]=double.MaxValue;
                vlArr[2]=double.MinValue;
                for (int i = 0; i < fldIndex.Length; i++)
                {
                    object vlObj = ftr.get_Value(fldIndex[i]);
                    if(vlObj!=null)
                    {
                        double vl = System.Convert.ToDouble(vlObj);
                        vlArr[0] = vlArr[0] + 1;
                        if (vl < vlArr[1])
                        {
                            vlArr[1] = vl;
                            vlArr[5]=i;
                        }
                        if (vl > vlArr[2])
                        {
                            vlArr[2] = vl;
                            vlArr[6] = i;
                        }
                        vlArr[3] = vlArr[3] + vl;
                        vlArr[4] = vlArr[4] + (vl * vl);
                        vlArr[7] = vlArr[7] - vl;
                        vlArr[8] = vlArr[8] * vl;
                        vlArr[9] = vlArr[9] / vl;
                        if(catStat)
                        {
                            int cntVl;
                            string vlStr = vl.ToString();
                            if(dic.TryGetValue(vlStr,out cntVl))
                            {
                                dic[vlStr] = cntVl+1;
                            }
                            else
                            {
                                dic.Add(vlStr,1);
                            }
                        }
                    }
                }
                for (int i = 0; i < stats.Length; i++)
                {
                    rasterUtil.localType st = stats[i];
                    double sVl = 0;
                    switch (st)
                    {
                        case rasterUtil.localType.MAX:
                            sVl = vlArr[2];
                         break;
                        case rasterUtil.localType.MIN:
                            sVl = vlArr[1];
                         break;
                        case rasterUtil.localType.MAXBAND:
                            sVl = vlArr[6];
                         break;
                        case rasterUtil.localType.MINBAND:
                            sVl = vlArr[5];
                         break;
                        case rasterUtil.localType.SUM:
                            sVl = vlArr[3];
                         break;
                        case rasterUtil.localType.MULTIPLY:
                            sVl = vlArr[8];
                         break;
                        case rasterUtil.localType.DIVIDE:
                            sVl = vlArr[9];
                         break;
                        case rasterUtil.localType.SUBTRACT:
                            sVl = vlArr[7];
                         break;
                        case rasterUtil.localType.MEAN:
                            sVl = vlArr[3]/vlArr[0];
                         break;
//.........这里部分代码省略.........
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:101,代码来源:featureUtil.cs

示例10: selectStrataFeaturesToSample

        public void selectStrataFeaturesToSample(ITable inputTable, string strataModelPath, string strataFieldName = "Cluster", double proportionOfMean = 0.1, double alpha = 0.05, bool weightsEqual = false)
        {
            IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)inputTable;
            if (!objInfo2.CanBypassEditSession())
            {
                System.Windows.Forms.MessageBox.Show("Input Table participates in a composite relationship. Please export this table as a new table and try again!");
                return;
            }
            esriUtil.Statistics.dataPrepStrata dpC = new Statistics.dataPrepStrata();
            dpC.buildModel(strataModelPath);
            List<string> labels = dpC.Labels;
            HashSet<string> unqVls = geoUtil.getUniqueValues(inputTable, strataFieldName);
            System.Random rd = new Random();
            int[] samplesPerCluster = esriUtil.Statistics.dataPrepSampleSize.sampleSizeMaxCluster(strataModelPath, proportionOfMean, alpha);
            double[] propPerCluster = esriUtil.Statistics.dataPrepSampleSize.clusterProportions(strataModelPath);
            double[] weightsPerCluster = new double[propPerCluster.Length];
            double sSamp = System.Convert.ToDouble(samplesPerCluster.Sum());
            for (int i = 0; i < weightsPerCluster.Length; i++)
            {
                weightsPerCluster[i] = propPerCluster[i] / (samplesPerCluster[i] / sSamp);
            }
            if (weightsEqual)
            {
                double minProp = weightsPerCluster.Min();
                for (int i = 0; i < samplesPerCluster.Length; i++)
                {
                    samplesPerCluster[i] = System.Convert.ToInt32(samplesPerCluster[i] * (weightsPerCluster[i] / minProp));
                    weightsPerCluster[i] = 1;
                }
            }
            int[] tsPerCluster = new int[propPerCluster.Length];
            double[] randomRatioPerClust = new double[propPerCluster.Length];
            if (samplesPerCluster.Length != unqVls.Count)
            {
                System.Windows.Forms.MessageBox.Show("Unique Values in cluster field do not match the number of cluster models!");
                return;
            }
            string sampleFldName = geoUtil.createField(inputTable, "sample", esriFieldType.esriFieldTypeSmallInteger, false);
            string weightFldName = geoUtil.createField(inputTable, "weight", esriFieldType.esriFieldTypeDouble, false);
            IQueryFilter qf0 = new QueryFilterClass();
            qf0.SubFields = strataFieldName;
            string h = "";
            IField fld = inputTable.Fields.get_Field(inputTable.FindField(strataFieldName));
            if (fld.Type == esriFieldType.esriFieldTypeString) h = "'";
            for (int i = 0; i < samplesPerCluster.Length; i++)
            {

                qf0.WhereClause = strataFieldName + " = " + h + labels[i] + h;
                int tCnt = inputTable.RowCount(qf0);
                tsPerCluster[i] = tCnt;
                randomRatioPerClust[i] = System.Convert.ToDouble(samplesPerCluster[i]) / tCnt;
            }
            IQueryFilter qf = new QueryFilterClass();
            qf.SubFields = strataFieldName + "," + sampleFldName + "," + weightFldName;
            IWorkspace wks = ((IDataset)inputTable).Workspace;
            IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
            if (wksE.IsBeingEdited())
            {
                wksE.StopEditing(true);
            }
            try
            {
                ICursor cur = inputTable.Update(qf, false);
                int sIndex = cur.FindField(sampleFldName);
                int cIndex = cur.FindField(strataFieldName);
                int wIndex = cur.FindField(weightFldName);
                IRow rw = cur.NextRow();
                while (rw != null)
                {
                    string clustStr = rw.get_Value(cIndex).ToString();
                    int clust = labels.IndexOf(clustStr);
                    double w = weightsPerCluster[clust];
                    double rNum = rd.NextDouble();
                    int ss = 0;
                    double r = randomRatioPerClust[clust];
                    if (rNum < r)
                    {
                        ss = 1;
                    }
                    rw.set_Value(sIndex, ss);
                    rw.set_Value(wIndex, w);
                    cur.UpdateRow(rw);
                    rw = cur.NextRow();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:91,代码来源:featureUtil.cs

示例11: selectRandomFeaturesToSample

 public void selectRandomFeaturesToSample(ITable inputTable, int totalSamples)
 {
     IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)inputTable;
     if (!objInfo2.CanBypassEditSession())
     {
         System.Windows.Forms.MessageBox.Show("Input Table participates in a composite relationship. Please export this table as a new table and try again!");
         return;
     }
     System.Random rd = new Random();
     double tRec = inputTable.RowCount(null);
     double gR = totalSamples / System.Convert.ToDouble(tRec);
     string sampleFldName = geoUtil.createField(inputTable, "sample", esriFieldType.esriFieldTypeSmallInteger, false);
     string weightFldName = geoUtil.createField(inputTable, "weight", esriFieldType.esriFieldTypeDouble, false);
     IWorkspace wks = ((IDataset)inputTable).Workspace;
     IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
     if (wksE.IsBeingEdited())
     {
         wksE.StopEditing(true);
     }
     try
     {
         ICursor cur = inputTable.Update(null, false);
         int sIndex = cur.FindField(sampleFldName);
         int wIndex = cur.FindField(weightFldName);
         IRow rw = cur.NextRow();
         while (rw != null)
         {
             double rNum = rd.NextDouble();
             int ss = 0;
             if (rNum <= gR)
             {
                 ss = 1;
             }
             rw.set_Value(sIndex, ss);
             rw.set_Value(wIndex, 1);
             cur.UpdateRow(rw);
             rw = cur.NextRow();
         }
         System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(e.ToString());
     }
 }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:45,代码来源:featureUtil.cs

示例12: selectPcaFeaturesToSample

 public void selectPcaFeaturesToSample(ITable inputTable, string pcaModelPath, double proportionOfMean, double alpha)
 {
     IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)inputTable;
     if (!objInfo2.CanBypassEditSession())
     {
         System.Windows.Forms.MessageBox.Show("Input Table participates in a composite relationship. Please export this table as a new table and try again!");
         return;
     }
     Statistics.dataPrepPrincipleComponents pca = new Statistics.dataPrepPrincipleComponents();
     pca.buildModel(pcaModelPath);
     System.Random rd = new Random();
     double tSamples = System.Convert.ToDouble(esriUtil.Statistics.dataPrepSampleSize.sampleSizeMaxMean(pca.MeanVector, pca.StdVector, proportionOfMean, alpha));
     int tRecords = inputTable.RowCount(null);
     double gR = tSamples / tRecords;
     string sampleFldName = geoUtil.createField(inputTable, "sample", esriFieldType.esriFieldTypeSmallInteger, false);
     IQueryFilter qf0 = new QueryFilterClass();
     IQueryFilter qf = new QueryFilterClass();
     qf.SubFields = sampleFldName;
     IWorkspace wks = ((IDataset)inputTable).Workspace;
     IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
     if (wksE.IsBeingEdited())
     {
         wksE.StopEditing(true);
     }
     try
     {
         ICursor cur = inputTable.Update(qf, false);
         int sIndex = cur.FindField(sampleFldName);
         IRow rw = cur.NextRow();
         while (rw != null)
         {
             double rNum = rd.NextDouble();
             int ss = 0;
             double r = gR;
             if (rNum < r)
             {
                 ss = 1;
             }
             rw.set_Value(sIndex, ss);
             cur.UpdateRow(rw);
             rw = cur.NextRow();
         }
         System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(e.ToString());
     }
 }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:49,代码来源:featureUtil.cs

示例13: selectKSFeaturesToSample

        public void selectKSFeaturesToSample(ITable sampledTable,ITable samplesToDrawFromTable, string ksModelPath, string groupFieldName = "")
        {
            IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)sampledTable;
            if (!objInfo2.CanBypassEditSession())
            {
                System.Windows.Forms.MessageBox.Show("Sampled Table participates in a composite relationship. Please export this table as a new table and try again!");
                return;
            }
            if (samplesToDrawFromTable != null)
            {
                objInfo2 = (IObjectClassInfo2)samplesToDrawFromTable;
                if (!objInfo2.CanBypassEditSession())
                {
                    System.Windows.Forms.MessageBox.Show("Samples to draw from table participates in a composite relationship. Please export this table as a new table and try again!");
                    return;
                }
            }
            if (groupFieldName == null) groupFieldName = "";
            try
            {
                esriUtil.Statistics.dataPrepCompareSamples dpComp = new Statistics.dataPrepCompareSamples(ksModelPath);
                Dictionary<string,object[]> sampledBinPropDic = calcBinValues(dpComp, sampledTable); //key = stratfield_bin, values = [0] ratios {10} for random selection [1] counts {10} from sample
                //bins and ratios calculated next use ratios to select from class and bin

                IWorkspace wks = ((IDataset)sampledTable).Workspace;
                IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
                if (wksE.IsBeingEdited())
                {
                    wksE.StopEditing(true);
                }

                System.Random rd = new Random();
                string sampleFldName = geoUtil.createField(sampledTable, "sample", esriFieldType.esriFieldTypeSmallInteger, false);
                List<string> labels = dpComp.Labels.ToList();

                ICursor cur = sampledTable.Update(null, false);
                int sIndex = cur.FindField(sampleFldName);
                int cIndex = cur.FindField(groupFieldName);
                int bIndex = cur.FindField("BIN");
                IRow rw = cur.NextRow();
                while (rw != null)
                {
                    string clustStr = labels[0];
                    if (cIndex > -1)
                    {
                        clustStr = rw.get_Value(cIndex).ToString();
                    }
                    int b = System.Convert.ToInt32(rw.get_Value(bIndex));
                    double rNum = rd.NextDouble();
                    double r = ((double[])sampledBinPropDic[clustStr][0])[b];

                    int ss = 0;
                    if (rNum <= r)
                    {
                        ss = 1;
                    }
                    rw.set_Value(sIndex, ss);
                    cur.UpdateRow(rw);
                    rw = cur.NextRow();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
                if (samplesToDrawFromTable != null)
                {
                    appendSamples(sampledTable, samplesToDrawFromTable, sampledBinPropDic,dpComp);
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:71,代码来源:featureUtil.cs

示例14: selectEqualFeaturesToSample

        public void selectEqualFeaturesToSample(ITable inputTable, string mapField, int SamplesPerClass, bool weightsEqual=false )
        {
            IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)inputTable;
            if (!objInfo2.CanBypassEditSession())
            {
                System.Windows.Forms.MessageBox.Show("Input Table participates in a composite relationship. Please export this table as a new table and try again!");
                return;
            }
            HashSet<string> unqVls = geoUtil.getUniqueValues(inputTable, mapField);
            System.Random rd = new Random();
            int samplesPerClass = SamplesPerClass;
            double tSamples = System.Convert.ToDouble(samplesPerClass * unqVls.Count);
            double gR = samplesPerClass / tSamples;
            double[] weightsPerClass = new double[unqVls.Count];
            int[] tsPerClass = new int[unqVls.Count];
            double[] ratioPerClass = new double[unqVls.Count];
            string sampleFldName = geoUtil.createField(inputTable, "sample", esriFieldType.esriFieldTypeSmallInteger, false);
            string weightFldName = geoUtil.createField(inputTable, "weight", esriFieldType.esriFieldTypeDouble, false);
            IQueryFilter qf0 = new QueryFilterClass();
            qf0.SubFields = mapField;
            string h = "";
            IField fld = inputTable.Fields.get_Field(inputTable.FindField(mapField));
            if (fld.Type == esriFieldType.esriFieldTypeString) h = "'";
            for (int i = 0; i < unqVls.Count; i++)
            {

                qf0.WhereClause = mapField + " = " + h + unqVls.ElementAt(i) + h;
                int tCnt = inputTable.RowCount(qf0);
                tsPerClass[i] = tCnt;
                ratioPerClass[i] = System.Convert.ToDouble(samplesPerClass) / tCnt;
            }
            double tsSamp = System.Convert.ToDouble(tsPerClass.Sum());
            for (int i = 0; i < weightsPerClass.Length; i++)
            {
                weightsPerClass[i] = (tsPerClass[i]/tsSamp) / (gR);
            }
            if (weightsEqual)
            {
                double minW = weightsPerClass.Min();
                for (int i = 0; i < weightsPerClass.Length; i++)
                {
                    double aSamp = samplesPerClass*(weightsPerClass[i]/minW);
                    ratioPerClass[i] = aSamp / tsPerClass[i];
                    weightsPerClass[i] = 1;
                }

            }
            IQueryFilter qf = new QueryFilterClass();
            qf.SubFields = mapField + "," + sampleFldName + "," + weightFldName;
            IWorkspace wks = ((IDataset)inputTable).Workspace;
            IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
            if (wksE.IsBeingEdited())
            {
                wksE.StopEditing(true);
            }
            try
            {
                ICursor cur = inputTable.Update(qf, false);
                int sIndex = cur.FindField(sampleFldName);
                int cIndex = cur.FindField(mapField);
                int wIndex = cur.FindField(weightFldName);
                IRow rw = cur.NextRow();
                List<string> unqLst = unqVls.ToList();
                while (rw != null)
                {
                    string classStr = rw.get_Value(cIndex).ToString();
                    int cls = unqLst.IndexOf(classStr);
                    double w = weightsPerClass[cls];
                    double rNum = rd.NextDouble();
                    int ss = 0;
                    double r = ratioPerClass[cls];
                    if (rNum < r)
                    {
                        ss = 1;
                    }
                    rw.set_Value(sIndex, ss);
                    rw.set_Value(wIndex, w);
                    cur.UpdateRow(rw);
                    rw = cur.NextRow();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:87,代码来源:featureUtil.cs

示例15: UpdatePointXYFromGeometry

        private bool UpdatePointXYFromGeometry(ITable PointTable, IQueryFilter QueryFilter, bool Unversioned, double UpdateIfMoreThanTolerance, out int ChangedPointCount)
        {
            IProgressDialogFactory pProgressorDialogFact = new ProgressDialogFactoryClass();
              ITrackCancel pTrackCancel = new CancelTrackerClass();
              IStepProgressor pStepProgressor = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd);
              IProgressDialog2 pProgressorDialog = (IProgressDialog2)pStepProgressor;
              try
              {
            pStepProgressor.MinRange = 0;
            pStepProgressor.MaxRange = PointTable.RowCount(null);
            pStepProgressor.StepValue = 1;
            pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
            bool bCont = true;

            IRow pPointFeat = null;
            ICursor pPtCurs = null;
            ChangedPointCount = 0;
            if (Unversioned)
            {
              ITableWrite pTableWr = (ITableWrite)PointTable;//used for unversioned table
              pPtCurs = pTableWr.UpdateRows(QueryFilter, false);
            }
            else
              pPtCurs = PointTable.Update(QueryFilter, false);

            pPointFeat = pPtCurs.NextRow();

            int iPointIdx_X = pPtCurs.Fields.FindField("X");
            int iPointIdx_Y = pPtCurs.Fields.FindField("Y");

            pProgressorDialog.ShowDialog();
            pStepProgressor.Message = "Updating point data...";

            while (pPointFeat != null)
            {//loop through all of the fabric points, and if any of the point id values are in the deleted set,
              //then remove the control name from the point's NAME field

              bCont = pTrackCancel.Continue();
              if (!bCont)
            break;

              IFeature pFeat = (IFeature)pPointFeat;
              IPoint pPtSource = (IPoint)pFeat.ShapeCopy;

              if (pPtSource == null)
              {
            Marshal.ReleaseComObject(pPointFeat); //garbage collection
            pPointFeat = pPtCurs.NextRow();
            continue;
              }

              if (pPtSource.IsEmpty)
              {
            Marshal.ReleaseComObject(pPointFeat); //garbage collection
            pPointFeat = pPtCurs.NextRow();
            continue;
              }
              IPoint pPtTarget = new ESRI.ArcGIS.Geometry.PointClass();
              pPtTarget.X = Convert.ToDouble(pPointFeat.get_Value(iPointIdx_X));
              pPtTarget.Y = Convert.ToDouble(pPointFeat.get_Value(iPointIdx_Y));

              ILine pLine = new ESRI.ArcGIS.Geometry.LineClass();
              pLine.PutCoords(pPtSource, pPtTarget);

              if (pLine.Length > UpdateIfMoreThanTolerance)
              {
            pPointFeat.set_Value(iPointIdx_X, pPtSource.X);
            pPointFeat.set_Value(iPointIdx_Y, pPtSource.Y);

            //if (Unversioned)
              pPtCurs.UpdateRow(pPointFeat);
            //else
            //  pPointFeat.Store();
            ChangedPointCount++;
            string sCnt = ChangedPointCount.ToString() + " of " + pStepProgressor.MaxRange.ToString();
            pStepProgressor.Message = "Updating point data..." + sCnt;
              }

              Marshal.ReleaseComObject(pPointFeat); //garbage collection
              pPointFeat = pPtCurs.NextRow();

              if (pStepProgressor.Position < pStepProgressor.MaxRange)
            pStepProgressor.Step();

            }
            Marshal.ReleaseComObject(pPtCurs); //garbage collection
            return bCont;

              }
              catch (COMException ex)
              {
            MessageBox.Show("Problem updating point XY from shape: " + Convert.ToString(ex.ErrorCode));
            ChangedPointCount = 0;
            return false;
              }
              finally
              {
            pStepProgressor = null;
            if (!(pProgressorDialog == null))
              pProgressorDialog.HideDialog();
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:101,代码来源:CoordinateInverse.cs


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