示例#1
0
文件: EditsDAO.cs 项目: EAWCS1/SUITT
        // join edit with working?
        public IFeatureCursor getDeletes(string key)
        {
            // Used in commit action
            IFeatureClass fc = null;
            try
            {
                fc = this.transactionDB.OpenFeatureClass("E_" + key);
            }
            catch(Exception e)
            {
                MessageBox.Show("Edit Feature Class For E_" + key + " Not Found in Transaction",
                    "EXCEPTION", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                throw new HandledException(e);
            }

            IQueryFilter filter = new QueryFilterClass();
            filter.WhereClause = EDIT_STATE + " = '"+DEL+"'";

            IFeatureCursor r = null;
            try
            {
                r = fc.Search(filter, false);
            }
            finally
            {
                Utils.Release(filter);
            }
            return r;
        }
        public void AddGlossary(string SqlWhereClause)
        {
            int idFld = m_GlossaryTable.FindField("Glossary_ID");
            int trmFld = m_GlossaryTable.FindField("Term");
            int defFld = m_GlossaryTable.FindField("Definition");
            int dsFld = m_GlossaryTable.FindField("DefinitionSourceID");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            ICursor theCursor = m_GlossaryTable.Search(QF, false);
            IRow theRow = theCursor.NextRow();

            while (theRow != null)
            {
                Glossary anGlossary = new Glossary();
                anGlossary.Glossary_ID = theRow.get_Value(idFld).ToString();
                anGlossary.Term = theRow.get_Value(trmFld).ToString();
                anGlossary.Definition = theRow.get_Value(trmFld).ToString();
                anGlossary.DefinitionSourceID = theRow.get_Value(dsFld).ToString();
                anGlossary.RequiresUpdate = true;

                m_GlossaryDictionary.Add(anGlossary.Glossary_ID, anGlossary);

                theRow = theCursor.NextRow();
            }
        }
        protected override void Execute()
        {
            var featureClass = FeatureWorkspace.OpenFeatureClass(Args.FeatureClass.Trim());

            var errors = ValidateFields(featureClass, Args.ReturnValues);

            if (errors.Any())
            {
                ErrorMessage = "{0} does not contain an attribute {1}. Check your spelling."
                    .With(Args.FeatureClass, string.Join(" or ", errors));

                return;
            }

            var filter = new QueryFilterClass
                {
                    WhereClause = Args.WhereClause
                };

            var fCursor = featureClass.Search(filter, true);

            var fields = featureClass.Fields;

            var container = AddResultsToContainer(fCursor, fields, Args.ReturnValues, Args.SpatialRefefence);

            Result = container;
        }
示例#4
0
 public static void AddFeaturesToSelection(IFeatureLayer featureLayer, int[] oids, string whereClause)
 {
     if (featureLayer != null && oids != null)
     {
         try
         {
             IFeatureClass featureClass = featureLayer.FeatureClass;
             IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
             if (featureSelection != null && featureClass != null && oids.Length > 0)
             {
                 IWorkspace workspace = DisplayMap.GetWorkspaceFromClass(featureClass);
                 if (workspace != null)
                 {
                     IQueryFilter2 queryFilter = new QueryFilterClass();
                     queryFilter.WhereClause = featureClass.OIDFieldName + " < 0";
                     ISelectionSet selectionSet = featureClass.Select(queryFilter, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, workspace);
                     selectionSet.AddList(oids.Length, ref oids[0]);
                     queryFilter = new QueryFilterClass();
                     if (string.IsNullOrEmpty(whereClause) == false)
                     {
                         queryFilter.WhereClause = whereClause;
                         selectionSet = selectionSet.Select(queryFilter, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, workspace);
                     }
                     featureSelection.SelectionSet = selectionSet;
                 }
             }
         }
         catch { }
     }
 }
        // The AddDatasources method adds Datasource structures to the collection, based on a query defined by input parameters.
        public void AddDataSources(string SqlWhereClause)
        {
            // Get m_identifier indexes outside the loop for better performance
            int idFld = m_DataSourcesTable.FindField("DataSources_ID");
            int sourceFld = m_DataSourcesTable.FindField("Source");
            int notesFld = m_DataSourcesTable.FindField("Notes");

            // Setup the query
            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            // Perform the search, and grab the first returned row
            ICursor theCursor = m_DataSourcesTable.Search(QF,false);
            IRow theRow = theCursor.NextRow();

            // Loop through the returned rows until you're all done.
            while (theRow != null)
            {
                // Populate a DataSource Structure
                Datasource aDataSource = new Datasource();
                aDataSource.DataSources_ID = theRow.get_Value(idFld).ToString();
                aDataSource.Source = theRow.get_Value(sourceFld).ToString();
                aDataSource.Notes = theRow.get_Value(notesFld).ToString();
                aDataSource.RequiresUpdate = true;

                // Add the Structure to the dictionary
                m_dataSourceDictionary.Add(aDataSource.DataSources_ID, aDataSource);

                // Increment to the next returned DataSource
                theRow = theCursor.NextRow();
            }
        }
        public virtual IQueryFilter getQueryFilter(string[] values)
        {
            IQueryFilter qf = new QueryFilterClass();

            for (int ii = 0; ii < values.Length; ii++)
            {
                if (fields.Length > 1)
                {
                    string[] curr_values = values[ii].Split(';');

                    qf.WhereClause += " (";

                    for (int j = 0; j < fields.Length; j++)
                    {
                        qf.WhereClause = qf.WhereClause + fields[j] + "='" + curr_values[j].Trim() +"' ";

                        if (j < fields.Length - 1)
                        {
                            qf.WhereClause += " AND ";
                        }
                    }

                    qf.WhereClause += ") ";
                }
                else
                {
                    qf.WhereClause = qf.WhereClause + " " + fields[0] + "='" + values[ii] + "'";// +((ii <= (values.Length - 1)) ? "" : "OR ");
                }

                if (ii < (values.Length - 1))
                    qf.WhereClause += " OR ";
            }
            return qf;
        }
示例#7
0
 private string[] GetUnByDataStatistics(ILayer layer, String strField)
 {
     IFeatureLayer featureLayer = layer as IFeatureLayer;
     ILayerFields pLayerFields = featureLayer as ILayerFields;
     int nCount=pLayerFields.FieldCount;
     IQueryFilter queryFilter = new QueryFilterClass();
     queryFilter.SubFields = strField;
     IFeatureCursor featureCursor = featureLayer.FeatureClass.Search(queryFilter, true);
     IDataStatistics dataStatistics = new DataStatisticsClass();
     dataStatistics.Field = strField;
     dataStatistics.Cursor = featureCursor as ICursor;
     System.Collections.IEnumerator pEnumvar = dataStatistics.UniqueValues;
     int number = dataStatistics.UniqueValueCount;
     pEnumvar.Reset();
     object obj = null;
     pEnumvar.MoveNext();
     int i = 0;
     string[] str = new string[nCount];
     while (pEnumvar.MoveNext())
     {
         obj = pEnumvar.Current;
         str[i++] = obj.ToString();
     }
     return str;
 }
示例#8
0
 public void CheckIFeatureSelection()
 {
     IQueryFilter qf = new QueryFilterClass();
     qf.WhereClause = "";
     ISelectionSet ss = fc.Select(qf, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, ws);
     Assert.Greater(ss.Count, 0);
 }
        public void AddDataSourcePolys(string SqlWhereClause)
        {
            int idFld = m_DataSourcePolysFC.FindField("DataSourcePolys_ID");
            int notesFld = m_DataSourcePolysFC.FindField("Notes");
            int dsFld = m_DataSourcePolysFC.FindField("DataSourceID");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            IFeatureCursor theCursor = m_DataSourcePolysFC.Search(QF, false);
            IFeature theFeature = theCursor.NextFeature();

            while (theFeature != null)
            {
                DataSourcePoly anDataSourcePoly = new DataSourcePoly();
                anDataSourcePoly.DataSourcePolys_ID = theFeature.get_Value(idFld).ToString();
                anDataSourcePoly.Notes = theFeature.get_Value(notesFld).ToString();
                anDataSourcePoly.DataSourceID = theFeature.get_Value(dsFld).ToString();
                anDataSourcePoly.Shape = (IPolygon)theFeature.Shape;
                anDataSourcePoly.RequiresUpdate = true;

                m_DataSourcePolysDictionary.Add(anDataSourcePoly.DataSourcePolys_ID, anDataSourcePoly);

                theFeature = theCursor.NextFeature();
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(theCursor);
        }
示例#10
0
        public void AddOtherPolys(string SqlWhereClause)
        {
            int idFld = m_OtherPolysFC.FindField("OtherPolys_ID");
            int unitFld = m_OtherPolysFC.FindField("MapUnit");
            int idConfFld = m_OtherPolysFC.FindField("IdentityConfidence");
            int lblFld = m_OtherPolysFC.FindField("Label");
            int notesFld = m_OtherPolysFC.FindField("Notes");
            int dsFld = m_OtherPolysFC.FindField("DataSourceID");
            int symFld = m_OtherPolysFC.FindField("Symbol");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            IFeatureCursor theCursor = m_OtherPolysFC.Search(QF, false);
            IFeature theFeature = theCursor.NextFeature();

            while (theFeature != null)
            {
                OtherPoly anOtherPoly = new OtherPoly();
                anOtherPoly.OtherPolys_ID = theFeature.get_Value(idFld).ToString();
                anOtherPoly.MapUnit = theFeature.get_Value(unitFld).ToString();
                anOtherPoly.IdentityConfidence = theFeature.get_Value(idConfFld).ToString();
                anOtherPoly.Label = theFeature.get_Value(lblFld).ToString();
                anOtherPoly.Notes = theFeature.get_Value(notesFld).ToString();
                anOtherPoly.DataSourceID = theFeature.get_Value(dsFld).ToString();
                anOtherPoly.Symbol = theFeature.get_Value(symFld).ToString();
                anOtherPoly.Shape = (IPolygon)theFeature.Shape;
                anOtherPoly.RequiresUpdate = true;

                m_OtherPolysDictionary.Add(anOtherPoly.OtherPolys_ID, anOtherPoly);

                theFeature = theCursor.NextFeature();
            }
        }
示例#11
0
        public void AddNotes(string SqlWhereClause = null)
        {
            int idFld = m_NotesTable.FindField("Notes_ID");
            int ownerFld = m_NotesTable.FindField("OwnerID");
            int typeFld = m_NotesTable.FindField("Type");
            int notesFld = m_NotesTable.FindField("Notes");
            int dsFld = m_NotesTable.FindField("DataSourceID");

            ICursor theCursor;

            if (SqlWhereClause == null) { theCursor = m_NotesTable.Search(null, false); }
            else
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = SqlWhereClause;
                theCursor = m_NotesTable.Search(QF, false);
            }

            IRow theRow = theCursor.NextRow();

            while (theRow != null)
            {
                Note anNote = new Note();
                anNote.Notes_ID = theRow.get_Value(idFld).ToString();
                anNote.OwnerID = theRow.get_Value(ownerFld).ToString();
                anNote.Notes = theRow.get_Value(notesFld).ToString();
                anNote.Type = theRow.get_Value(typeFld).ToString();
                anNote.DataSourceID = theRow.get_Value(dsFld).ToString();
                anNote.RequiresUpdate = true;

                m_NotesDictionary.Add(anNote.Notes_ID, anNote);

                theRow = theCursor.NextRow();
            }
        }
示例#12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (axMapControl1.LayerCount > LayerCount)
            {
                axMapControl1.DeleteLayer(axMapControl1.LayerCount);
            }
            //if (textBox1.Text != "")
            //{
                List<IFeature> pFList = new List<IFeature>();
                //QI��FeatureSelection
                IFeatureSelection pFeatureSelection = pFeatureLayer as IFeatureSelection;
                //����������
                IQueryFilter pQueryFilter = new QueryFilterClass();
                //���ù���������IJ�ѯ����
                pQueryFilter.WhereClause = label4.Text + " like '%" + textBox1.Text + "%'";

                IFeatureCursor pFeatureCursor = pFeatureLayer.Search(pQueryFilter, false);
                IFeature pFeature = pFeatureCursor.NextFeature();
                while (pFeature != null)
                {
                    //��ȡҪ�ض���
                    pFList.Add(pFeature);
                    pFeature = pFeatureCursor.NextFeature();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);

                if (pFList.Count > 0)
                {
                    dataGridView1.RowCount = pFList.Count + 1;
                    //���ñ߽���
                    dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Sunken;
                    //��������
                    dataGridView1.ColumnCount = pFList[0].Fields.FieldCount;
                    //������һ��Ҫ�ص��ֶ����ڸ���ͷ��ֵ���ֶε����ƣ�
                    for (int m = 0; m < pFList[0].Fields.FieldCount; m++)
                    {
                        dataGridView1.Columns[m].HeaderText = pFList[0].Fields.get_Field(m).AliasName;
                        if (pFList[0].Fields.get_Field(m).AliasName == label4.Text)
                        {
                            DisplayFiledNum = m;
                        }
                    }
                    //����Ҫ��
                    for (int i = 0; i < pFList.Count; i++)
                    {
                        pFeature = pFList[i];
                        for (int j = 0; j < pFeature.Fields.FieldCount; j++)
                        {
                            //����ֶ�ֵ
                            dataGridView1[j, i].Value = pFeature.get_Value(j).ToString();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("û���κ�����");
                }
            //}
        }
示例#13
0
        public override bool Check(ref List<Error> checkResult)
        {
            IQueryFilter pQueryFilter = new QueryFilterClass();
            pQueryFilter.WhereClause = m_structPara.strWhereClause;
            //����������ѯ
            IFeatureCursor ipFeatCursor = pSrcFeatClass.Search(pQueryFilter, true);
            IFeature ipFeature = ipFeatCursor.NextFeature();
            IGeometryCollection pGeometryCollection = new GeometryBagClass();
            ///��ȡ�����������geometry
            while (ipFeature != null)
            {
                IGeometry ipGeometry = ipFeature.Shape;
                if (ipGeometry == null)
                {
                    ipFeature = ipFeatCursor.NextFeature();
                    continue;
                }
                object Missing = Type.Missing;
                pGeometryCollection.AddGeometry(ipGeometry, ref Missing, ref Missing);

                ipFeature = ipFeatCursor.NextFeature();
            }

            ISpatialIndex pSpatialIndex = (ISpatialIndex)pGeometryCollection;
            pSpatialIndex.AllowIndexing = true;
            pSpatialIndex.Invalidate();

            ///��������ͼ������ص��Ŀռ��ѯ
            ISpatialFilter pSpatialFilter = new SpatialFilterClass();
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelOverlaps;
            ///�����GeometryCollection����spatialfilter
            pSpatialFilter.Geometry = (IGeometry)pGeometryCollection;
            string Fields = "OBJECTID,Shape";
            pSpatialFilter.SubFields = Fields;

            IFeatureCursor ipResultFtCur = pRelFeatClass.Search(pSpatialFilter, true);

            //��������
            List<Error> pRuleResult = new List<Error>();
            AddResult(ref pRuleResult, ipResultFtCur);

            checkResult = pRuleResult;

            if (ipResultFtCur != null)
            {
                Marshal.ReleaseComObject(ipResultFtCur);
                ipResultFtCur = null;
            } if (pSrcFeatClass != null)
            {
                Marshal.ReleaseComObject(pSrcFeatClass);
                pSrcFeatClass = null;
            }
            if (pRelFeatClass != null)
            {
                Marshal.ReleaseComObject(pRelFeatClass);
                pRelFeatClass = null;
            }
            return true;
        }
示例#14
0
        public override bool Check(ref List<Error> checkResult)
        {
            //����Ӧ��featureclass
            ITable ipTable=null;
            ICursor ipCursor=null;
            try
            {
                IFeatureWorkspace ipFtWS;
                ipFtWS = (IFeatureWorkspace) m_QueryWorkspace;
                ipTable = ipFtWS.OpenTable(m_layerName);

                //ִ�в�ѯ����
                IQueryFilter pFilter = new QueryFilterClass();

                pFilter.WhereClause = ConstructClause();
                pFilter.SubFields = "OBJECTID,BSM";

                //���Ų�ѯ
                try
                {
                    ipCursor = ipTable.Search(pFilter, false);
                    if (ipCursor == null)
                    {
                        return false;
                    }
                }
                catch (Exception ex)
                {

                    SendMessage(enumMessageType.RuleError, "��ǰ�������ݿ��ͼ��" + m_layerName + "�У�SQL���" + pFilter.WhereClause + "�޷�ִ��!");
                    return false;
                }
                //����Ϊ�գ�����ʽ����ȷ
                if (ipCursor == null)
                {
                    return false;
                }
                checkResult = GetResult(ipCursor);

                return checkResult!=null;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (ipCursor != null)
                {
                    Marshal.ReleaseComObject(ipCursor);
                    ipCursor = null;
                }
                if (ipTable != null)
                {
                    Marshal.ReleaseComObject(ipTable);
                    ipTable = null;
                }
            }
        }
 public static void SelectLayerFeatures(IFeatureLayer fealyr,string whereclause)
 {
     IFeatureSelection feaSelection = fealyr as IFeatureSelection;
     if(feaSelection!=null)
     {
         IQueryFilter queryFilter = new QueryFilterClass();
         queryFilter.WhereClause = whereclause;
         feaSelection.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
         feaSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
     }
 }
示例#16
0
        //添加字段并赋值
        private void AddField()
        {
            //添加温度字段
            string HighTemp = "HighTemperature";
            string LowTemp = "LowTemperature";
            IFeatureLayer lyrProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IFeatureLayer;
            IFeatureClass ProClass = lyrProVince.FeatureClass; ;
            if (ProClass.Fields.FindField(HighTemp) < 0)
            {
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = HighTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);
            }
            if (ProClass.Fields.FindField(LowTemp) < 0)
            {
                IField pField = new FieldClass();
                IFieldEdit pFieldEdit = pField as IFieldEdit;
                pFieldEdit.Name_2 = LowTemp;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                IClass pClass = ProClass as IClass;
                pClass.AddField(pFieldEdit);

            }
            //为字段赋值
            string[] provinces = new string[] { "黑龙江省", "内蒙古自治区", "新疆维吾尔自治区", "吉林省", "甘肃省", "河北省", "北京市", "山西省", "天津市", "陕西省", "宁夏回族自治区", "青海省", "辽宁省", "山东省", "西藏自治区", "河南省", "江苏省", "安徽省", "四川省", "湖北省", "重庆市", "上海市", "浙江省", "湖南省", "江西省", "云南省", "贵州省", "广西壮族自治区", "福建省", "台湾省", "海南省", "广东省", "香港特别行政区", "澳门" };
            TomorrowWeatherInfo weath;

            IFeatureCursor featCursor = null;
            IQueryFilter queryFilter = new QueryFilterClass();
            for (int i = 0; i < provinces.Length; i++)
            {
                string selCity = provinces[i];
                string whereClause = "[NAME] = '" + selCity + "'";
                queryFilter.WhereClause = whereClause;
                featCursor = ProClass.Search(queryFilter, false);
                IFeature pFeature = featCursor.NextFeature();
                string pcity = Utilities.getCity(selCity);
                weath = new TomorrowWeatherInfo(pcity);

                Random random=new Random();//测试用随机数产生器
                if (pFeature != null)
                {
                    pFeature.set_Value(pFeature.Fields.FindField("HighTemperature"), random.Next(20,40));
                    pFeature.set_Value(pFeature.Fields.FindField("LowTemperature"), random.Next(1,20));
                    pFeature.Store();
                }
            }
            IGeoFeatureLayer geoProVince = Utilities.GetLayerByName("省市", axMapControl1.Map) as IGeoFeatureLayer;
            setColor(geoProVince);
        }
        public void AddDescriptionOfMapUnits(string SqlWhereClause = null)
        {
            int idFld = m_DescriptionOfMapUnitsTable.FindField("DescriptionOfMapUnits_ID");
            int unitFld = m_DescriptionOfMapUnitsTable.FindField("MapUnit");
            int nameFld = m_DescriptionOfMapUnitsTable.FindField("Name");
            int flNameFld = m_DescriptionOfMapUnitsTable.FindField("FullName");
            int lblFld = m_DescriptionOfMapUnitsTable.FindField("Label");
            int ageFld = m_DescriptionOfMapUnitsTable.FindField("Age");
            int descFld = m_DescriptionOfMapUnitsTable.FindField("Description");
            int hierFld = m_DescriptionOfMapUnitsTable.FindField("HierarchyKey");
            int styleFld = m_DescriptionOfMapUnitsTable.FindField("ParagraphStyle");
            int rgbFld = m_DescriptionOfMapUnitsTable.FindField("AreaFillRGB");
            int patFld = m_DescriptionOfMapUnitsTable.FindField("AreaFillPatternDescription");
            int dsFld = m_DescriptionOfMapUnitsTable.FindField("DescriptionSourceID");
            int glFld = m_DescriptionOfMapUnitsTable.FindField("GeneralLithologyTerm");
            int glConfFld = m_DescriptionOfMapUnitsTable.FindField("GeneralLithologyConfidence");

            ICursor theCursor;

            if (SqlWhereClause == null) { theCursor = m_DescriptionOfMapUnitsTable.Search(null, false); }
            else
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = SqlWhereClause;
                theCursor = m_DescriptionOfMapUnitsTable.Search(QF, false);
            }

            IRow theRow = theCursor.NextRow();

            while (theRow != null)
            {
                DescriptionOfMapUnit anDescriptionOfMapUnit = new DescriptionOfMapUnit();
                anDescriptionOfMapUnit.DescriptionOfMapUnits_ID = theRow.get_Value(idFld).ToString();
                anDescriptionOfMapUnit.MapUnit = theRow.get_Value(unitFld).ToString();
                anDescriptionOfMapUnit.Name = theRow.get_Value(nameFld).ToString();
                anDescriptionOfMapUnit.FullName = theRow.get_Value(flNameFld).ToString();
                anDescriptionOfMapUnit.Label = theRow.get_Value(lblFld).ToString();
                anDescriptionOfMapUnit.Age = theRow.get_Value(ageFld).ToString();
                anDescriptionOfMapUnit.Description = theRow.get_Value(descFld).ToString();
                anDescriptionOfMapUnit.HierarchyKey = theRow.get_Value(hierFld).ToString();
                anDescriptionOfMapUnit.ParagraphStyle = theRow.get_Value(styleFld).ToString();
                anDescriptionOfMapUnit.AreaFillRGB = theRow.get_Value(rgbFld).ToString();
                anDescriptionOfMapUnit.AreaFillPatternDescription = theRow.get_Value(patFld).ToString();
                anDescriptionOfMapUnit.DescriptionSourceID = theRow.get_Value(dsFld).ToString();
                anDescriptionOfMapUnit.GeneralLithologyTerm = theRow.get_Value(glFld).ToString();
                anDescriptionOfMapUnit.GeneralLithologyConfidence = theRow.get_Value(glConfFld).ToString();
                anDescriptionOfMapUnit.RequiresUpdate = true;

                m_DescriptionOfMapUnitsDictionary.Add(anDescriptionOfMapUnit.DescriptionOfMapUnits_ID, anDescriptionOfMapUnit);

                theRow = theCursor.NextRow();
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     string connStr = cmbCon.Text;
     if (connStr != "" && connStr != null)
     {
         IQueryFilter qf = new QueryFilterClass();
         qf.WhereClause = "CONNECTION = '" + cmbCon.Text + "'";
         msUtil.removeExistingRecords(msUtil.ConnectionsTable, qf);
         cmbCon.Items.Remove(connStr);
         cmbCon.Text = "";
         cmbSrv.Items.Clear();
         cmbSrv.Text = "";
         chbLayers.Items.Clear();
     }
     cmbCon.SelectedItem = cmbCon.Items[0];
 }
示例#19
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            // add Exception handling
            IMap map = ArcMap.Document.FocusMap;
            for (int i = 0; i < map.LayerCount; i++)
            {
                ILayer layer = map.get_Layer(i);
                string[] layerName = layer.Name.Split(new char[] {'.'});

                if (layerName[layerName.Length - 1] == "Cities" && layer.Visible == true)
                {
                    IFeatureLayer citiesLayer = map.get_Layer(i) as IFeatureLayer;
                    IFeatureClass citiesClass = citiesLayer.FeatureClass;

                    // fields indexes start from 0
                    int cityNameIndex = citiesClass.FindField("AREANAME");
                    int stateIndex = citiesClass.FindField("ST");

                    /**
                     * Important class
                     * IQueryFilter
                     *
                     */
                    IQueryFilter queryFilter = new QueryFilterClass();
                    /**
                     * _ - one symbol
                     * % - many symbol
                     *
                     */
                    queryFilter.WhereClause = String.Format("AREANAME LIKE '%{0}%'", searchTextBox.Text.ToUpper());
                    IFeatureCursor resCursor = citiesClass.Search(queryFilter, true);

                    IFeature cityFeature = resCursor.NextFeature();
                    while (cityFeature != null)
                    {
                        MessageBox.Show(String.Format("{0}, {1}", cityFeature.get_Value(cityNameIndex), cityFeature.get_Value(stateIndex)));

                        cityFeature = resCursor.NextFeature();
                    }

                    //
                    Marshal.ReleaseComObject(resCursor);

                    break;
                }
            }
        }
        public void AddOrientationDataPoints(string SqlWhereClause)
        {
            int idFld = m_OrientationDataPointsFC.FindField("OrientationDataPoints_ID");
            int stationFld = m_OrientationDataPointsFC.FindField("StationID");
            int typeFld = m_OrientationDataPointsFC.FindField("Type");
            int idConfFld = m_OrientationDataPointsFC.FindField("IdentityConfidence");
            int lblFld = m_OrientationDataPointsFC.FindField("Label");
            int plotFld = m_OrientationDataPointsFC.FindField("PlotAtScale");
            int aziFld = m_OrientationDataPointsFC.FindField("Azimuth");
            int incFld = m_OrientationDataPointsFC.FindField("Inclination");
            int orConfFld = m_OrientationDataPointsFC.FindField("OrientationConfidenceDegrees");
            int notesFld = m_OrientationDataPointsFC.FindField("Notes");
            int dsFld = m_OrientationDataPointsFC.FindField("DataSourceID");
            int symbRotFld = m_OrientationDataPointsFC.FindField("SymbolRotation");
            int symFld = m_OrientationDataPointsFC.FindField("Symbol");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            IFeatureCursor theCursor = m_OrientationDataPointsFC.Search(QF, false);
            IFeature theFeature = theCursor.NextFeature();

            while (theFeature != null)
            {
                OrientationDataPoint anOrientationDataPoint = new OrientationDataPoint();
                anOrientationDataPoint.OrientationDataPoints_ID = theFeature.get_Value(idFld).ToString();
                anOrientationDataPoint.StationID = theFeature.get_Value(stationFld).ToString();
                anOrientationDataPoint.Type = theFeature.get_Value(typeFld).ToString();
                anOrientationDataPoint.IdentityConfidence = theFeature.get_Value(idConfFld).ToString();
                anOrientationDataPoint.Label = theFeature.get_Value(lblFld).ToString();
                bool result;
                result = int.TryParse(theFeature.get_Value(plotFld).ToString(), out anOrientationDataPoint.PlotAtScale);
                result = double.TryParse(theFeature.get_Value(aziFld).ToString(), out anOrientationDataPoint.Azimuth);
                result = double.TryParse(theFeature.get_Value(incFld).ToString(), out anOrientationDataPoint.Inclination);
                result = double.TryParse(theFeature.get_Value(orConfFld).ToString(), out anOrientationDataPoint.OrientationConfidenceDegrees);
                anOrientationDataPoint.Notes = theFeature.get_Value(notesFld).ToString();
                anOrientationDataPoint.DataSourceID = theFeature.get_Value(dsFld).ToString();
                result = double.TryParse(theFeature.get_Value(symbRotFld).ToString(), out anOrientationDataPoint.SymbolRotation);
                result = int.TryParse(theFeature.get_Value(symFld).ToString(), out anOrientationDataPoint.Symbol);
                anOrientationDataPoint.Shape = (IPoint)theFeature.Shape;
                anOrientationDataPoint.RequiresUpdate = true;

                m_OrientationDataPointsDictionary.Add(anOrientationDataPoint.OrientationDataPoints_ID, anOrientationDataPoint);

                theFeature = theCursor.NextFeature();
            }
        }
