Пример #1
0
 private void Worker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         e.Result = false;
         int[] oids = e.Argument as int[];
         if (oids == null || oids.Length < 2)
         {
             return;
         }
         IFeatureClass        featureClass        = this.m_pFtLayer.FeatureClass;
         IFeature             feature             = featureClass.GetFeature(oids[0]);
         IFeature             feature2            = featureClass.GetFeature(oids[1]);
         IPolyline            polyline            = feature.Shape as IPolyline;
         ITopologicalOperator topologicalOperator = polyline as ITopologicalOperator;
         IGeometry            geometry            = null;
         if (topologicalOperator != null)
         {
             geometry = topologicalOperator.Intersect(feature2.Shape, (esriGeometryDimension)1);
         }
         if (!geometry.IsEmpty)
         {
             IMultipoint      multipoint      = geometry as IMultipoint;
             IPointCollection pointCollection = multipoint as IPointCollection;
             this.m_pGeoFlash = pointCollection.get_Point(0);
             e.Result         = true;
         }
     }
     catch (Exception exception)
     {
         e.Result = false;
     }
 }
Пример #2
0
        public static void DeleteCheckArea(int pOID, IFeatureClass pFeatureClass)
        {
            //删除指定要素:
            if (pFeatureClass.GetFeature(pOID) == null)
            {
                return;
            }

            pFeatureClass.GetFeature(pOID).Delete();
        }
Пример #3
0
        /// <summary>
        /// 将要素类序列化成json格式对象
        /// </summary>
        /// <param name="inputFeaClass">输入要素类</param>
        /// <returns></returns>
        public static JsonObject FclassToJsonObj(IFeatureClass inputFeaClass)
        {
            //获取要素数目
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = null;
            int count = inputFeaClass.FeatureCount(pQueryFilter);

            //将每一个要素序列化成json数据
            IFeature          pFeature       = null;
            List <JsonObject> jsonGeometries = new List <JsonObject>();

            for (int i = 1; i < count; i++)//OBJECTID从1开始
            {
                pFeature = inputFeaClass.GetFeature(i);
                IGeometry  pGeometry   = pFeature.Shape;
                JsonObject featureJson = new JsonObject();
                JsonObject feaGeoJson  = null;//几何对象
                if (pGeometry != null)
                {
                    feaGeoJson = Conversion.ToJsonObject(pGeometry);
                    featureJson.AddJsonObject("geometry", feaGeoJson);//加入几何对象
                }

                jsonGeometries.Add(featureJson);
            }

            JsonObject resultJson = new JsonObject();

            resultJson.AddArray("geometries", jsonGeometries.ToArray());
            return(resultJson);
        }
Пример #4
0
        //捕捉
        public IPoint Snapping(double x, double y, IFeatureLayer featureLayer)
        {
            IMap          map          = this.axMapControl1.Map;
            IActiveView   activeView   = this.axMapControl1.ActiveView;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IPoint        point        = new PointClass();

            point.PutCoords(x, y);

            IFeature feature     = featureClass.GetFeature(0);
            IPoint   hitPoint1   = new PointClass();
            IPoint   hitPoint2   = new PointClass();
            IHitTest hitTest     = feature.Shape as IHitTest;
            double   hitDist     = 0;
            int      partIndex   = 0;
            int      vertexIndex = 0;
            bool     bVertexHit  = false;

            double tol = ConvertPixelsToMapUnits(activeView, 8);

            if (hitTest.HitTest(point, tol, esriGeometryHitPartType.esriGeometryPartBoundary,
                                hitPoint2, ref hitDist, ref partIndex, ref vertexIndex, ref bVertexHit))
            {
                hitPoint1 = hitPoint2;
            }
            axMapControl1.ActiveView.Refresh();
            return(hitPoint1);
        }
Пример #5
0
        private IEnvelope GetLayerSelectedFeaturesEnvelope(IFeatureLayer pFeatLyr)
        {
            IEnvelope         layerEnvelope = null;
            IFeatureClass     pFeatCls      = pFeatLyr.FeatureClass;
            IFeatureSelection selectLayer   = pFeatLyr as IFeatureSelection;
            ISelectionSet     selectionSet  = selectLayer.SelectionSet;
            IEnumIDs          enumIDs       = selectionSet.IDs;
            IFeature          feature;
            int i  = 1;
            int iD = enumIDs.Next();

            while (iD != -1) //-1 is reutned after the last valid ID has been reached
            {
                feature = pFeatCls.GetFeature(iD);
                IEnvelope envelope = feature.ShapeCopy.Envelope;
                if (i == 1)
                {
                    layerEnvelope = envelope;
                }
                else
                {
                    layerEnvelope.Union(envelope);
                }
                i++;
                iD = enumIDs.Next();
            }
            return(layerEnvelope);
        }
        public static void WriteBuildErrorsToTurnFC(string outputFileGdbPath, string fdsName, string turnFCName,
                                                    IGPMessages messages, ITrackCancel trackcancel)
        {
            messages.AddMessage("Writing build errors to the turn feature class...");

            // Create a new field on the turn feature class for the build errors

            Geoprocessor gp = new Geoprocessor();

            gp.AddOutputsToMap = false;
            AddField addFieldTool = new AddField();

            addFieldTool.in_table   = outputFileGdbPath + "\\" + fdsName + "\\" + turnFCName;
            addFieldTool.field_name = "BuildError";
            addFieldTool.field_type = "SHORT";
            gp.Execute(addFieldTool, trackcancel);

            // Open the turn feature class in the file geodatabase and find the BuildError field on it

            Type          factoryType     = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            var           wsf             = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
            var           fws             = wsf.OpenFromFile(outputFileGdbPath, 0) as IFeatureWorkspace;
            IFeatureClass turnFC          = fws.OpenFeatureClass(turnFCName);
            int           buildErrorField = turnFC.FindField("BuildError");

            // Open the BuildErrors.txt file generated from building the network dataset

            string   s, leftTrimmedString, oidString;
            int      leftTrimAmt = 24 + turnFCName.Length;
            IFeature feat        = null;

            string[] buildErrorsFiles = System.IO.Directory.GetFiles(Environment.GetEnvironmentVariable("TEMP"), "BuildErrors.txt", System.IO.SearchOption.AllDirectories);
            string   buildErrorsFile  = buildErrorsFiles[0];

            System.IO.StreamReader f = new System.IO.StreamReader(buildErrorsFile);

            // Loop through the BuildErrors.txt file and write the value 1 for each entry found.

            while ((s = f.ReadLine()) != null)
            {
                // ignore blank lines
                if (s.Length == 0)
                {
                    continue;
                }

                // ignore build errors not dealing with the turn source
                if (s.Remove(leftTrimAmt) != ("SourceName: " + turnFCName + ", ObjectID: "))
                {
                    continue;
                }

                leftTrimmedString = s.Substring(leftTrimAmt);
                oidString         = leftTrimmedString.Remove(leftTrimmedString.IndexOf(", "));
                feat = turnFC.GetFeature(Convert.ToInt32(oidString, System.Globalization.CultureInfo.InvariantCulture));
                feat.set_Value(buildErrorField, 1);
                feat.Store();
            }
            f.Close();
        }
Пример #7
0
        public static string ReturnCounty(IFeatureClass SiteLayer, IFeatureClass intersectLayer, string fieldName)
        {//Returns a string saying what County and State the SiteLayer is in
            // Get the feature and its geometry given an Object ID.
            IFeature  stateFeature  = SiteLayer.GetFeature(0);
            IGeometry queryGeometry = stateFeature.Shape;

            IFeature intersectFeature = intersectLayer.GetFeature(0);

            // Create the spatial filter.
            ISpatialFilter spatialFilter = new SpatialFilter();

            spatialFilter.Geometry      = queryGeometry;
            spatialFilter.GeometryField = intersectLayer.ShapeFieldName;
            spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
            spatialFilter.SubFields     = fieldName;

            // Find the position of the field provided the fieldName variable
            int nameFieldPosition = intersectLayer.FindField(fieldName);

            // Execute the query and iterate through the cursor's results.
            IFeatureCursor highwayCursor  = intersectLayer.Search(spatialFilter, false);
            IFeature       highwayFeature = null;

            while ((highwayFeature = highwayCursor.NextFeature()) != null)
            {
                name = Convert.ToString(highwayFeature.get_Value(nameFieldPosition));
            }

            // The cursors is no longer needed, so dispose of it.
            Marshal.ReleaseComObject(highwayCursor);

            return(name);
        }