示例#21
0
        public void AddMapUnitPolys(string SqlWhereClause)
        {
            // Figure out the MapUnitPolys_ID field. It could be one of the following.
            string[] mupIdFields = { "MapUnitPolys_ID", "CMUMapUnitPolys_ID", "CSAMapUnitPolys_ID", "CSBMapUnitPolys_ID", "CSCMapUnitPolys_ID", "CSDMapUnitPolys_ID", "CSEMapUnitPolys_ID", "CSFMapUnitPolys_ID" };
            string mupIdField = "";
            int idFld = -1;
            for (int i = 0; i < mupIdFields.Length; i++)
                if (idFld == -1)
                {
                    mupIdField = mupIdFields[i];
                    idFld = m_MapUnitPolysFC.FindField(mupIdField);
                }
            int unitFld = m_MapUnitPolysFC.FindField("MapUnit");
            int idConfFld = m_MapUnitPolysFC.FindField("IdentityConfidence");
            int lblFld = m_MapUnitPolysFC.FindField("Label");
            int notesFld = m_MapUnitPolysFC.FindField("Notes");
            int dsFld = m_MapUnitPolysFC.FindField("DataSourceID");
            int symFld = m_MapUnitPolysFC.FindField("Symbol");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            IFeatureCursor theCursor = m_MapUnitPolysFC.Search(QF, false);
            IFeature theFeature = theCursor.NextFeature();

            while (theFeature != null)
            {
                MapUnitPoly anMapUnitPoly = new MapUnitPoly();
                anMapUnitPoly.MapUnitPolys_ID = theFeature.get_Value(idFld).ToString();
                anMapUnitPoly.MapUnit = theFeature.get_Value(unitFld).ToString();
                anMapUnitPoly.IdentityConfidence = theFeature.get_Value(idConfFld).ToString();
                anMapUnitPoly.Label = theFeature.get_Value(lblFld).ToString();
                anMapUnitPoly.Notes = theFeature.get_Value(notesFld).ToString();
                anMapUnitPoly.DataSourceID = theFeature.get_Value(dsFld).ToString();
                anMapUnitPoly.Symbol = theFeature.get_Value(symFld).ToString();
                anMapUnitPoly.Shape = (IPolygon)theFeature.Shape;
                anMapUnitPoly.RequiresUpdate = true;

                m_MapUnitPolysDictionary.Add(anMapUnitPoly.MapUnitPolys_ID, anMapUnitPoly);

                theFeature = theCursor.NextFeature();
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(theCursor);
        }
        public void AddGeologicEvents(string SqlWhereClause = null)
        {
            int idFld = m_GeologicEventsTable.FindField("GeologicEvents_ID");
            int eventFld = m_GeologicEventsTable.FindField("Event");
            int ageDisplayFld = m_GeologicEventsTable.FindField("AgeDisplay");
            int ageYoungerTermFld = m_GeologicEventsTable.FindField("AgeYoungerTerm");
            int ageOlderTermFld = m_GeologicEventsTable.FindField("AgeOlderTerm");
            int timeScaleFld = m_GeologicEventsTable.FindField("TimeScale");
            int ageYoungerValueFld = m_GeologicEventsTable.FindField("AgeYoungerValue");
            int ageOlderValueFld = m_GeologicEventsTable.FindField("AgeOlderValue");
            int dataSrcFld = m_GeologicEventsTable.FindField("DataSourceID");
            int notesFld = m_GeologicEventsTable.FindField("Notes");

            ICursor theCursor;

            if (SqlWhereClause == null) { theCursor = m_GeologicEventsTable.Search(null, false); }
            else
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = SqlWhereClause;
                theCursor = m_GeologicEventsTable.Search(QF, false);
            }

            IRow theRow = theCursor.NextRow();

            while (theRow != null)
            {
                GeologicEvents anGeologicEvents = new GeologicEvents();
                anGeologicEvents.GeologicEvents_ID = theRow.get_Value(idFld).ToString();
                anGeologicEvents.Event = theRow.get_Value(eventFld).ToString();
                anGeologicEvents.AgeDisplay = theRow.get_Value(ageDisplayFld).ToString();
                anGeologicEvents.AgeYoungerTerm = theRow.get_Value(ageYoungerTermFld).ToString();
                anGeologicEvents.AgeOlderTerm = theRow.get_Value(ageOlderTermFld).ToString();
                anGeologicEvents.TimeScale = theRow.get_Value(timeScaleFld).ToString();
                anGeologicEvents.AgeYoungerValue = theRow.get_Value(ageYoungerValueFld).ToString();
                anGeologicEvents.AgeOlderValue = theRow.get_Value(ageOlderValueFld).ToString();
                anGeologicEvents.DataSourceID = theRow.get_Value(dataSrcFld).ToString();
                anGeologicEvents.Notes = theRow.get_Value(notesFld).ToString();
                anGeologicEvents.RequiresUpdate = true;

                m_GeologicEventsDictionary.Add(anGeologicEvents.GeologicEvents_ID, anGeologicEvents);

                theRow = theCursor.NextRow();
            }
        }