Пример #8
0
        private void GetQueryGeometry()
        {
            if (queryFeatureClass == null)
            {
                return;
            }
            queryGeometry = null;
            object missing = Type.Missing;

            switch (strGeometryType)
            {
            case "点":
                queryGeometry = new MultipointClass();
                break;

            case "线":
                queryGeometry = new PolylineClass();
                break;

            case "多边形":
            case "矩形":
            case "圆":
                queryGeometry = new PolygonClass();
                break;

            default:
                break;
            }

            for (int i = 0; i < queryFeatureClass.FeatureCount(null); i++)
            {
                queryGeometry.AddGeometry(queryFeatureClass.GetFeature(i).Shape, ref missing, ref missing);
            }
        }
Пример #9
0
        /// <summary>
        /// To open the editor form, we need to first determine which barrier is
        ///  being edited, then pass that value to the form
        /// </summary>
        private void OpenBarrierEditorForm()
        {
            // get the barrier layer by using the category name to as the NAClassName
            INAWindowCategory activeCategory = GetActiveCategory();
            string            categoryName   = activeCategory.NAClass.ClassDefinition.Name;
            INALayer          naLayer        = GetActiveAnalysisLayer();
            ILayer            layer          = naLayer.get_LayerByNAClassName(categoryName);

            // get a selection count and popup a message if more or less than one item is selected
            IFeatureSelection fSel   = layer as IFeatureSelection;
            ISelectionSet     selSet = fSel.SelectionSet;

            if (selSet.Count != 1)
            {
                System.Windows.Forms.MessageBox.Show("Only one barrier in a category can be selected at a time for this command to execute", "Barrier Location Editor Warning");
            }
            else
            {
                // get the object IDs of the selected item
                int id = selSet.IDs.Next();

                // Get the barrier feature by using the selected ID
                IFeatureClass fClass         = naLayer.Context.NAClasses.get_ItemByName(categoryName) as IFeatureClass;
                IFeature      barrierFeature = fClass.GetFeature(id);

                // display the form for editing the barrier
                EditorForm form = new EditorForm(m_application, naLayer.Context, barrierFeature);
                form.ShowDialog();
                form = null;
            }
        }
Пример #10
0
        private void clipToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IFeatureLayer pFeaturelayer;
            IRasterLayer  inRasterlayer;
            int           indexLayer = Convert.ToInt32(Interaction.InputBox("请输入裁剪边界的矢量(.shp)图层下标", "字符串", "", 500, 250));

            pFeaturelayer = this.axMapControl1.Map.get_Layer(indexLayer) as IFeatureLayer;

            int indexRater = Convert.ToInt32(Interaction.InputBox("请输入需要裁剪的栅格图层下标", "字符串", "", 500, 250));

            inRasterlayer = this.axMapControl1.Map.get_Layer(indexRater) as IRasterLayer;
            IRaster inRaster = inRasterlayer.Raster;
            IRaster outRaster;
            //outRaster = this.ShpLayerClipRaster(pFeaturelayer, inRaster);//方法1

            IFeatureClass pFeatureClass = pFeaturelayer.FeatureClass;
            IPolygon      pPolygon      = (pFeatureClass.GetFeature(0)).Shape as IPolygon;

            outRaster = RasterClip(inRasterlayer, pPolygon);//方法2


            //Add output into ArcMap as a raster layer
            IRasterLayer pOutRasLayer = new RasterLayerClass();

            pOutRasLayer.CreateFromRaster(outRaster);
            this.axMapControl1.AddLayer(pOutRasLayer, 0);
            axMapControl1.ActiveView.Refresh();
        }
Пример #11
0
        public static string latlongCoordinates(IFeatureClass SiteLayer)
        {
            // Get the feature and its geometry given an Object ID.
            IFeature  stateFeature  = SiteLayer.GetFeature(0);
            IGeometry shapeGeometry = stateFeature.Shape;

            IArea pArea;

            pArea = shapeGeometry as IArea;

            IPoint pPoint;

            pPoint = pArea.Centroid;

            IGeometry pGeometry = (IGeometry)pPoint;
            ISpatialReferenceFactory    pSpatFactory   = new SpatialReferenceEnvironment();
            IGeographicCoordinateSystem pGeoSystem     = pSpatFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_NAD1983);
            ISpatialReference           pSpatReference = (ISpatialReference)pGeoSystem;

            pSpatReference.SetFalseOriginAndUnits(-180, -90, 1000000);
            pGeometry.Project(pSpatReference);

            double Longitude = Math.Abs(pPoint.X);
            double Latitude  = Math.Abs(pPoint.Y);

            return(Longitude.ToString("#.######") + "° W, " + Latitude.ToString("#.######") + "° N");
        }
        protected override void OnClick()
        {
            IMap          map              = ArcMap.Document.ActiveView as IMap;
            ILayer        lineLayer        = map.Layer[0];
            IFeatureLayer lineFeatureLayer = lineLayer as IFeatureLayer;
            IFeatureClass lineFeatureClass = lineFeatureLayer.FeatureClass;

            ILayer        pointLayer        = map.Layer[1];
            IFeatureLayer pointFeatureLayer = pointLayer as IFeatureLayer;
            IFeatureClass pointFeatureClass = pointFeatureLayer.FeatureClass;


            // Get Feature from 1st layer in ArcMap's TOC - check Object ID
            IFeature  lineFeature = lineFeatureClass.GetFeature(1);
            IPolyline polyline    = lineFeature.Shape as IPolyline;

            IPointCollection pointCollection = polyline as IPointCollection;

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                // Add point to a Points feature class
                IPoint   point        = pointCollection.get_Point(i);
                IFeature pointFeature = pointFeatureClass.CreateFeature();
                pointFeature.Shape = point;
                pointFeature.Store();
            }

            ArcMap.Document.ActiveView.Refresh();
            ArcMap.Application.CurrentTool = null;
        }