示例#23
0
        private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            IFeatureSelection pFeatureSelection = pFeatureLayer as IFeatureSelection;
            //����������
            IQueryFilter pQueryFilter = new QueryFilterClass();
            //���ù���������IJ�ѯ����
            pQueryFilter.WhereClause = dataGridView1.Columns[0].HeaderText + "=" + dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();

            IFeatureCursor pFeatureCursor = pFeatureLayer.Search(pQueryFilter, false);
            IFeature pFeature = pFeatureCursor.NextFeature();

            SearchViewInfo frm = null;
            if (frm == null || frm.IsDisposed)
                frm = new SearchViewInfo(pFeature);

            frm.Show();
            frm.TopMost = true;
        }
示例#24
0
        /// <summary>
        /// 删除feature图元
        /// </summary>
        /// <param name="intObjID"></param>
        /// <param name="strLayerName"></param>
        /// <param name="map"></param>
        public void DelFeature(int intObjID, string strLayerName, AxMapControl map)
        {
            IFeatureLayer pfeaLayer;
            for (int intI = 0; intI < map.LayerCount; intI++)
            {
                try
                {
                    pfeaLayer = map.get_Layer(intI) as IFeatureLayer;
                    if (pfeaLayer != null && pfeaLayer.FeatureClass.AliasName == strLayerName)
                    {

                        //定义一个地物类,把要编辑的图层转化为定义的地物类
                        IFeatureClass fc = pfeaLayer.FeatureClass;
                        //先定义一个编辑的工作空间,然后把转化为数据集,最后转化为编辑工作空间,
                        IWorkspaceEdit w = (fc as IDataset).Workspace as IWorkspaceEdit;
                        //开始事务操作
                        w.StartEditing(false);
                        //开始编辑
                        w.StartEditOperation();
                        IQueryFilter queryFilter = new QueryFilterClass();
                        queryFilter.WhereClause = "OBJECTID=" + intObjID;
                        IFeatureCursor updateCursor = pfeaLayer.FeatureClass.Update(queryFilter, false);
                        IFeature feature = updateCursor.NextFeature();

                        int m = 0;
                        while (feature != null)
                        {
                            m++;
                            updateCursor.DeleteFeature();
                            feature = updateCursor.NextFeature();
                        }
                        //结束编辑
                        w.StopEditOperation();
                        //结束事务操作
                        w.StopEditing(true);
                        break;
                    }
                }
                catch
                {

                }
            }
        }
示例#25
0
        public void AddStations(string SqlWhereClause)
        {
            int idFld = m_StationsFC.FindField("Stations_ID");
            int fieldFld = m_StationsFC.FindField("FieldID");
            int lblFld = m_StationsFC.FindField("Label");
            int plotFld = m_StationsFC.FindField("PlotAtScale");
            int locConfFld = m_StationsFC.FindField("LocationConfidenceMeters");
            int latFld = m_StationsFC.FindField("Latitude");
            if (latFld == -1)
                latFld = m_StationsFC.FindField("MapY");
            int longFld = m_StationsFC.FindField("Longitude");
            if (longFld == -1)
                longFld = m_StationsFC.FindField("MapX");
            int dsFld = m_StationsFC.FindField("DataSourceID");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            IFeatureCursor theCursor = m_StationsFC.Search(QF, false);
            IFeature theFeature = theCursor.NextFeature();

            while (theFeature != null)
            {
                Station anStation = new Station();
                anStation.Stations_ID = theFeature.get_Value(idFld).ToString();
                anStation.FieldID = theFeature.get_Value(fieldFld).ToString();
                anStation.Label = theFeature.get_Value(lblFld).ToString();
                string plotFldStr = theFeature.get_Value(plotFld).ToString();
                anStation.PlotAtScale = int.Parse(string.IsNullOrEmpty(plotFldStr) ? "-9999" : plotFldStr);
                string locConfFldStr = theFeature.get_Value(locConfFld).ToString();
                anStation.LocationConfidenceMeters = double.Parse(string.IsNullOrEmpty(locConfFldStr) ? "-9999" : locConfFldStr);
                string latFldStr = theFeature.get_Value(latFld).ToString();
                anStation.Latitude = double.Parse(string.IsNullOrEmpty(latFldStr) ? "-9999" : latFldStr);
                string longFldStr = theFeature.get_Value(longFld).ToString();
                anStation.Longitude = double.Parse(string.IsNullOrEmpty(longFldStr) ? "-9999" : longFldStr);
                anStation.DataSourceID = theFeature.get_Value(dsFld).ToString();
                anStation.Shape = (IPoint)theFeature.Shape;
                anStation.RequiresUpdate = true;

                m_StationsDictionary.Add(anStation.Stations_ID, anStation);

                theFeature = theCursor.NextFeature();
            }
        }
        /// <summary>
        /// 复制要素
        /// </summary>
        /// <params name="sourceFeaLayer"></params>
        /// <params name="targetFeaLayer"></params>
        /// <params name="ID"></params>
        /// <returns></returns>
        public static bool CopyFeature(IFeatureLayer sourceFeaLayer, IFeatureLayer targetFeaLayer, string ID)
        {
            //获得编辑工作空间
            IDataset pSourceDataset = null;
            IWorkspace pSourceWorkspace = null;
            IWorkspaceEdit pSourceWorkspaceEdit = null;
            IFeature pSourceFeature = null;
            IFeatureCursor feaCursor = null;

            try
            {
                pSourceDataset = (IDataset)sourceFeaLayer.FeatureClass;
                pSourceWorkspace = pSourceDataset.Workspace;
                pSourceWorkspaceEdit = pSourceWorkspace as IWorkspaceEdit;

                //遍历源图层找到对应要素

                IQueryFilter queryFilter = new QueryFilterClass();
                queryFilter.WhereClause = "";
                feaCursor = sourceFeaLayer.FeatureClass.Search(queryFilter, true);
                pSourceFeature = feaCursor.NextFeature();
                while (pSourceFeature != null)
                {
                    IGeometry geometry = pSourceFeature.Shape as IGeometry;
                    InsertNewFeature(targetFeaLayer, geometry, ID);//将源图层中要素插入到新图层中并赋值

                    pSourceFeature = feaCursor.NextFeature();
                }

                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (feaCursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(feaCursor);  //释放指针
                }
            }
        }
        public void AddContactsAndFaults(string SqlWhereClause)
        {
            int idFld = m_ContactsAndFaultsFC.FindField("ContactsAndFaults_ID");
            int typeFld = m_ContactsAndFaultsFC.FindField("Type");
            int concFld = m_ContactsAndFaultsFC.FindField("IsConcealed");
            int locConfFld = m_ContactsAndFaultsFC.FindField("LocationConfidenceMeters");
            int exConfFld = m_ContactsAndFaultsFC.FindField("ExistenceConfidence");
            int idConfFld = m_ContactsAndFaultsFC.FindField("IdentityConfidence");
            int symbFld = m_ContactsAndFaultsFC.FindField("Symbol");
            int lblFld = m_ContactsAndFaultsFC.FindField("Label");
            int notesFld = m_ContactsAndFaultsFC.FindField("Notes");
            int dsFld = m_ContactsAndFaultsFC.FindField("DataSourceID");
            int symFld = m_ContactsAndFaultsFC.FindField("RuleID");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            IFeatureCursor theCursor = m_ContactsAndFaultsFC.Search(QF, false);
            IFeature theFeature = theCursor.NextFeature();

            while (theFeature != null)
            {
                ContactsAndFault anContactsAndFault = new ContactsAndFault();
                anContactsAndFault.ContactsAndFaults_ID = theFeature.get_Value(idFld).ToString();
                anContactsAndFault.Type = theFeature.get_Value(typeFld).ToString();
                bool result = int.TryParse(theFeature.get_Value(concFld).ToString(), out anContactsAndFault.IsConcealed);
                string locConfFldStr = theFeature.get_Value(locConfFld).ToString();
                anContactsAndFault.LocationConfidenceMeters = double.Parse(string.IsNullOrEmpty(locConfFldStr) ? "-9999" : locConfFldStr);
                anContactsAndFault.ExistenceConfidence = theFeature.get_Value(exConfFld).ToString();
                anContactsAndFault.IdentityConfidence = theFeature.get_Value(idConfFld).ToString();
                anContactsAndFault.Symbol = theFeature.get_Value(symbFld).ToString();
                anContactsAndFault.Label = theFeature.get_Value(lblFld).ToString();
                anContactsAndFault.Notes = theFeature.get_Value(notesFld).ToString();
                anContactsAndFault.DataSourceID = theFeature.get_Value(dsFld).ToString();
                anContactsAndFault.RuleID = theFeature.get_Value(symFld).ToString();
                anContactsAndFault.Shape = (IPolyline)theFeature.Shape;
                anContactsAndFault.RequiresUpdate = true;

                m_ContactsAndFaultsDictionary.Add(anContactsAndFault.ContactsAndFaults_ID, anContactsAndFault);

                theFeature = theCursor.NextFeature();
            }
        }
        public void AddExtendedAttributes(string SqlWhereClause = null)
        {
            int idFld = m_ExtendedAttributesTable.FindField("ExtendedAttributes_ID");
            int ownerTableFld = m_ExtendedAttributesTable.FindField("OwnerTable");
            int ownerFld = m_ExtendedAttributesTable.FindField("OwnerID");
            int propertyFld = m_ExtendedAttributesTable.FindField("Property");
            int propertyValueFld = m_ExtendedAttributesTable.FindField("PropertyValue");
            int valueLinkFld = m_ExtendedAttributesTable.FindField("ValueLinkID");
            int qualifierFld = m_ExtendedAttributesTable.FindField("Qualifier");
            int dataSrcFld = m_ExtendedAttributesTable.FindField("DataSourceID");
            int notesFld = m_ExtendedAttributesTable.FindField("Notes");

            ICursor theCursor;

            if (SqlWhereClause == null) { theCursor = m_ExtendedAttributesTable.Search(null, false); }
            else
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = SqlWhereClause;
                theCursor = m_ExtendedAttributesTable.Search(QF, false);
            }

            IRow theRow = theCursor.NextRow();

            while (theRow != null)
            {
                ExtendedAttributes anExtendedAttributes = new ExtendedAttributes();
                anExtendedAttributes.ExtendedAttributes_ID = theRow.get_Value(idFld).ToString();
                anExtendedAttributes.OwnerTable = theRow.get_Value(ownerTableFld).ToString();
                anExtendedAttributes.OwnerID = theRow.get_Value(ownerFld).ToString();
                anExtendedAttributes.Property = theRow.get_Value(propertyFld).ToString();
                anExtendedAttributes.PropertyValue = theRow.get_Value(propertyValueFld).ToString();
                anExtendedAttributes.ValueLinkID = theRow.get_Value(valueLinkFld).ToString();
                anExtendedAttributes.Qualifier = theRow.get_Value(qualifierFld).ToString();
                anExtendedAttributes.DataSourceID = theRow.get_Value(dataSrcFld).ToString();
                anExtendedAttributes.Notes = theRow.get_Value(notesFld).ToString();
                anExtendedAttributes.RequiresUpdate = true;

                m_ExtendedAttributesDictionary.Add(anExtendedAttributes.ExtendedAttributes_ID, anExtendedAttributes);

                theRow = theCursor.NextRow();
            }
        }
        public List<string> listaElementos(string Ruta, string Campo, string Query)
        {
            List<string> Lista = new List<string>();
            Lista.Add("");//Elemento vacio primer elemento
            IGPUtilities pGputilities = new GPUtilitiesClass();
            IFeatureClass pFeatureClass = pGputilities.OpenFeatureClassFromString(Ruta);
            ITable pTable = (ITable)pFeatureClass;
            IQueryFilter pQuery = new QueryFilterClass();
            pQuery.WhereClause = Query;
            ICursor pCursor = pTable.Search(pQuery, true);
            IRow pRow = pCursor.NextRow();
            while (pRow != null)
            {
                int idx = pRow.Fields.FindField(Campo);
                Lista.Add(pRow.get_Value(idx).ToString());
                pRow = pCursor.NextRow();
            }

            return Lista;
        }
        public void AddGeologicLines(string SqlWhereClause)
        {
            int idFld = m_GeologicLinesFC.FindField("GeologicLines_ID");
            int typeFld = m_GeologicLinesFC.FindField("Type");
            int locConfFld = m_GeologicLinesFC.FindField("LocationConfidenceMeters");
            int exConfFld = m_GeologicLinesFC.FindField("ExistenceConfidence");
            int idConfFld = m_GeologicLinesFC.FindField("IdentityConfidence");
            int symbFld = m_GeologicLinesFC.FindField("Symbol");
            int lblFld = m_GeologicLinesFC.FindField("Label");
            int notesFld = m_GeologicLinesFC.FindField("Notes");
            int dsFld = m_GeologicLinesFC.FindField("DataSourceID");
            int symFld = m_GeologicLinesFC.FindField("RuleID");

            IQueryFilter QF = new QueryFilterClass();
            QF.WhereClause = SqlWhereClause;

            IFeatureCursor theCursor = m_GeologicLinesFC.Search(QF, false);
            IFeature theFeature = theCursor.NextFeature();

            while (theFeature != null)
            {
                GeologicLine anGeologicLine = new GeologicLine();
                anGeologicLine.GeologicLines_ID = theFeature.get_Value(idFld).ToString();
                anGeologicLine.Type = theFeature.get_Value(typeFld).ToString();
                string locConfFldStr = theFeature.get_Value(locConfFld).ToString();
                anGeologicLine.LocationConfidenceMeters = double.Parse(string.IsNullOrEmpty(locConfFldStr) ? "-9999" : locConfFldStr);
                anGeologicLine.ExistenceConfidence = theFeature.get_Value(exConfFld).ToString();
                anGeologicLine.IdentityConfidence = theFeature.get_Value(idConfFld).ToString();
                anGeologicLine.Symbol = theFeature.get_Value(symbFld).ToString();
                anGeologicLine.Label = theFeature.get_Value(lblFld).ToString();
                anGeologicLine.Notes = theFeature.get_Value(notesFld).ToString();
                anGeologicLine.DataSourceID = theFeature.get_Value(dsFld).ToString();
                anGeologicLine.RuleID = theFeature.get_Value(symFld).ToString();
                anGeologicLine.Shape = (IPolyline)theFeature.Shape;
                anGeologicLine.RequiresUpdate = true;

                m_GeologicLinesDictionary.Add(anGeologicLine.GeologicLines_ID, anGeologicLine);

                theFeature = theCursor.NextFeature();
            }
        }