Пример #13
0
        private IFeature Convert_Point2MultiPoint_Class(IFeatureClass PointFeatureClass)
        {
            IWorkspaceFactory contourWSF   = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace contourFWS   = (IFeatureWorkspace)contourWSF.OpenFromFile(WorkSpaceName, 0);
            IFields           pFields      = CreateShapeFields(esriGeometryType.esriGeometryMultipoint);
            string            filename     = PointFeatureClass.AliasName + "_muilti";
            string            filename_shp = WorkSpaceName + @"/" + filename + ".shp";

            if (System.IO.File.Exists(filename_shp))
            {
                System.IO.File.Delete(filename_shp);
                System.IO.File.Delete(System.IO.Path.ChangeExtension(filename_shp, ".dbf"));
                System.IO.File.Delete(System.IO.Path.ChangeExtension(filename_shp, ".shx"));
            }
            contourFWS.CreateFeatureClass(filename, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", null);
            IFeatureClass    MultiFeatureClass = contourFWS.OpenFeatureClass(filename);
            IPointCollection pPointCollection  = new MultipointClass();

            for (int i = 0; i < PointFeatureClass.FeatureCount(null); i++)
            {
                IFeature pFeature = PointFeatureClass.GetFeature(i);
                IPoint   pPoint   = pFeature.Shape as IPoint;
                pPointCollection.AddPoint(pPoint);
            }
            IFeature MultiFeature = MultiFeatureClass.CreateFeature();

            MultiFeature.Shape = pPointCollection as IGeometry;
            MultiFeature.Store();
            return(MultiFeature);
        }
Пример #14
0
        public bool polygoncontain(IFeatureClass SourceFeatureClass, IFeatureClass InspectedFeatureClass)
        {
            IFeature SourceFeature    = SourceFeatureClass.GetFeature(1);
            IFeature InspectedFeature = InspectedFeatureClass.GetFeature(1);

            return(polygoncontain(SourceFeature, InspectedFeature));
        }
Пример #15
0
        /// <summary>
        /// 添加一棵树
        /// </summary>
        /// <param name="polyID">标签</param>
        /// <param name="featClass">要素类</param>
        /// <param name="uniqueTouch">唯一连接表</param>
        public void AddTree(int polyID, IFeatureClass featClass, Dictionary <int, Posi> uniqueTouch)
        {
            int       minTreeAngle = 135; //剪枝角度阈值
            IPolyline polyline     = featClass.GetFeature(polyID).ShapeCopy as IPolyline;
            Posi      tag          = uniqueTouch[polyID];
            Tree      tree         = new Tree(polyID); //新建一棵树

            tree.InsertAsRoot(polyID, polyline, 0);

            if (tag != Posi.BOTH)
            {
                InitTag(tag, minTreeAngle, ref tree, featClass);       //初始化FROM标签
                if (tree.Size() > 1)                                   //tag有更新
                {
                    GoForward(tag, minTreeAngle, ref tree, featClass); //向FROM端延申
                }
            }
            else
            {
                InitTag(Posi.FROM, minTreeAngle, ref tree, featClass);       //初始化FROM标签
                if (tree.Size() > 1)                                         //tag有更新
                {
                    GoForward(Posi.FROM, minTreeAngle, ref tree, featClass); //向FROM端延申
                }
                InitTag(Posi.TO, minTreeAngle, ref tree, featClass);         //初始化TO标签
                if (tree.Size() > 1)                                         //tag有更新
                {
                    GoForward(Posi.TO, minTreeAngle, ref tree, featClass);   //向TO端延申
                }
            }

            this.forest.Add(tree);
        }
Пример #16
0
        private void dataGridView1_CellClick(object obj, DataGridViewCellEventArgs dataGridViewCellEventArg)
        {
            int rowIndex = dataGridViewCellEventArg.RowIndex;

            if (rowIndex >= 0)
            {
                int             num  = Convert.ToInt32(this.dataGridView1[2, rowIndex].Value);
                DataGridViewRow item = this.dataGridView1.Rows[dataGridViewCellEventArg.RowIndex];
                IFeatureClass   tag  = (IFeatureClass)item.Tag;
                if (tag != null)
                {
                    IFeature feature = tag.GetFeature(num);
                    if (feature != null)
                    {
                        this.m_pFlashGeo = feature.Shape;
                    }
                }
                CommonUtils.ScaleToTwoGeo(this.m_app.FocusMap, this.m_commonDistAls.m_pBaseLine, this.m_pFlashGeo);
                this.timer_0.Start();
                this.timer_0.Interval = 300;
                this.m_app.ActiveView.Refresh();
                this.m_nTimerCount = 0;
                this.FlashDstItem();
            }
        }
Пример #17
0
        private void Update(int status, IFeatureLayer buildingsfeaturelayer)
        {
            //Get the editor
            _editor = GetEditorFromArcMap(_application as IMxApplication);
            if (_editor == null)
            {
                MessageBox.Show("Editor version of ArcMap required.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (_editor.EditState != esriEditState.esriStateEditing)
            {
                MessageBox.Show("Start an edit session first.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            IFeatureSelection featureselection = buildingsfeaturelayer as IFeatureSelection;

            if (featureselection.SelectionSet.Count == 0)
            {
                MessageBox.Show("Select at least one feature.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }



            IFeatureClass featureclass = buildingsfeaturelayer.FeatureClass;
            IEnumIDs      enumIDs      = featureselection.SelectionSet.IDs;

            _editor.StartOperation();
            enumIDs.Reset();
            int intOID = enumIDs.Next();

            while (intOID != -1)
            {
                IFeature feature = featureclass.GetFeature(intOID);
                if (feature != null)
                {
                    int inspectionfieldindex = _utilitiesArcMap.FindField(featureclass, "rsi");
                    if (inspectionfieldindex > -1)
                    {
                        //_editor.StartOperation();
                        feature.set_Value(inspectionfieldindex, status);
                        //_editor.StopOperation("Status updated!" + feature.OID);
                        feature.Store();
                    }
                    else
                    {
                        throw new Exception("Selected layer does not have the 'rsi field'.");
                    }
                }
                intOID = enumIDs.Next();
            }

            _activeView.Refresh();

            _editor.StopOperation("Inspected...");

            GetStatus();
        }
Пример #18
0
        private void PopulateFields()
        {
            IFeatureLayer featureLayer = _utilitiesArcMap.FeatureLayer(cbo_FeatureLayers.Text);
            IFeatureClass featureClass = featureLayer.FeatureClass;

            try
            {
                if (featureLayer != null)
                {
                    int fieldIndex = _utilitiesArcMap.FindField(featureLayer, "rsi_index");

                    _editor.StartOperation();

                    for (var i = 0; i < _features.Count; i++)
                    {
                        double oid = _features[i]["oid"];

                        IFeature feature = featureClass.GetFeature((int)oid);

                        feature.set_Value(fieldIndex, i + 1);
                        feature.Store();
                    }
                    _editor.StopOperation("Generated Indicies");
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MB_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #19
0
        private void ApplyDomain(DomainCode code)
        {
            if (CheckRequirements())
            {
                IFeatureLayer     featureLayer     = _utilities.FeatureLayer(cboFeatureLayer.Text);
                IFeatureClass     featureClass     = featureLayer.FeatureClass;
                IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
                IEnumIDs          enumIDs          = featureSelection.SelectionSet.IDs;
                int fieldIndex = _utilities.FindField(featureClass, cboField.Text);


                _editor.StartOperation();
                enumIDs.Reset();

                int intOID = enumIDs.Next();

                while (intOID != -1)
                {
                    IFeature feature = featureClass.GetFeature(intOID);
                    if (feature != null)
                    {
                        feature.set_Value(fieldIndex, (int)code);

                        feature.Store();
                    }
                    intOID = enumIDs.Next();
                }

                _activeView.Refresh();
                _editor.StopOperation("Update Class Type");
            }
        }
        //step.3 遍历待复制的要素类,复制图形和属性并改变图形的坐标系
        /// <summary>
        /// 遍历待复制的要素类,复制图形和属性并改变图形的坐标系
        /// </summary>
        /// <param name="fromFeatureClass">待复制的要素类</param>
        /// <param name="toFeatureClass">目标要素类</param>
        private void featureClassTransSpatialRef(IFeatureClass fromFeatureClass, IFeatureClass toFeatureClass)
        {
            IFeature       pFeature;
            IGeometry2     pGeometry;
            IFeatureCursor toCursor     = toFeatureClass.Insert(true);
            int            FeatureCount = fromFeatureClass.FeatureCount(null);

            for (int i = 0; i < FeatureCount; i++)
            {
                pFeature  = fromFeatureClass.GetFeature(i);
                pGeometry = pFeature.Shape as IGeometry2;
                IZAware pZAware = pGeometry as IZAware;
                pZAware.ZAware = true;
                pGeometry.ProjectEx(spatialRefTo, esriTransformDirection.esriTransformForward, geoTransformation, false, 0, 0);
                IFeatureBuffer pFeaBuffer = toFeatureClass.CreateFeatureBuffer();
                pFeaBuffer.Shape = pGeometry;
                for (int j = 2; j < fromFeatureClass.Fields.FieldCount; j++)
                {
                    try
                    {
                        pFeaBuffer.set_Value(j, pFeature.Value[fromFeatureClass.FindField(toFeatureClass.Fields.Field[j].Name)]);
                    }
                    catch
                    {
                        continue;
                    }
                }
                toCursor.InsertFeature(pFeaBuffer);
                toCursor.Flush();
            }
        }
Пример #21
0
        //private IFeatureClass Create_PointFeature(List<Point3D> PointList,string FileFullPath)
        //{
        //    string FileName = System.IO.Path.GetFileName(FileFullPath);
        //    IFeatureClass MptFeatureClass;


        //}


        private void Complete_PropertyTable(ref IFeatureClass pFeatureClass, List <Point3D> PointList)
        {
            string[] FieldName = { "ptName", "X", "Y", "Z" };
            IClass   pTable    = pFeatureClass as IClass;   //use ITable or IClass

            for (int i = 0; i < FieldName.Length; i++)
            {
                IField     pField = new FieldClass();
                IFieldEdit pFieldEdit;
                pFieldEdit        = pField as  IFieldEdit;
                pFieldEdit.Name_2 = FieldName[i];
                if (i == 0)
                {
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                }
                else
                {
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                }
                pTable.AddField(pFieldEdit);
            }

            for (int i = 0; i < pFeatureClass.FeatureCount(null); i++)
            {
                IFeature pFeature = pFeatureClass.GetFeature(i);
                pFeature.set_Value(pFeatureClass.FindField(FieldName[0]), PointList[i].ID);
                pFeature.set_Value(pFeatureClass.FindField(FieldName[1]), PointList[i].X);
                pFeature.set_Value(pFeatureClass.FindField(FieldName[2]), PointList[i].Y);
                pFeature.set_Value(pFeatureClass.FindField(FieldName[3]), PointList[i].Z);
                pFeature.Store();
            }
        }
Пример #22
0
        /// <summary>
        ///测试getFeature与getFeatures
        /// </summary>
        /// <param name="featureCls"></param>
        /// <param name="oids"></param>
        /// <param name="fieldIndex"></param>
        public void SearchById(IFeatureClass featureCls, int[] oids, int fieldIndex)
        {
            foreach (var oid in oids)
            {
                var feature = featureCls.GetFeature(oid);
                Console.WriteLine("oid:" + feature.get_Value(fieldIndex));
            }



            using (var comReleaser = new ComReleaser())
            {
                IFeatureCursor featureCursor = featureCls.GetFeatures(oids, true);;
                IFeature       feature       = featureCursor.NextFeature();
                while (feature != null)
                {
                    Console.WriteLine("oid:" + feature.get_Value(fieldIndex));
                    feature = featureCursor.NextFeature();
                }
            }

            using (var comReleaser = new ComReleaser())
            {
                IGeoDatabaseBridge geodatabaseBridge = new GeoDatabaseHelperClass();
                IFeatureCursor     featureCursor     = geodatabaseBridge.GetFeatures(featureCls, oids, true);;
                IFeature           feature           = featureCursor.NextFeature();
                while (feature != null)
                {
                    Console.WriteLine("oid:" + feature.get_Value(fieldIndex));
                    feature = featureCursor.NextFeature();
                }
            }
        }
Пример #23
0
        private void ShowFalshFeature(int iColumnIndex, int iRowIndex, string strLayerCoum)
        {
            if (iRowIndex == -1)
            {
                return;
            }
            int    iOID         = Convert.ToInt32(DataGridErrs.Rows[iRowIndex].Cells[iColumnIndex].Value);
            string strLayer     = DataGridErrs.Rows[iRowIndex].Cells[strLayerCoum].Value.ToString();
            ILayer pLayer       = ModDBOperator.GetLayer(_MapControl, strLayer);
            double d_mapx       = -1;
            double d_mapy       = -1;
            string errFeaGepStr = string.Empty;

            try
            {
                d_mapx = Convert.ToDouble(DataGridErrs.CurrentRow.Cells["定位点X"].FormattedValue.ToString());
                d_mapy = Convert.ToDouble(DataGridErrs.CurrentRow.Cells["定位点Y"].FormattedValue.ToString());
            }
            catch
            {
                d_mapx = 0; d_mapy = 0;
            }
            try
            {
                errFeaGepStr = DataGridErrs.CurrentRow.Cells["错误几何形状"].FormattedValue.ToString();
            }
            catch
            {
                errFeaGepStr = string.Empty;
            }

            if (iOID != -1)
            {
                if (pLayer != null && pLayer is IFeatureLayer)
                {
                    IFeatureClass pFeatureClass = (pLayer as IFeatureLayer).FeatureClass;
                    if (pFeatureClass == null)
                    {
                        return;
                    }
                    try
                    {
                        IFeature pFeature = pFeatureClass.GetFeature(iOID);
                        //ModOperator.FlashFeature(pFeature, m_hookHelper.ActiveView);
                        //IHookActions pHookActions = m_hookHelper as IHookActions;
                        //pHookActions.DoAction(pFeature.Shape, esriHookActions.esriHookActionsPan);
                        //Application.DoEvents();
                        //pHookActions.DoAction(pFeature.Shape, esriHookActions.esriHookActionsFlash);
                        _MapControl.Map.ClearSelection();
                        _MapControl.Map.SelectFeature(pLayer, pFeature);
                        ShowErrorGeo(d_mapx, d_mapy, errFeaGepStr);
                        _MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, _MapControl.ActiveView.Extent);
                        //Application.DoEvents();
                        //pHookActions.DoAction(pFeature.Shape, esriHookActions.esriHookActionsCallout);
                    }
                    catch { return; }
                }
            }
        }
Пример #24
0
        private void GetFacilityInterdicted(IFeatureWorkspace featureWorkspace, int[] r)
        {
            int           p            = 22;
            IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Hospitals");
            IFeature      pFeature;

            for (int i = 1; i <= p; i++)
            {
                pFeature = featureClass.GetFeature(i) as IFeature;
                IFeatureBuffer pFeatureBuffer = pFeature as IFeatureBuffer;
                pFeatureBuffer.set_Value(pFeature.Fields.FindField("interdicted"), r[i - 1]);
            }
            IMap pMap = this.axMapControl.Map;
            IGraphicsContainer pGraphicsContainerXL = pMap as IGraphicsContainer;

            //add interdicted points
            for (int i = 0; i < p; i++)
            {
                if (r[i] == 1)
                {
                    pFeature = featureClass.GetFeature(i) as IFeature;
                    IPoint       pPoint   = pFeature.Shape as IPoint;
                    ITextElement pTextEle = new TextElementClass();
                    IElement     pElement = pTextEle as IElement;
                    //text
                    pTextEle.Text      = "interdicted";
                    pTextEle.ScaleText = true;
                    pElement.Geometry  = pPoint;
                    //BalloonCallout
                    IBalloonCallout pBalloonCallout = new BalloonCalloutClass();
                    pBalloonCallout.Style       = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                    pBalloonCallout.AnchorPoint = pPoint;
                    IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
                    pTextSymbol.Background          = pBalloonCallout as ITextBackground;
                    pTextSymbol.Direction           = esriTextDirection.esriTDAngle;
                    pTextSymbol.Angle               = 15;
                    pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    pTextSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVATop;
                    pTextEle.Symbol = pTextSymbol;
                    pGraphicsContainerXL.AddElement(pTextEle as IElement, 0);
                }
            }
            axMapControl.Refresh();
        }
Пример #25
0
        public static string GetComment(int pOID, IFeatureClass pFeatureClass)
        {
            //根据OID获取注释信息:
            string   comment = "";
            IFeature feature = pFeatureClass.GetFeature(pOID);

            //comment = pFeatureClass.GetFeature(pOID).get_Value(pFeatureClass.FindField("Comment")).ToString();
            comment = feature.get_Value(feature.Fields.FindField("note")).ToString();
            return(comment);
        }
Пример #26
0
        /// <summary>
        /// 获取Polyline之间的夹角(角度)
        /// </summary>
        /// <param name="id1">Base Polyline的OID</param>
        /// <param name="id2">待比较Polyline的OID</param>
        /// <param name="featureClass">要素类</param>
        private double GetPolylineAngle(int id1, int id2, IFeatureClass featureClass)
        {
            Posi IItoI = GetRel(id1, id2, featureClass);
            Posi ItoII = GetRel(id2, id1, featureClass);

            double[]           v1  = null;
            double[]           v2  = null;
            ISegmentCollection sc1 = featureClass.GetFeature(id1).ShapeCopy as ISegmentCollection;
            ISegmentCollection sc2 = featureClass.GetFeature(id2).ShapeCopy as ISegmentCollection;

            if (IItoI == Posi.FROM)
            {
                ISegment seg = sc1.get_Segment(0);
                v1 = new double[2] {
                    seg.ToPoint.X - seg.FromPoint.X, seg.ToPoint.Y - seg.FromPoint.Y
                };
            }
            else
            {
                ISegment seg = sc1.get_Segment(sc1.SegmentCount - 1);
                v1 = new double[2] {
                    seg.FromPoint.X - seg.ToPoint.X, seg.FromPoint.Y - seg.ToPoint.Y
                };
            }

            if (ItoII == Posi.FROM)
            {
                ISegment seg = sc2.get_Segment(0);
                v2 = new double[2] {
                    seg.ToPoint.X - seg.FromPoint.X, seg.ToPoint.Y - seg.FromPoint.Y
                };
            }
            else
            {
                ISegment seg = sc2.get_Segment(sc2.SegmentCount - 1);
                v2 = new double[2] {
                    seg.FromPoint.X - seg.ToPoint.X, seg.FromPoint.Y - seg.ToPoint.Y
                };
            }

            return(getVetorAngle(v1, v2));
        }
Пример #27
0
        private void InitBrokePoint()
        {
            int userClassID;
            int userID;
            int userSubID;
            IFeatureClassContainer featureDataset =
                (IFeatureClassContainer)this._nearestEdgeInfo.GeometricNetwork.FeatureDataset;
            IFeatureClass pointClass = null;
            IFeatureClass lineClass  = null;
            int           num3       = 0;


            pointClass = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0].FeatureClass;
            lineClass  = _pipeLayer.GetLayers(enumPipelineDataType.Line)[0].FeatureClass;
            this._networkInfo.LayerLine =
                MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)lineClass).Name, false) as
                IFeatureLayer;
            this._networkInfo.LayerPoint =
                MapHelper.FindFeatureLayerByFCName(m_iApp.FocusMap as IBasicMap, ((IDataset)pointClass).Name, false) as
                IFeatureLayer;
            INetElements network = (INetElements)this._nearestEdgeInfo.GeometricNetwork.Network;

            network.QueryIDs(this._nearestEdgeInfo.EdgeID, esriElementType.esriETEdge, out userClassID, out userID,
                             out userSubID);
            this._networkInfo.LineFeature = lineClass.GetFeature(userID);
            Label label = this.lblPickPipeInfo;

            string[] name = new string[]
            { this._networkInfo.LayerLine.Name, ",", lineClass.OIDFieldName, "=", userID.ToString() };
            label.Text = string.Concat(name);
            string.Format("\r\n爆管点位置({0:f2},{1:f2},{2:f2})", this._nearestEdgeInfo.Location.X,
                          this._nearestEdgeInfo.Location.Y, this._nearestEdgeInfo.Location.Z);

            //初始化下拉菜单

            cmbDomainValues.Items.Clear();
            IBasicLayerInfo pLayerInfo = _pipeLayer.GetLayers(enumPipelineDataType.Point)[0];
            IYTField        pField     = pLayerInfo.GetField(PipeConfigWordHelper.PointWords.FSW);

            this.label1.Text = pField.Name;
            if (!string.IsNullOrEmpty(pField.DomainValues))
            {
                string[] domianValues = pField.DomainValues.Split('/');
                foreach (var onePair in domianValues)
                {
                    cmbDomainValues.Items.Add(onePair);
                }
            }
            if (this.listFieldValues.Items.Count == 0)
            {
                this.listFieldValues.Items.Add("阀门");
                this.listFieldValues.Items.Add("阀门井");
            }
        }
        private void BuildFileList()
        {
            _fileList.Clear();

            IFeatureLayer featureLayer = ((CustomLayer)cbo_layers.SelectedItem).FeatureLayer();
            IFeatureClass featureClass = ((CustomLayer)cbo_layers.SelectedItem).FeatureClass();


            if (rb_all.Checked)
            {
                IFeatureCursor cursor     = featureClass.Search(null, false);
                IFields        fields     = cursor.Fields;
                int            fieldIndex = _utilitiesArcMap.FindField(featureClass, cbo_fieldname.Text);

                IFeature feature = cursor.NextFeature();

                while (feature != null)
                {
                    //string fileName = Utilities.Utilities_General.AddPrefixAndSuffixToFileName(Convert.ToString(feature.get_Value(fieldIndex)), txb_prefix.Text, txb_suffix.Text);
                    string fileName = Convert.ToString(feature.get_Value(fieldIndex));
                    if (!_fileList.ContainsKey(fileName))
                    {
                        _fileList.Add(fileName, false);
                    }

                    feature = cursor.NextFeature();
                }
            }

            if (rb_selected.Checked)
            {
                IFeatureSelection selection = featureLayer as IFeatureSelection;
                IEnumIDs          IDs       = selection.SelectionSet.IDs;
                IDs.Reset();

                int oid = IDs.Next();

                while (oid != -1)
                {
                    IFeature feature = featureClass.GetFeature(oid);
                    if (feature != null)
                    {
                        int    fieldIndex = _utilitiesArcMap.FindField(featureClass, cbo_fieldname.Text);
                        string fileName   = Convert.ToString(feature.get_Value(fieldIndex));
                        if (!_fileList.ContainsKey(fileName))
                        {
                            _fileList.Add(fileName, false);
                        }

                        oid = IDs.Next();
                    }
                }
            }
        }
Пример #29
0
        public static bool DeleteError(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IFeatureClass        class2           = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            esriTopologyRuleType topologyRuleType = pTopoErrorFeat.TopologyRuleType;

            if (topologyRuleType != esriTopologyRuleType.esriTRTPointProperlyInsideArea)
            {
                if (topologyRuleType != esriTopologyRuleType.esriTRTPointCoveredByLineEndpoint)
                {
                    return(false);
                }
            }
            else
            {
                class2.GetFeature(pTopoErrorFeat.OriginOID).Delete();
                return(true);
            }
            class2.GetFeature(pTopoErrorFeat.OriginOID).Delete();
            return(true);
        }
Пример #30
0
        private IPointCollection Convert_Point2MultiPoint(IFeatureClass PointFeatureClass)
        {
            IPointCollection pPointCollection = new MultipointClass();

            for (int i = 0; i < PointFeatureClass.FeatureCount(null); i++)
            {
                IFeature pFeature = PointFeatureClass.GetFeature(i);
                IPoint   pPoint   = pFeature.Shape as IPoint;
                pPointCollection.AddPoint(pPoint);
            }
            return(pPointCollection);
        }
Пример #31
0
        /// <summary>
        /// 获取历史记录列表
        /// </summary>
        /// <param name="fid">要获取历史记录的要素</param>
        /// <param name="fc"></param>
        /// <param name="historyFC"></param>
        /// <returns>历史记录列表,每一个值都是objectid,而不是道路编号</returns>
        public static List<int> GetHistoryList(int fid, IFeatureClass fc, IFeatureClass historyFC)
        {
            var f = fc.GetFeature(fid);
            if (f == null) return null;

            var historyList = new List<int>();
            var o = f.get_Value(f.Fields.FindField(ParentIDFieldName));
            if (o == null || o == DBNull.Value) return historyList;

            var parentNo = Convert.ToInt32(o);
            int id;
            while(parentNo != -1)
            {
                parentNo = GetParentNo(parentNo, historyFC, out id);
                if (id != -1) historyList.Add(id);
            }
            return historyList;
        }
Пример #32
0
        /// <summary>
        /// Geocodes a table of addresses
        /// </summary>
        /// <param name="addressTable">Input address table</param>
        /// <param name="addressFieldNames">Fields defined in the table</param>
        /// <param name="whereClause">Query filter where clause</param>
        /// <param name="outputFeatureClass">Output feature class for matched addresses</param>
        /// <param name="outputFieldNames">Output field names</param>
        /// <param name="fieldsToCopy"></param>
        /// <param name="cancelTracker"></param>
        public virtual void MatchTable(ITable addressTable, String addressFieldNames, String whereClause,
          IFeatureClass outputFeatureClass, String outputFieldNames, IPropertySet fieldsToCopy, ITrackCancel cancelTracker)
        {
            _log.Debug("IAddressGeocoding MatchTable");

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

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

              int count = addressTable.RowCount(queryFilter);

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

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

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

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

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

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

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

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

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

              resultSet = MatchAddress(addressProperties);

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

              // Output match fields and values
              // Insert the Feature into the output featureClass and get the next row
              if (m_needToUpdate)
              {
                  _log.Debug("IAddressGeocoding Updating Feature" + row.OID.ToString());

                  // Record is being rematched so find record to update
                  IFeature feature = outputFeatureClass.GetFeature(row.OID);

                  for (int i = 0; i < names.Length; i++)
                  {
                      if (names[i] == "Shape")
                          feature.Shape = items[i] as IGeometry;
                      else
                      {
                          if (names[i] == "Status")
                          {
                              matchStatus = items[i] as string;
                              feature.set_Value(outputFeatureClass.FindField(names[i]), items[i]);
                          }
                      }
                  }

                  // Set the match type
                  if (outputFeatureClass.FindField("Match_type") != -1)
                  {
                      feature.set_Value(outputFeatureClass.FindField("Match_type"), "A");
                  }

                  // Copy over values from address table
                  for (int j = 0; j < copyToArray.Length; j++)
                  {
                      feature.set_Value(outputFeatureClass.FindField(copyToArray[j]),
                      row.get_Value(addressTable.FindField(copyFromArray[j] as string)));
                  }

                  updateCursor.UpdateFeature(feature);
              }
              else
              {
                  // set shape and status of matched record
                  for (int i = 0; i < names.Length; i++)
                  {
                      if (names[i] == "Shape")
                          featureBuffer.Shape = items[i] as IGeometry;
                      else
                      {
                          if (names[i] == "Status")
                          matchStatus = items[i] as string;
                          featureBuffer.set_Value(outputFeatureClass.FindField(names[i]), items[i]);
                      }
                  }

                  // Set the match type
                  if (outputFeatureClass.FindField("Match_type") != -1)
                  {
                      featureBuffer.set_Value(outputFeatureClass.FindField("Match_type"), "A");
                  }

                  // Copy over values from address table
                  for (int j = 0; j < copyToArray.Length; j++)
                  {
                      try
                      {
                          featureBuffer.set_Value(outputFeatureClass.FindField(copyToArray[j]),
                              row.get_Value(addressTable.FindField(copyFromArray[j] as string)));
                      }
                      catch (Exception ex)
                      {
                          _log.Error("An error occurred copying values from the address table: " + ex.Message);
                      }
                  }

                  insertCursor.InsertFeature(featureBuffer);
              }

              row = readCursor.NextRow();

              // Update the MatchTable progress
              if (progStats != null)
              {
                  progStats.StepByValue(matchStatus);
                  progStats.Update();
              }
              if (cancelTracker != null)
              {
                  if (!cancelTracker.Continue())
                      break;
              }
              }

              _log.Debug("IAddressGeocoding MatchTable End of updating features.");

              // Clean up the cursors
              if (insertCursor != null)
              {
              insertCursor.Flush();
              Marshal.ReleaseComObject(insertCursor);
              }
              if (updateCursor != null)
              {
              updateCursor.Flush();
              Marshal.ReleaseComObject(updateCursor);
              }
              if (readCursor != null)
              Marshal.ReleaseComObject(readCursor);
        }
        private bool updatePolygon(IFeatureClass ftrCls,int oid)
        {
            bool x = false;
            IGeometry geo = ftrCls.GetFeature(oid).ShapeCopy;
            ISpatialFilter spFlt = new SpatialFilterClass();
            spFlt.WhereClause = ftrCls.OIDFieldName + " <> " + oid.ToString();
            spFlt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IQueryFilterDefinition2 qryDef2 = (IQueryFilterDefinition2)spFlt;
            qryDef2.PostfixClause = "Order by Shape_Area DESC";
            spFlt.Geometry = geo;
            spFlt.GeometryField = ftrCls.ShapeFieldName;
            spFlt.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;
            IFeatureCursor ftrCur = ftrCls.Search(spFlt, false);
            int shapeAreaIndex = ftrCur.FindField("Shape_Area");
            IFeature ftr = ftrCur.NextFeature();
            while (ftr!=null)
            {
                IGeometry geoMax = ftr.ShapeCopy;
                int beforeCnt = ((IGeometryCollection)geoMax).GeometryCount;
                ITopologicalOperator4 tp = (ITopologicalOperator4)geoMax;
                IGeometry uGeo = tp.Union(geo);
                int afterCnt = ((IGeometryCollection)uGeo).GeometryCount;
                if (beforeCnt >= afterCnt)
                {
                    try
                    {
                        ftr.Shape = uGeo;
                        if (shapeAreaEdit)
                        {
                            ftr.set_Value(shapeAreaIndex, ((IArea)uGeo).Area);
                        }
                        ftr.Store();
                        x = true;
                        return x;
                    }
                    catch (Exception e)
                    {
                        x = false;
                        Console.WriteLine(e.ToString());
                        return x;
                    }

                }
                ftr = ftrCur.NextFeature();
            }
            return x;
        }
Пример #34
0
        private List<double> overlapStandard(IFeatureClass featureClass, string targetLayerName)
        {
            List<double> overlapList = new List<double>();
            IFeatureClass targetFeatureClass = GisUtil.getFeatureClass(mapFolder, targetLayerName);
            for (int i = 0; i < featureClass.FeatureCount(null); i++)
            {
                IFeature feature = featureClass.GetFeature(i);
                IGeometry geometry = feature.ShapeCopy;
                geometry.SpatialReference = mapControl.SpatialReference;
                ITopologicalOperator tpOp = geometry as ITopologicalOperator;
                IArea area = geometry as IArea;
                ISpatialFilter cityFilter = new SpatialFilterClass();
                cityFilter.Geometry = geometry;
                cityFilter.GeometryField = "SHAPE";
                cityFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor feaCursor = targetFeatureClass.Search(cityFilter, false);

                //获取所有与该块相交的要素, 然后检测其相交的面积, 依照比例计算最终的值.
                IFeature cityFea = feaCursor.NextFeature();
                double overlap = 0;
                while (cityFea != null)
                {
                    if (cityFea != null)
                    {
                        IGeometry intersectedGeom = tpOp.Intersect(cityFea.ShapeCopy, esriGeometryDimension.esriGeometry2Dimension);
                        IArea intersectedGeomArea = intersectedGeom as IArea;
                        //获取gridcode.
                        ITable table = cityFea.Table;
                        IRow row = table.GetRow(0);
                        int fieldNum = table.FindField("GRIDCODE");
                        double value = (double)cityFea.get_Value(fieldNum);
                        overlap = overlap + value * (intersectedGeomArea.Area / area.Area);
                    }
                    cityFea = feaCursor.NextFeature();
                }
                overlapList.Add(overlap);
            }
            return overlapList;
        }
Пример #35
0
        public static void UpdateRoads(List<RoadCrossInfo> lines, IFeatureClass fc, IFeatureClass historyFC, IFeatureClass crossFC, out List<string> newRoadIds, out Dictionary<string, string> oldRoadNewIds)
        {
            RemoveDisabledRoads(lines);
            CutFragments(lines);
            var now = DateTime.Now;
            newRoadIds = new List<string>();
            // 添加新路线
            foreach(var line in lines)
            {
                var ls = SplitLine(line.Geometry, line.Crossings.Select(x => x.Crossing).ToList());
                var ret = StoreNewRoads(ls, fc, crossFC, now);
                newRoadIds.AddRange(ret);
            }

            // 按照老路线归类交点
            var dict = new Dictionary<int, List<IPoint>>();
            var dict2 = new Dictionary<int, IPolyline>();
            foreach(var line in lines)
            {
                foreach(var cross in line.Crossings)
                {
                    if (dict.ContainsKey(cross.Road.Id) == false)
                    {
                        dict.Add(cross.Road.Id, new List<IPoint>());
                        dict2.Add(cross.Road.Id, cross.Road.Geometry);
                    }

                    dict[cross.Road.Id].Add(cross.Crossing);
                }
            }
            oldRoadNewIds = new Dictionary<string, string>();
            foreach(var pair in dict)
            {
                var id = pair.Key;
                var f = fc.GetFeature(id);
                Archive(f, historyFC);
                var ls = SplitLine(dict2[id], pair.Value);

                var ret = StoreOldRoads(ls, f, fc, crossFC, now);
                foreach(var p in ret)
                {
                    oldRoadNewIds.Add(p.Key, p.Value);
                }
            }
        }
Пример #36
0
        /// <summary>
        /// ����λ�ڻ������еĵ�Ҫ��- ʹ��ISpatialFilter
        /// </summary>
        /// <param name="ipPtFeaCls">��ͼ��</param>
        /// <param name="ipBufferFeaCls">������ͼ��</param>
        /// <returns></returns>
        private bool SearchSpatialFilter(IFeatureClass ipPtFeaCls,
                                         IFeatureClass ipBufferFeaCls)
        {
            if (ipBufferFeaCls == null || ipPtFeaCls == null) return false;

            ISpatialFilter pSpatialFilter = new SpatialFilterClass(); //(CLSID_SpatialFilter);

            // 1. ���ÿռ��ϵ
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;

            // 2.���ù��˼���
            string shapeFieldName = ipPtFeaCls.ShapeFieldName;
            pSpatialFilter.GeometryField = shapeFieldName;

            // ���cursor
            IFeatureCursor ipResultFtCur = null;

            // ����Դͼ��Ҫ��
            IFeatureCursor ipFeatCursor;
            IFeature ipFeature;

            IQueryFilter pQueryFilter = new QueryFilterClass(); //(CLSID_QueryFilter);
            string SubFields = "OID,Shape";
            pQueryFilter.SubFields = SubFields;
            ipFeatCursor = ipBufferFeaCls.Search(pQueryFilter, true);
            ipFeature = ipFeatCursor.NextFeature();

            m_aryResult = new List<PointDistInfo>();
            while (ipFeature != null)
            {
                IGeometry ipGeometry1, ipGeometry2;
                int OID1, OID2;
                ipGeometry1 = ipFeature.Shape;
                OID1 = ipFeature.OID;

                if (ipGeometry1 == null)
                {
                    ipFeature = ipFeatCursor.NextFeature();
                    continue;
                }

                pSpatialFilter.Geometry = ipGeometry1;

                if (ipResultFtCur != null)
                {
                    Marshal.ReleaseComObject(ipResultFtCur);
                }
                ipResultFtCur = ipPtFeaCls.Search(pSpatialFilter, true);

                // ��ӵ��������
                if (ipResultFtCur == null)
                {
                    ipFeature = ipFeatCursor.NextFeature();
                    continue;
                }

                IFeature ipResFeature = ipResultFtCur.NextFeature();

                while (ipResFeature != null)
                {
                    OID2 = ipResFeature.OID;

                    // ID��ͬ��˵����ͬһ���㡣ID1:��������ID2:�����ڻ������еĵ�
                    if (OID1 == OID2)
                    {
                        ipResFeature = ipResultFtCur.NextFeature();
                        continue;
                    }

                    // ��ҽ����¼
                    PointDistInfo PtInfo;
                    // OID1
                    PtInfo.OID1 = OID1;
                    // OID2
                    PtInfo.OID2 = OID2;

                    IFeature ipFeat = null;
                    //if (OID1 == 58)
                    //{
                    //   //XtraMessageBox.Show("RulePointDist:SearchSpatialFiler :OIDΪ58�ĵ����޷���ȡ������ԭ��");
                    //   break;

                    //}

                    try
                    {
                        ipFeat = ipPtFeaCls.GetFeature(OID1);
                    }
                    catch (Exception ex)
                    {
                        SendMessage(enumMessageType.Exception, "��ȡҪ�س����"+ex.ToString());
                        break;
                    }

                    if (ipFeat != null)
                    {
                        IGeometry ipPtGeo1 = ipFeat.Shape;
                        ipGeometry2 = ipResFeature.Shape;

                        // ����
                        PtInfo.dDistance = CalDist(ipPtGeo1, ipGeometry2);

                        // �Ƿ������ͬ�㣬���Ƿ���Ӿ���Ϊ0�ĵ�
                        if (m_pPara.bSearchSamePt ||
                            (!m_pPara.bSearchSamePt && PtInfo.dDistance != 0))
                        {
                            m_aryResult.Add(PtInfo);
                        }
                    }

                    ipResFeature = ipResultFtCur.NextFeature();
                }

                ipFeature = ipFeatCursor.NextFeature();
            }

            return true;
        }
Пример #37
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ipPtFeaCls"></param>
        /// <returns></returns>
        private bool SearchPoints(IFeatureClass ipPtFeaCls)
        {
            if (ipPtFeaCls == null) return false;
            try
            {
                // ����Դͼ��Ҫ��
                IQueryFilter ipQuery = new QueryFilterClass();
                ipQuery.SubFields = "OBJECTID,Shape,BSM";
                IFeatureCursor ipFeatCursor = ipPtFeaCls.Search(ipQuery, true);
                IFeature ipFeature = ipFeatCursor.NextFeature();

                IGeometry ipGeometry = null;
                int OID1 = -1;
                m_aryResult = new List<PointDistInfo>();
                int iDecimal = 0;

                int iParmer = GetParameter(m_pPara.dPointDist, out iDecimal);
                while (ipFeature != null)
                {
                    ipGeometry = ipFeature.Shape;
                    OID1 = ipFeature.OID;
                    if (ipGeometry == null)
                    {
                        ipFeature = ipFeatCursor.NextFeature();
                        continue;
                    }
                    else
                    {
                        if (ipGeometry.GeometryType == esriGeometryType.esriGeometryPoint ||
                            ipGeometry.GeometryType == esriGeometryType.esriGeometryMultipoint)
                        {
                            IPoint ipT = (IPoint)ipGeometry;
                            int dx = Convert.ToInt32(Math.Round(ipT.X, iDecimal) * iParmer);
                            int dy = Convert.ToInt32(Math.Round(ipT.Y, iDecimal) * iParmer);
                            string str = dx.ToString() + "_" + dy.ToString();
                            if (!m_PointtoOID.Contains(str))
                            //����һhashtable���Ե�ġ�x_y��������ɵ��ַ���Ϊkey�������У�x��y��ȡһλС����������������IJ�������"<=0.1"��Ч,�����x_y��keyֵ��ͬ������������϶�>=0.1
                            {
                                m_PointtoOID.Add(str, OID1);
                            }
                            else
                            {
                                object OID = m_PointtoOID[str];
                                IFeature OriginFeature = ipPtFeaCls.GetFeature((int)OID);
                                IPoint OriginPoint = (IPoint)OriginFeature.Shape;
                                // ��������
                                double dDist = (ipT.X - OriginPoint.X) * (ipT.X - OriginPoint.X) +
                                               (ipT.Y - OriginPoint.Y) * (ipT.Y - OriginPoint.Y);
                                ///���Ҵ�������
                                if ((int)OID != OID1 && Math.Round(Math.Sqrt(dDist), 2) < m_pPara.dPointDist)
                                {
                                    //m_OIDtoOID.Add(OID1, OID);

                                    if (!m_RepeatOIDtoOID.Contains(str))
                                    {
                                        string strTemp = OID1.ToString();
                                        m_RepeatOIDtoOID.Add(str, strTemp);
                                    }
                                    else
                                    {
                                        string strTemp = m_RepeatOIDtoOID[str].ToString() + "," + OID1;
                                        m_RepeatOIDtoOID[str] = strTemp;
                                    }

                                    //// ��ҽ����¼
                                    //PointDistInfo PtInfo = new PointDistInfo();

                                    //PtInfo.dDistance = Math.Round(Math.Sqrt(dDist), 2);

                                    //PtInfo.OID1 = Convert.ToInt32(OID1);
                                    //PtInfo.OID2 = Convert.ToInt32(OID);

                                    //m_aryResult.Add(PtInfo);
                                }
                            }
                        }
                    }
                    ipFeature = ipFeatCursor.NextFeature();
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
Пример #38
0
    public static void DeleteFeature(IFeatureClass theFC, int OID)
    {
      try
      {
        IFeature theNF = theFC.GetFeature(OID);

        if (theNF != null) { theNF.Delete(); }
      }
      catch (Exception ex) { }
    }
Пример #39
0
        internal static string retrieveNodeID(IFeatureClass pointFeatureClass, int osmIDPointFieldIndex, int extensionVersion, IPoint pointGeometry)
        {
            string nodeID = string.Empty;

            if (pointGeometry == null)
                return String.Empty;

            if (pointGeometry.IsEmpty)
                return String.Empty;

            if (((IPointIDAware)pointGeometry).PointIDAware == false)
            {
                return nodeID;
            }
            if (extensionVersion == 1)
            {
                nodeID = Convert.ToString(pointGeometry.ID);
            }
            else if (extensionVersion == 2)
            {
                IFeature pointFeature = null;
                try
                {
                    pointFeature = pointFeatureClass.GetFeature(pointGeometry.ID);
                }
                catch { }
                if (pointFeature != null)
                {
                    if (osmIDPointFieldIndex > -1)
                    {
                        nodeID = Convert.ToString(pointFeature.get_Value(osmIDPointFieldIndex));
                    }
                }
                Marshal.ReleaseComObject(pointFeature);
            }
            return nodeID;
        }
Пример #40
0
 private void DrawSelectResult(IFeatureClass fishnetFeaCls)
 {
     //第八, 按不同的成绩用不同的颜色画方块.
     for (int i = 0; i < featureList.Count; i++)
     {
         if (((Feature)featureList[i]).inUse == 1)
         {
             GisUtil.drawPolygonByScore(fishnetFeaCls.GetFeature(i).ShapeCopy, ((Feature)featureList[i]).score, mapControl);
         }
         else
         {
             GisUtil.drawPolygonByScore(fishnetFeaCls.GetFeature(i).ShapeCopy, 0, mapControl);
         }
     }
 }
Пример #41
0
        private bool ProcessLayer(
			string layerKey,
			IFeatureClass workingFC,
			IFeatureClass editsFC,
			IFeatureClass pristineFC,
			IPolygon seeBounds,
			double shiftLimit)
        {
            if (workingFC == null
                || editsFC == null
                || pristineFC == null
                || seeBounds == null
                || seeBounds.IsEmpty == true)
            {
                this.LogMessage("Bad arguments passed to ProcessLayer");
                return false;
            }

            // Loop through Inserts, Updates, Deletes
            IFeatureCursor theInsCursor = null;
            IFeatureCursor theUpdCursor = null;
            IFeatureCursor theDelCursor = null;

            int workingOID = -1;
            int pristineOID = -1;

            try
            {
                string theTxID = this.TxID;

                theInsCursor = this._eDao.getInserts(layerKey);
                theUpdCursor = this._eDao.getUpdates(layerKey);
                theDelCursor = this._eDao.getDeletes(layerKey);

                IFeature theWorkingFeature = null;
                IFeature thePristineFeature = null;

                string[] pks = new String[1] { workingFC.Fields.get_Field(0).Name }; //this._tmConfig.get_LayerConfig(layerKey).Keys;
                IQueryFilter thePKFilter = null;

                IFeature theEditIndicator = theInsCursor.NextFeature();
                while (theEditIndicator != null)
                {
                    thePKFilter = DAOUtils.setupFilter(theEditIndicator, pks);

                    if (thePKFilter != null)
                    {
                        // Pass working feature, no original feature
                        int idx = theEditIndicator.Fields.FindField(EditsDAO.EDIT_OID_LOG);
                        int oid = Convert.ToInt32(theEditIndicator.get_Value(idx));
                        theWorkingFeature = workingFC.GetFeature(oid);
                        this.LogMessage("Checking insert " + theEditIndicator.OID + ". Biz Where clause: " + thePKFilter.WhereClause);
                        this.LogMessage("Working OID: " + oid + " Null? " + Convert.ToString(theWorkingFeature == null));
                        workingOID = oid;
                        thePristineFeature = null;
                        pristineOID = -1;

                        this.EvaluateEditInSee(theWorkingFeature, thePristineFeature, seeBounds, theTxID, thePKFilter.WhereClause, shiftLimit);
                    }
                    else
                    {
                        this.CreateMissingPKError(theEditIndicator, pks, "insert");
                    }
                    theEditIndicator = theInsCursor.NextFeature();
                }

                theEditIndicator = theUpdCursor.NextFeature();
                while (theEditIndicator != null)
                {
                    thePKFilter = DAOUtils.setupFilter(theEditIndicator, pks);

                    if (thePKFilter != null)
                    {
                        // Pass working feature, pristine feature
                        int idx = theEditIndicator.Fields.FindField(EditsDAO.EDIT_OID_LOG);
                        int oid = Convert.ToInt32(theEditIndicator.get_Value(idx));
                        theWorkingFeature = workingFC.GetFeature(oid);
                        this.LogMessage("Checking update " + theEditIndicator.OID + ". Biz Where clause: " + thePKFilter.WhereClause);
                        this.LogMessage("Working OID: " + oid + " Null? " + Convert.ToString(theWorkingFeature == null));
                        workingOID = oid;

                        thePristineFeature = null;
                        IFeatureCursor thePristineCursor = null;

                        try
                        {
                            thePristineCursor = pristineFC.Search(thePKFilter, false);
                            thePristineFeature = thePristineCursor.NextFeature();
                            pristineOID = thePristineFeature.OID;
                        }
                        catch (Exception)
                        { }
                        finally
                        {
                            if (thePristineCursor != null)
                            {
                                Marshal.ReleaseComObject(thePristineCursor);
                            }
                        }

                        this.LogMessage("Pristine OID: " + pristineOID + " Null? " + Convert.ToString(thePristineFeature == null));

                        this.EvaluateEditInSee(theWorkingFeature, thePristineFeature, seeBounds, theTxID, thePKFilter.WhereClause, shiftLimit);
                    }
                    else
                    {
                        this.CreateMissingPKError(theEditIndicator, pks, "update");
                    }
                    theEditIndicator = theUpdCursor.NextFeature();
                }

                theEditIndicator = theDelCursor.NextFeature();
                while (theEditIndicator != null)
                {
                    thePKFilter = DAOUtils.setupFilter(theEditIndicator, pks);

                    if (thePKFilter != null)
                    {
                        // Pass no working feature, pristine feature
                        thePristineFeature = null;
                        IFeatureCursor thePristineCursor = null;
                        this.LogMessage("Checking delete " + theEditIndicator.OID + ". Biz Where clause: " + thePKFilter.WhereClause);
                        theWorkingFeature = null;
                        workingOID = -1;

                        try
                        {
                            thePristineCursor = pristineFC.Search(thePKFilter, false);
                            thePristineFeature = thePristineCursor.NextFeature();
                            pristineOID = thePristineFeature.OID;
                        }
                        catch (Exception)
                        { }
                        finally
                        {
                            if (thePristineCursor != null)
                            {
                                Marshal.ReleaseComObject(thePristineCursor);
                            }
                        }

                        this.LogMessage("Pristine OID: " + pristineOID + " Null? " + Convert.ToString(thePristineFeature == null));

                        this.EvaluateEditInSee(theWorkingFeature, thePristineFeature, seeBounds, theTxID, thePKFilter.WhereClause, shiftLimit);
                    }
                    else
                    {
                        this.CreateMissingPKError(theEditIndicator, pks, "delete");
                    }
                    theEditIndicator = theDelCursor.NextFeature();
                }
            }
            catch (Exception ex)
            {
                this.LogMessage("Error raised while checking edits for layer " + layerKey + " working OID: " + workingOID + " pristine OID: " + pristineOID + Environment.NewLine +
                    ex.Message + Environment.NewLine + ex.StackTrace);
                return false;
            }
            finally
            {
                if (theInsCursor != null)
                    Marshal.ReleaseComObject(theInsCursor);
                if (theUpdCursor != null)
                    Marshal.ReleaseComObject(theUpdCursor);
                if (theDelCursor != null)
                    Marshal.ReleaseComObject(theDelCursor);
            }
            return true;
        }
Пример #42
0
        private List<double> IntersectRestraint(IFeatureClass featureClass, string targetLayerName)
        {
            List<double> ratioList = new List<double>();
            IFeatureClass targetFeatureClass = GisUtil.getFeatureClass(mapFolder, targetLayerName);
            List<IGeometry> geometryList = new List<IGeometry>();
            for (int i = 0; i < targetFeatureClass.FeatureCount(null); i++)
            {
                geometryList.Add(targetFeatureClass.GetFeature(i).Shape);
            }
            IGeometry geometry = GisUtil.unionAllFeature(geometryList); //e0图层所有的几何图形.
            ITopologicalOperator toOp = geometry as ITopologicalOperator;

            for (int i = 0; i < featureClass.FeatureCount(null); i++)
            {
                IFeature feature = featureClass.GetFeature(i);
                IGeometry srcGeom = feature.ShapeCopy;
                srcGeom.SpatialReference = mapControl.SpatialReference;
                IGeometry intersectedGeom = toOp.Intersect(srcGeom, esriGeometryDimension.esriGeometry2Dimension);
                //测量相交图形的面积, 超过原图形的一半, 有效.
                IArea area = intersectedGeom as IArea;
                IArea srcArea = srcGeom as IArea;
                double ratio = (area.Area / srcArea.Area) * 100;
                ratioList.Add(ratio);
            }
            return ratioList;
        }
Пример #43
0
        public void Store(IFeatureClass exceptionFC)
        {
            IFeatureBuffer theFBuffer;

            // New exceptions need to be inserted
            if (this.ObjectID == -1)
            {
                theFBuffer = exceptionFC.CreateFeatureBuffer();
            }
            else
            {
                theFBuffer = (IFeatureBuffer)exceptionFC.GetFeature(this.ObjectID);
            }

            int idx;
            idx = theFBuffer.Fields.FindField("ATTACHMENT");
            theFBuffer.set_Value(idx, this._attachment);

            //idx = theFBuffer.Fields.FindField("DATA_EXCEPTION_POINT_ID");
            //theFBuffer.set_Value(idx, {populated by trigger});

            idx = theFBuffer.Fields.FindField("DATA_EXCEPTION_STATUS");
            theFBuffer.set_Value(idx, this._status);

            idx = theFBuffer.Fields.FindField("EXCEPTION_DESCRIPTION");
            theFBuffer.set_Value(idx, this._description);

            idx = theFBuffer.Fields.FindField("LATITUDE");
            theFBuffer.set_Value(idx, this._location.Y);

            idx = theFBuffer.Fields.FindField("LONGITUDE");
            theFBuffer.set_Value(idx, this._location.X);

            idx = theFBuffer.Fields.FindField("OPERATIONAL_DATASET_NAME");
            theFBuffer.set_Value(idx, this._operationDSName);

            idx = theFBuffer.Fields.FindField("QA_TEST_NAME");
            theFBuffer.set_Value(idx, this._testName);

            // Shape
            theFBuffer.Shape = this._location;

            if (this.ObjectID == -1)
            {
                ICursor theInsertCursor = ((ITable)exceptionFC).Insert(false);
                this._objectID = (int)theInsertCursor.InsertRow(theFBuffer);
                theInsertCursor.Flush();

                Marshal.ReleaseComObject(theInsertCursor);
            }
            else
            {
                ((IFeature)theFBuffer).Store();
            }
        }
Пример #44
0
        private static List<CrossroadInfo> TransformToCrossroadInfo(Dictionary<int, List<IPoint>> dict, IFeatureClass fc)
        {
            var ret = new List<CrossroadInfo>();
            foreach(var pair in dict)
            {
                var f = fc.GetFeature(pair.Key);

                var name = f.get_Value(f.Fields.FindField("NAME")).ToString();
                var no = Convert.ToInt32(f.get_Value(f.Fields.FindField("NO_")));

                foreach(var pt in pair.Value)
                {
                    ret.Add(new CrossroadInfo{
                        Name=name,
                        NO=no,
                        Point=pt,
                        OID=pair.Key
                    });
                }
            }
            return ret;
        }
Пример #45
0
        public static List<int> SplitPolyline(int oid, List<IPoint> pts, IFeatureClass fc)
        {
            var f = fc.GetFeature(oid);

            var geo = f.ShapeCopy as IPolyline;
            var ret = new List<int>();

            var lines = SplitPolylineInner(geo, pts);

            if (lines.Count < 2) return ret ;

            var cursor = fc.Insert(true);
            var idIndex = cursor.FindField(IDField);
            var id = GetNewId(fc);
            foreach(var line in lines)
            {
                var buff = fc.CreateFeatureBuffer();
                ret.Add(id);
                buff.set_Value(idIndex, id);
                buff.Shape = line;
                CopyFields(f, buff);
                cursor.InsertFeature(buff);
                cursor.Flush();
                id++;
            }

            Marshal.ReleaseComObject(cursor);
            f.Delete();
            return ret;
        }
Пример #46
0
        private List<double> distanceStandard(IFeatureClass featureClass, string targetLayerName)
        {
            List<double> distanceList = new List<double>();
            IFeatureClass targetFeatureClass = GisUtil.getFeatureClass(mapFolder, targetLayerName);
            //将所有的geometry放入一个arraylist.
            List<IGeometry> geometryList = new List<IGeometry>();
            for (int i = 0; i < targetFeatureClass.FeatureCount(null); i++)
            {
                geometryList.Add(targetFeatureClass.GetFeature(i).ShapeCopy);
            }
            IGeometry geometry = GisUtil.unionAllFeature(geometryList);
            IProximityOperator proOp = geometry as IProximityOperator;

            //求到路的距离.
            for (int i = 0; i < featureClass.FeatureCount(null); i++)
            {
                IFeature fea = featureClass.GetFeature(i);
                IGeometry geom = fea.ShapeCopy;
                geom.SpatialReference = mapControl.SpatialReference;
                double distance = proOp.ReturnDistance(geom);
                distanceList.Add(distance);
            }
            return distanceList;
        }