示例#31
0
        ComboBoxListItem[] getVillageCommitteeDict(string townshipCode)
        {
            List <ComboBoxListItem> vVillageCommitteeDict = new List <ComboBoxListItem>();

            vVillageCommitteeDict.Add(new ComboBoxListItem("请选择", "请选择"));
            if (VillageCommitteeFeatureLayer != null)
            {
                IQueryFilter vQueryFilter = new QueryFilterClass();
                vQueryFilter.WhereClause = (string.Format("XZDM = '{0}'", townshipCode));
                IFeatureCursor vFeatureCursor = VillageCommitteeFeatureLayer.FeatureClass.Search(vQueryFilter, true);
                IFeature       vFeature       = vFeatureCursor.NextFeature();
                while (vFeature != null)
                {
                    int    vXZDMIndex = vFeature.Fields.FindField("CWHDM");
                    int    VNameIndex = vFeature.Fields.FindField("村委会_dwg");
                    string vXZDM      = vFeature.get_Value(vXZDMIndex).ToString();
                    string vName      = vFeature.get_Value(VNameIndex).ToString();
                    vVillageCommitteeDict.Add(new ComboBoxListItem(vXZDM, vName));
                    vFeature = vFeatureCursor.NextFeature();
                }
            }
            return(vVillageCommitteeDict.ToArray());
        }
示例#32
0
 public void AddNextToTable(bool bAll)
 {
     if (this.m_pTable != null)
     {
         IQueryFilter queryFilter = null;
         queryFilter = new QueryFilterClass();
         System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
         if (this.m_strWhere.Length > 1)
         {
             queryFilter.WhereClause = this.m_strWhere + " and " + this.m_pTable.OIDFieldName + " > " +
                                       this.m_MaxOID.ToString();
         }
         else
         {
             queryFilter.WhereClause = this.m_pTable.OIDFieldName + " > " + this.m_MaxOID.ToString();
         }
         this.m_pCursor = this.m_pTable.Search(queryFilter, false);
         this.AddRecordToListView(bAll);
         ComReleaser.ReleaseCOMObject(this.m_pCursor);
         this.m_pCursor = null;
         System.Windows.Forms.Cursor.Current = Cursors.Default;
     }
 }
示例#33
0
        private IFeature FindJunctionFeature(string osmid)
        {
            IFeatureClass fcPoint = OsmPointFeatureClass;

            IQueryFilter filter = new QueryFilterClass();

            filter.SubFields   = string.Join(",", new string[] { fcPoint.OIDFieldName, fcPoint.ShapeFieldName, "OSMID" });
            filter.WhereClause = fcPoint.WhereClauseByExtensionVersion(osmid, "OSMID", OsmExtVersion);

            using (ComReleaser cr = new ComReleaser())
            {
                IFeatureCursor cursor = fcPoint.Search(filter, false);
                cr.ManageLifetime(cursor);

                IFeature feature = cursor.NextFeature();
                if (feature != null)
                {
                    return(feature);
                }
            }

            return(null);
        }
示例#34
0
        public void OrderByGuidFileGdb()
        {
            IFeatureWorkspace featureWs =
                WorkspaceUtils.OpenFileGdbFeatureWorkspace(TestData.GetArealeFileGdbPath());
            ITable table = DatasetUtils.OpenTable(featureWs, "TLM_NUTZUNGSAREAL");

            IQueryFilter queryFilter = new QueryFilterClass();

            var queryFilterDef = (IQueryFilterDefinition)queryFilter;

            queryFilterDef.PostfixClause = "ORDER BY UUID";

            foreach (IRow row in GdbQueryUtils.GetRows(table, queryFilter, true))
            {
                object value = row.get_Value(1);

                Assert.False(value == DBNull.Value, "Empty UUID field");

                var currentGuid = new Guid((string)value);

                Console.WriteLine(currentGuid);
            }
        }
示例#35
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entityID">实体编码</param>
        /// <param name="pFeatlayerList">MapControl中的图层集</param>
        /// <param name="lyrName">图层名称</param>
        private void GetGraphElementsInLyr(string entityID, List <IFeatureLayer> pFeatlayerList, string lyrName)
        {
            string entityField = ClsConfig.LayerConfigs[lyrName].EntityID;

            IFeatureLayer  featLyr  = this.GetFeatureLayerByName(pFeatlayerList, lyrName);
            IFeatureCursor pCursor  = null;
            IFeature       pFeature = null;
            //查询一个字段(ENTIID)
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = entityField + " = '" + entityID + "'";
            pCursor = featLyr.FeatureClass.Search(queryFilter, false);
            if (pCursor != null)
            {
                pFeature = pCursor.NextFeature();
            }
            while (pFeature != null)
            {
                ClsGraphElement ge = this.GetGraphElement(pFeature, lyrName);
                this._graphElements.Add(ge);
                pFeature = pCursor.NextFeature();
            }
        }
示例#36
0
        private void binddata()
        {
            IQueryFilter pFilter = new QueryFilterClass();

            pFilter.WhereClause = "strtype ='1'";
            IFeatureCursor   pCursor  = frmzhzzt.pFeatureClass.Search(pFilter, false);
            IFeature         pFeature = pCursor.NextFeature();
            List <Histogram> list     = new List <Histogram>();

            while (pFeature != null)
            {
                Histogram his     = new Histogram();
                string    id      = pFeature.get_Value(pFeature.Fields.FindField("BID")).ToString();
                string    blc     = pFeature.get_Value(pFeature.Fields.FindField("bilici")).ToString();
                string    textstr = pFeature.get_Value(pFeature.Fields.FindField("textstr")).ToString();
                his.BLC = Convert.ToDouble(blc);
                his.ID  = id;
                his.HistogramEntName = textstr;
                list.Add(his);
                pFeature = pCursor.NextFeature();
            }
            dgrdvZhzzt.DataSource = list;
        }
示例#37
0
文件: FarmInfo.cs 项目: lidan233/C---
        private void button3_Click(object sender, EventArgs e)
        {
            string sql = "delete from build where id=" + textBox1.Text.Trim() + "";

            Dao.dml(sql);
            clearContent();
            textBox1.Text = "";


            //设定筛选条件获得满足要求的所有Feature
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = "";
            IFeatureCursor cursor  = me.FeatureClass.Search(queryFilter, false);
            IFeature       feature = cursor.NextFeature();
            //获取想要获取的字段值的fieldName的id号
            string name  = "";
            int    index = 0;

            while (feature != null)
            {
                if (Convert.ToString(feature.get_Value(1)) == textBox2.Text.Trim())
                {
                    cursor.DeleteFeature();
                }
                feature = cursor.NextFeature();
            }



            MessageBox.Show("删除成功!");
            //更新表格内容
            DataSet dataset = null;

            dataset = Dao.query("select*from build");
            dataGridView1.DataSource = dataset.Tables[0];
        }
示例#38
0
        //初始化普通车辆智能体
        //随机产生起点、终点构建车辆智能体
        public void InitializeOrdinaryVehicleAgent(int OrdinaryVehicleNumber)
        {
            IFeatureLayer pFeatureLayer = CDataImport.ImportFeatureLayerFromControltext(@"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\data\point.shp");
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            int           pointNumber   = pFeatureClass.FeatureCount(null);
            Random        random        = new Random();

            for (int i = 0; i < OrdinaryVehicleNumber; i++)
            {
                OrdinaryVehicle pOrdinaryVehicle = new OrdinaryVehicle();
                pOrdinaryVehicle.ID          = i + 1;
                pOrdinaryVehicle.Origination = random.Next(1, pointNumber);
                pOrdinaryVehicle.Destination = random.Next(1, pointNumber);
                if (pOrdinaryVehicle.Origination != pOrdinaryVehicle.Destination)
                {
                    IQueryFilter pQueryFilterOrigination = new QueryFilterClass();
                    pQueryFilterOrigination.WhereClause = "OBJECTID=" + "'" + pOrdinaryVehicle.Origination + "'";
                    IFeatureCursor pFeatureCursorOrigination = pFeatureClass.Search(pQueryFilterOrigination, false);
                    IFeature       pFeatureOrigination       = pFeatureCursorOrigination.NextFeature();
                    while (pFeatureOrigination != null)
                    {
                        pOrdinaryVehicle.OriginationPoint = pFeatureOrigination.Shape as IPoint;
                        pFeatureOrigination = pFeatureCursorOrigination.NextFeature();
                    }
                    IQueryFilter pQueryFilterDestination = new QueryFilterClass();
                    pQueryFilterDestination.WhereClause = "OBJECTID=" + "'" + pOrdinaryVehicle.Destination + "'";
                    IFeatureCursor pFeatureCursorDestination = pFeatureClass.Search(pQueryFilterDestination, false);
                    IFeature       pFeatureDestination       = pFeatureCursorDestination.NextFeature();
                    while (pFeatureDestination != null)
                    {
                        pOrdinaryVehicle.DestinationPoint = pFeatureDestination.Shape as IPoint;
                        pFeatureDestination = pFeatureCursorDestination.NextFeature();
                    }
                    pOrdinaryVehicleAgent.Add(pOrdinaryVehicle);
                }
            }
        }
示例#39
0
        private void btnMap_Click_1(object sender, EventArgs e)
        {
            DataGrid curGrid;

            curGrid = (this.tabControl1.SelectedTab.Controls.Find("grid", true))[0] as DataGrid;
            m_pMapControl.Map.ClearSelection();
            int id = curGrid.CurrentRowIndex;

            if (id < 0)
            {
                return;
            }

            string SID          = curGrid[id, 0].ToString(); //在DataGrid中读出要素的ID
            string strClassName = curGrid[id, 3].ToString(); //读出要素所在层名
            //string strTopoClass = strClassName + "_Topo";

            IFeature       pFture = null;
            IFeatureCursor pFeaCursor;
            IFeatureClass  pCurFC;
            IQueryFilter   pFilter = new QueryFilterClass();

            pFilter.WhereClause = "OBJECTID = " + SID;

            pCurFC     = m_pWsp.OpenFeatureClass(strClassName);
            pFeaCursor = pCurFC.Search(pFilter, true);
            if (pFeaCursor != null)
            {
                pFture = pFeaCursor.NextFeature();

                if (pFture != null)
                {
                    MoveToFeature(m_pMapControl, pFture);
                    ShowSelectionFeature(m_pMapControl, pFture);
                }
            }
        }
示例#40
0
        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            if (this.gridView1.FocusedRowHandle == -1)
            {
                return;
            }
            DataRow dr = this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle);

            if (dr["FeatureClass"] != null && dr["FeatureClass"] is IFeatureClass)
            {
                IFeatureClass fc = dr["FeatureClass"] as IFeatureClass;
                //声明ColumnView对象
                var columnView = (ColumnView)gridControl1.FocusedView;
                //得到选中的行索引
                int id = columnView.FocusedRowHandle;
                if (id < 0)
                {
                    return;
                }
                string         SID    = gridView1.GetRowCellValue(id, "ErrorFeatureID").ToString();//在GridControl中读出要素的ID
                IFeature       pFture = null;
                IFeatureCursor pFeaCursor;
                IQueryFilter   pFilter = new QueryFilterClass();
                pFilter.WhereClause = "OBJECTID = " + SID;
                pFeaCursor          = fc.Search(pFilter, true);
                if (pFeaCursor != null)
                {
                    pFture = pFeaCursor.NextFeature();

                    if (pFture != null)
                    {
                        MoveToFeature(m_pMapControl, pFture);        //定位
                        ShowSelectionFeature(m_pMapControl, pFture); //高亮
                    }
                }
            }
        }
示例#41
0
        //重载一个去重复枚举字段值的查询日志
        public static List <string> SeachLog2(string inFieldName)
        {
            if (m_sysTable == null)
            {
                return(null);
            }
            Exception err;
            ITable    pTable = m_sysTable.OpenTable(m_LogNAME, out err);

            if (pTable == null)
            {
                MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(null);//若日志表不存在,返回null
            }
            List <string> resList = new List <string>();
            IQueryFilter  pQF     = new QueryFilterClass();

            pQF.WhereClause = "";
            ICursor pCursor = pTable.Search(pQF, false);
            IRow    pRow    = pCursor.NextRow();
            int     i1      = pTable.FindField(inFieldName);

            while (pRow != null)
            {
                string logRow = string.Empty;
                logRow = pRow.get_Value(i1).ToString();
                if (!resList.Contains(logRow))
                {
                    resList.Add(logRow);
                }
                pRow = pCursor.NextRow();
            }



            return(resList);
        }
示例#42
0
        /// <summary>
        /// 根据查询条件查询要素,对查询获取的要素执行更新操作
        /// </summary>
        /// <param name="featureClass">查询的要素类</param>
        /// <param name="whereClause">查询条件,此值为null时查询所有要素</param>
        /// <param name="doActionByFeatures">针对要素执行的操作,返回值代表是否立即停止更新操作</param>
        /// <param name="nullRecordException">在查询不到记录时是否抛出异常,默认false</param>
        public static void UpdateFeatures(this IFeatureClass featureClass, string whereClause, Func <IFeature, bool> doActionByFeatures, bool nullRecordException = false)
        {
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = whereClause;

            var      featureCursor = featureClass.Update(queryFilter, false);
            IFeature feature       = null;

            if (nullRecordException && featureClass.FeatureCount(queryFilter) == 0)
            {
                CheckNullToThrowException(featureClass, null, whereClause);
            }

            try
            {
                while ((feature = featureCursor.NextFeature()) != null)
                {
                    var isStopped = doActionByFeatures(feature);
                    featureCursor.UpdateFeature(feature);
                    if (isStopped)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)//抛出更具体的异常信息
            {
                var msgOid         = feature == null ? null : $"“OID = {feature.OID}”的";
                var msgWhereClause = string.IsNullOrEmpty(whereClause) ? null : $"根据条件“{whereClause}”";
                throw new Exception($"在{featureClass.AliasName}图层中,{msgWhereClause}更新{msgOid}记录时出错:{ex.Message}");
            }
            finally
            {
                Marshal.ReleaseComObject(featureCursor);
            }
        }
示例#43
0
        public void createFeature(IFeatureClass sourceFeatureClass, IFeatureClass targetFeatureClass)
        {
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = queryClause;
            IFeatureCursor cursor        = sourceFeatureClass.Search(queryFilter, true);
            IFeature       sourceFeature = cursor.NextFeature();

            while (sourceFeature != null)
            {
                IFeature targetFeature = targetFeatureClass.CreateFeature();

                //如果是线或面要素类需要执行下Simplify,这里用的点要素类,不做验证了
                targetFeature.Shape = sourceFeature.ShapeCopy;

                for (int i = 0; i < sourceFeature.Fields.FieldCount; i++)
                {
                    IField field = sourceFeature.Fields.get_Field(i);
                    if (field.Type != esriFieldType.esriFieldTypeOID && field.Type != esriFieldType.esriFieldTypeGeometry && field.Type != esriFieldType.esriFieldTypeGlobalID && field.Type != esriFieldType.esriFieldTypeGUID)
                    {
                        string fieldName = field.Name;
                        int    index     = targetFeature.Fields.FindField(fieldName);
                        if (index > -1 && fieldName != "Shape_Length" && fieldName != "Shape_Area")
                        {
                            targetFeature.set_Value(index, sourceFeature.get_Value(i));
                        }
                    }
                }
                targetFeature.Store();
                sourceFeature = cursor.NextFeature();
            }
            ComReleaser.ReleaseCOMObject(cursor);

            IFeatureClassManage targetFeatureClassManage = targetFeatureClass as IFeatureClassManage;

            targetFeatureClassManage.UpdateExtent();
        }
示例#44
0
 public void ShowDifferenceGeometry(IVersionedWorkspace iversionedWorkspace_0, int int_0, IMap imap_0,
                                    string string_0, string string_1)
 {
     try
     {
         IQueryFilter      filter       = new QueryFilterClass();
         IDataset          featureClass = null;
         IFeatureWorkspace workspace    = iversionedWorkspace_0.FindVersion(string_1) as IFeatureWorkspace;
         for (int i = 0; i < imap_0.LayerCount; i++)
         {
             IFeatureLayer layer = imap_0.get_Layer(i) as IFeatureLayer;
             if (layer != null)
             {
                 featureClass = layer.FeatureClass as IDataset;
                 if (featureClass.Name.ToUpper() == string_0.ToUpper())
                 {
                     break;
                 }
             }
         }
         if (featureClass != null)
         {
             IFeatureClass class3 = workspace.OpenFeatureClass(featureClass.Name);
             filter.WhereClause = "OBJECTID = " + int_0;
             IFeatureCursor o       = class3.Search(filter, false);
             IFeature       feature = o.NextFeature();
             if (feature != null)
             {
                 this.DrawDifferenceGeometry(feature.Shape, (imap_0 as IActiveView).ScreenDisplay);
             }
             ComReleaser.ReleaseCOMObject(o);
         }
     }
     catch
     {
     }
 }
示例#45
0
        /// <summary>
        /// Runs the SAS logistic procedure must have a SampleLocations, OutWorkspace, DependentField, IndependentFields, ClassFields, and optionally Validate and Weight must be specified to run
        /// Running the procedure will create a series of files within the SAS output directory (Workspace path \\SASOUTPUT) These files include; prc.log, prc.sas, prc.lst, outest.csv, and another csv
        /// file of the sample data named after the sample location feature class. Prc.log is the SAS log file. Prc.lst is the output from the SAS procedure. Prc.sas is the SAS code to run the logistic
        /// procedure. Outest.csv is the parameter output file, and [SampleLocationName].csv is the input data used by the sas procedure.
        /// </summary>
        public void runSasProcedure()
        {
            IQueryFilter qry = new QueryFilterClass();

            qry.SubFields = MapField;
            IFeatureCursor fCur   = samplelocations.Search(qry, false);
            int            dIndex = fCur.FindField(MapField);
            IFeature       fRow   = fCur.NextFeature();
            List <string>  sLst   = new List <string>();

            while (fRow != null)
            {
                string vl = fRow.get_Value(dIndex).ToString();
                if (!sLst.Contains(vl))
                {
                    sLst.Add(vl);
                }
                fRow = fCur.NextFeature();
            }
            sasIntegration sInt = new sasIntegration(SampleLocations, SasProcedure.ACCURACYASSESSMENT);

            sInt.Alpha             = Alpha;
            sInt.DependentField    = MapField;
            sInt.DescretFields     = ClassFields;
            sInt.IndependentFields = new string[] { ReferenceField };
            sInt.Weightfield       = WeightField;
            sInt.Validation        = false;
            sInt.StepWiseSelection = Exact;
            SasOutputFile          = sInt.RunProcedure();
            outRest = sInt.OutResultsPath;
            outLog  = sInt.OutLogPath;
            outSas  = sInt.OutSasPath;
            if (InTable != null)
            {
                addConfidenceIntervals();
            }
        }
        public IArray Search(IFeatureLayer pLayer, string sWhereClause)  //SQL语句找到某图层的目标
        {
            IArray pFeatureArray = new ArrayClass();

            if (pLayer == null)
            {
                return(pFeatureArray);
            }
            try
            {
                IFeatureClass pFeatureClass = pLayer.FeatureClass;
                IQueryFilter  pQueryFilter  = new QueryFilterClass();
                pQueryFilter.WhereClause = sWhereClause;
                IFeatureCursor pFeatureCursor = pFeatureClass.Search(pQueryFilter, false);
                IFeature       pFeature       = pFeatureCursor.NextFeature();
                while (pFeature != null)
                {
                    if (pFeature.Shape == null)
                    {
                        pFeature = pFeatureCursor.NextFeature();
                        continue;
                    }
                    if (!pFeature.Shape.IsEmpty)
                    {
                        pFeatureArray.Add(pFeature);
                    }
                    pFeature = pFeatureCursor.NextFeature();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                return(pFeatureArray);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Failed in searching with error: " + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            return(pFeatureArray);
        }
示例#47
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (_pSelectedField != null)
            {
                listUniqueValue.Enabled = true;
                listUniqueValue.Items.Clear();

                IQueryFilter queryFilter = new QueryFilterClass();                                  // 创建查询过滤条件对象
                queryFilter.SubFields = _pSelectedField.Name;                                       // 设置返回的字段名称

                IFeatureCursor  pFeatureCursor  = _pSelectedFeatureClass.Search(queryFilter, true); //得到IFeatureCursor游标
                ICursor         pCursor         = pFeatureCursor as ICursor;                        //接口查询返回ICursor游标
                IDataStatistics pDataStatistics = new DataStatistics();                             //创建DataStatistics对象,该对象用于进行字段值的统计以及获取字段的唯一值
                pDataStatistics.Cursor = pCursor;                                                   //给DataStatistics对象的游标属性赋值
                pDataStatistics.Field  = _pSelectedField.Name;                                      //给DataStatistics对象的字段属性赋值

                IEnumerator pEnumerator = pDataStatistics.UniqueValues;                             //获得唯一值数据集
                pEnumerator.Reset();                                                                //
                while (pEnumerator.MoveNext())                                                      //未到最后一条记录
                {
                    if (pEnumerator.Current != null)
                    {
                        string lsname = pEnumerator.Current.ToString();    //把当前值转成字符串
                        switch (ParseFieldType(_pSelectedField.Type))      //判断字段类型
                        {
                        case "System.String":                              //若为字符串,
                            listUniqueValue.Items.Add("'" + lsname + "'"); //在文本字符串两端加上单引号,然后添加进唯一值列表控件中
                            break;

                        default:
                            listUniqueValue.Items.Add(lsname);       //若为其他类型的字段,则直接添加进唯一值列表控件中
                            break;
                        }
                    }
                }
            }
        }
示例#48
0
        private IGSPlan FindFabricPlanByName(string PlanName, ICadastralEditor CadastralEditor)
        {
            ICursor pCur = null;

            try
            {
                ICadastralFabric pCadaFab   = CadastralEditor.CadastralFabric;
                ITable           pPlanTable = pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
                int          iPlanNameFldID = pPlanTable.FindField("NAME");
                string       PlanNameFld    = pPlanTable.Fields.get_Field(iPlanNameFldID).Name;
                IQueryFilter pQF            = new QueryFilterClass();
                pQF.WhereClause = PlanNameFld + "= '" + PlanName + "'";
                pQF.SubFields   = pPlanTable.OIDFieldName + PlanNameFld;
                pCur            = pPlanTable.Search(pQF, false);
                IRow    pPlanRow  = pCur.NextRow();
                IGSPlan pGSPlanDB = null;
                IGSPlan pGSPlan   = null;
                if (pPlanRow != null)
                {
                    //Since plan was found, generate plan object from database:
                    ICadastralFeatureGenerator pFeatureGenerator = new CadastralFeatureGeneratorClass();
                    pGSPlanDB = pFeatureGenerator.CreatePlanFromRow(CadastralEditor, pPlanRow);
                    //Hydrate the database plan as a new GSPlan in GeoSurvey Engine packet
                    pGSPlan = new GSPlanClass();
                    AssignGSPlan(pGSPlanDB, pGSPlan, true);
                }
                return(pGSPlan);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }
            finally
            {
            }
        }
示例#49
0
        private static string GEOOBJNUMPO = "850002,850102,851112"; //需要特殊处理的坡的编码

        #region                                                     //合并要素类中GUID码相同的要素
        /// <summary>
        /// 合并要素类中GUID码相同的要素
        /// </summary>
        /// <param name="pFeaClass">要合并的要素</param>
        /// <param name="inArGEOOGJNUM">多部件的地物编码</param>
        /// <param name="pGeoC">只合并此范围内的要素</param>
        public static void FeatureClassMerge(IFeatureClass pFeaClass, IGeometryCollection pGeoC, ArrayList inArGEOOGJNUM, double douTolerence)
        {
            IQueryFilter   pFilter    = new QueryFilterClass();
            IFeatureCursor pFeaCursor = null;
            IFeature       pfea;
            int            index = pFeaClass.FindField(GEOOBJNUM);

            ArrayList arrUniqueFea = new ArrayList();     //所有唯一值集合
            ArrayList arrMergeFea  = new ArrayList();     //待合并的要素
            ArrayList arrMergedFea = new ArrayList();     //已经合并的要素,等待下一步删除

            arrUniqueFea = GetUniqueValue(pFeaClass, GEOGUID, pGeoC, douTolerence);

            for (int i = 0; i < arrUniqueFea.Count; i++)
            {
                pFilter.WhereClause = String.Format("{0}='{1}'", GEOGUID, arrUniqueFea[i]);
                pFeaCursor          = pFeaClass.Update(pFilter, false);
                arrMergeFea.Clear();

                pfea = pFeaCursor.NextFeature();
                while (pfea != null)
                {
                    arrMergeFea.Add(pfea);
                    pfea = pFeaCursor.NextFeature();
                }
                if (arrMergeFea.Count > 1)
                {
                    FeatureMerge(arrMergeFea, ref arrMergedFea, pGeoC, inArGEOOGJNUM, index);
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);
            }

            for (int k = 0; k < arrMergedFea.Count; k++)    //删除已经合并的要素
            {
                (arrMergedFea[k] as IFeature).Delete();
            }
        }
        public void DeleteStandardLithology(StandardLithology theStandardLithology)
        {
            try { m_StandardLithologyDictionary.Remove(theStandardLithology.StandardLithology_ID); }
            catch { }

            IEditor theEditor = ArcMap.Editor;

            if (theEditor.EditState == esriEditState.esriStateNotEditing)
            {
                theEditor.StartEditing(m_theWorkspace);
            }
            theEditor.StartOperation();

            try
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = "StandardLithology_ID = '" + theStandardLithology.StandardLithology_ID + "'";

                m_StandardLithologyTable.DeleteSearchedRows(QF);

                theEditor.StopOperation("Delete StandardLithology");
            }
            catch (Exception e) { theEditor.StopOperation("StandardLithology Management Failure"); }
        }
示例#51
0
        // The following function uses an update cursor to change the value of a particular
        // field for a set of features in a feature class.
        private void UpdateFieldValues(IFeatureClass featureClass, string fieldname, object value)
        {
            // Create a new query filter.
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.WhereClause = "";
            queryFilter.SubFields   = fieldname;
            // Get an update cursor constrained by the query filter.
            IFeatureCursor featureCursor = featureClass.Update(queryFilter, false);

            IFields fields     = featureCursor.Fields;
            int     fieldIndex = fields.FindField(fieldname);
            IField  pf         = fields.get_Field(fieldIndex);


            IFeature feature = null;

            while ((feature = featureCursor.NextFeature()) != null)
            {
                feature.set_Value(fieldIndex, value);
                featureCursor.UpdateFeature(feature);
            }
            Marshal.ReleaseComObject(featureCursor);
        }
        public void DeleteGeologicEvents(GeologicEvents theGeologicEvents)
        {
            try { m_GeologicEventsDictionary.Remove(theGeologicEvents.GeologicEvents_ID); }
            catch { }

            IEditor theEditor = ArcMap.Editor;

            if (theEditor.EditState == esriEditState.esriStateNotEditing)
            {
                theEditor.StartEditing(m_theWorkspace);
            }
            theEditor.StartOperation();

            try
            {
                IQueryFilter QF = new QueryFilterClass();
                QF.WhereClause = "GeologicEvents_ID = '" + theGeologicEvents.GeologicEvents_ID + "'";

                m_GeologicEventsTable.DeleteSearchedRows(QF);

                theEditor.StopOperation("Delete GeologicEvents");
            }
            catch (Exception e) { theEditor.StopOperation("GeologicEvents Management Failure"); }
        }
示例#53
0
 private void ApplyBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.exptxtBox.Text == "")
         {
             return;
         }
         IQueryFilter filter = new QueryFilterClass();
         filter.WhereClause = this.exptxtBox.Text;
         IFeatureCursor pCursor = fteClss.Search(filter, false);
         if (pCursor == null)
         {
             return;
         }
         //ExpandMap(pCursor);
         FlashFeature(pCursor);
     }
     catch (Exception ex)
     {
         MessageBox.Show("表达式错误" + "\n" + ex.Message);
         return;
     }
 }
示例#54
0
        public List <string[]> GetUpdateGridsInfoList(string taskName, string code = "")
        {
            List <string[]>   grids    = new List <string[]>();
            IFeatureWorkspace ws       = Util.ServerWorkspace as IFeatureWorkspace;
            ITable            task_fc  = ws.OpenTable("TaskGridLog");
            IQueryFilter      filter   = new QueryFilterClass();
            string            whereStr = "TaskName = '" + taskName + "'";

            if (code != string.Empty)
            {
                whereStr += " and GridCode ='" + code + "'";
            }
            filter.WhereClause = whereStr;
            ICursor cur      = task_fc.Search(filter, false);
            IRow    task_fea = cur.NextRow();

            while (task_fea != null)
            {
                string[] values = new string[4];
                values[0] = task_fea.get_Value(task_fc.FindField("gridcode")) as string;
                string ispassed = task_fea.get_Value(task_fc.FindField("passed")).ToString();
                if (ispassed == "")
                {
                    values[1] = "否";
                }
                else
                {
                    values[1] = "是";
                }
                values[2] = task_fea.get_Value(task_fc.FindField("totaladditems")).ToString();
                values[3] = task_fea.get_Value(task_fc.FindField("totalupdateitems")).ToString();
                grids.Add(values);
                task_fea = cur.NextRow();
            }
            return(grids);
        }
示例#55
0
        /// <summary>
        ///  利用图形对指定要素进行图形求差(小面掏空大面)
        /// </summary>
        /// <param name="pFeatueCls">要素类</param>
        /// <param name="strCon">指定要素条件</param>
        /// <param name="pGeometry">求差图形</param>
        private void UpdateFeatureByOverlapArea(IFeatureClass pFeatueCls, string strCon, IGeometry pGeometry, out Exception err)
        {
            err = null;
            try
            {
                IQueryFilter pQf = new QueryFilterClass();
                pQf.WhereClause = strCon;
                IFeatureCursor pFcursor  = pFeatueCls.Update(pQf, false);
                IFeature       pFeatTemp = pFcursor.NextFeature();
                if (pFeatTemp != null)
                {
                    ITopologicalOperator pTop = pFeatTemp.Shape as ITopologicalOperator;
                    pTop.Simplify();
                    pFeatTemp.Shape = pTop.Difference(pGeometry);
                    pFcursor.UpdateFeature(pFeatTemp);
                }

                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFcursor);
            }
            catch (Exception exError)
            {
                err = exError;
            }
        }
示例#56
0
        /// <summary>
        /// 获取查询结果的游标
        /// </summary>
        /// <param name="pWorkspace">查询对象所在的工作空间</param>
        /// <param name="plstField">所要查询的字段名称</param>
        /// <param name="strKey">关键字</param>
        /// <param name="strTableName">表名</param>
        /// <param name="strLike">当前工作空间的通配符</param>
        /// <returns></returns>
        private ICursor GetCursor(IWorkspace pWorkspace, List <string> plstField, string strKey, string strTableName, string strLike)
        {
            ICursor pCursor = null;

            try
            {
                if (plstField.Count == 0)
                {
                    return(pCursor);
                }
                IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
                ITable            pTable            = pFeatureWorkspace.OpenTable(strTableName);
                IQueryFilter      pQueryFilter      = new QueryFilterClass();
                for (int i = 0; i < plstField.Count; i++)
                {
                    ///获取当前字段的索引号
                    int pIndex = pTable.FindField(plstField[i].ToString());
                    if (pIndex == -1)
                    {
                        continue;
                    }
                    ///根据字段名和关键字组合查询条件
                    if (pQueryFilter.WhereClause == "")
                    {
                        pQueryFilter.WhereClause = plstField[i].ToString() + " Like '" + m_strLike + strKey + m_strLike + "'";
                    }
                    else
                    {
                        pQueryFilter.WhereClause = pQueryFilter.WhereClause + " or " + plstField[i].ToString() + " Like '" + m_strLike + strKey + m_strLike + "'";
                    }
                }
                pCursor = pTable.Search(pQueryFilter, false);
                return(pCursor);
            }
            catch { return(pCursor); }
        }
示例#57
0
 private void m_pDataTable_RowDeleted(object sender, DataRowChangeEventArgs e)
 {
     if (this.m_InEditing && this.m_CanDo)
     {
         try
         {
             object[]       itemArray = e.Row.ItemArray;
             IWorkspaceEdit workspace = (this.m_pTable as IDataset).Workspace as IWorkspaceEdit;
             if (!(itemArray[0] is DBNull))
             {
                 int          num         = Convert.ToInt32(itemArray[0]);
                 IQueryFilter queryFilter = new QueryFilterClass
                 {
                     WhereClause = this.m_pTable.OIDFieldName + " = " + num.ToString()
                 };
                 IRow row = this.m_pTable.Search(queryFilter, false).NextRow();
                 if (row != null)
                 {
                     workspace.StartEditOperation();
                     row.Delete();
                     workspace.StopEditOperation();
                 }
                 row = null;
                 if (this.m_pTable is IFeatureLayer)
                 {
                     (this.m_pMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography,
                                                                 this.m_pTable, null);
                 }
             }
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message);
         }
     }
 }
        /// <summary>
        /// get OID Valve
        /// </summary>
        /// <param name="featureClass">feature class valve</param>
        /// <returns>list of OIDs valve</returns>
        internal static int[] GetOIDs(IFeatureClass featureClass)
        {
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.SubFields = featureClass.OIDFieldName;
            List <int> inputIds = new List <int>();
            //// using (ComReleaser comReleaser = new ComReleaser())
            //// {
            IFeatureCursor featureCursor = null;

            try
            {
                featureCursor = featureClass.Search(queryFilter, true);
                //// comReleaser.ManageLifetime(featureCursor);
                IFeature feature = featureCursor.NextFeature();
                while (feature != null)
                {
                    inputIds.Add(feature.OID);
                    feature = featureCursor.NextFeature();
                }
                ////}
            }
            catch
            {
                throw;
            }
            finally
            {
                if (featureCursor != null)
                {
                    Marshal.ReleaseComObject(featureCursor);
                }
            }

            return(inputIds.ToArray());
        }
示例#59
0
        private void gridControlTable_DoubleClick(object sender, EventArgs e)
        {
            object ojb   = this.gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "FID");
            int    index = Convert.ToInt32(ojb);

            ILayer        pLayer        = _pFtLayer as ILayer;
            IFeatureLayer pFeaturelayer = (IFeatureLayer)pLayer;
            IFeatureClass pFeatureClass = pFeaturelayer.FeatureClass;
            IQueryFilter  pQueryFilter  = new QueryFilterClass();

            pQueryFilter.WhereClause = "FID" + "=" + index.ToString();
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(pQueryFilter, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();

            if (pFeature != null)
            {
                IMap _map = EnviVars.instance.MapControl.Map;
                _map.ClearSelection();
                (_map as IActiveView).Extent = pFeature.Extent;
                _map.SelectFeature(pLayer, pFeature);
                (_map as IActiveView).Refresh();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
        }
示例#60
0
        //功能:查询点要素类中所有包含在面要素类内部的点要素
        private void iSpatialFilterOneByOneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stopwatch myWatch = Stopwatch.StartNew();
            //从MapControl中获取的点图层
            IFeatureLayer     pointFeatureLayer     = axMapControl1.get_Layer(0) as IFeatureLayer;
            IFeatureSelection pointFeatureSelection = pointFeatureLayer as IFeatureSelection;
            //从MapControl中获取的面图层
            IFeatureLayer polygonFeatureLayer = axMapControl1.get_Layer(1) as IFeatureLayer;
            //循环遍历面要素类内部的面,逐一进行查询
            IQueryFilter queryFilter = new QueryFilterClass();

            //Search如果返回属性值的话设置SubFields会提高效率
            queryFilter.SubFields = "Shape";
            IFeatureCursor cursor         = polygonFeatureLayer.Search(queryFilter, true);
            IFeature       polygonFeature = null;

            while ((polygonFeature = cursor.NextFeature()) != null)
            {
                IGeometry queryGeometry = polygonFeature.Shape;
                //构建空间查询
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                spatialFilter.Geometry      = queryGeometry;
                spatialFilter.GeometryField = pointFeatureLayer.FeatureClass.ShapeFieldName;
                spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelContains;
                pointFeatureSelection.SelectFeatures(spatialFilter as IQueryFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);
            }
            int count = pointFeatureSelection.SelectionSet.Count;

            axMapControl1.Refresh();
            //释放游标
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cursor);
            myWatch.Stop();
            string time = myWatch.Elapsed.TotalSeconds.ToString();

            MessageBox.Show("The selected point count is " + count.ToString() + "! and " + time + " Seconds");
        }