Ejemplo n.º 1
0
        public List <FeatureItem> Check(IFeatureClass featureClass, string pipelineName, string xFieldName, string yFieldName, string zFieldName)
        {
            List <FeatureItem> list = new List <FeatureItem>();
            int xIdx = featureClass.FindField(xFieldName);
            int yIdx = featureClass.FindField(yFieldName);
            int zIdx = featureClass.FindField(zFieldName);

            if (xIdx < 0 || yIdx < 0 || zIdx < 0)
            {
                list.Add(new FeatureItem()
                {
                    PipelineName  = pipelineName,
                    PipeLayerName = featureClass.AliasName,
                    CheckItem     = "坐标信息检查",
                    ErrDesc       = "字段配置错误 字段 " + (xIdx < 0 ? xFieldName + " " : "") + (yIdx < 0 ? yFieldName + " " : "") + (zIdx < 0 ? zFieldName + " " : "") + "不存在",
                });
                return(list);
            }
            bool           hasZ          = FeatureClassUtil.CheckHasZ(featureClass);
            IFeatureCursor featureCursor = featureClass.Search(null, false);
            IFeature       feature;

            while ((feature = featureCursor.NextFeature()) != null)
            {
                if (_worker != null && _worker.CancellationPending)
                {
                    return(list);
                }
                IPoint point = feature.Shape as IPoint;
                if (point == null || point.IsEmpty)
                {
                    list.Add(new FeatureItem(feature)
                    {
                        PipelineName  = pipelineName,
                        PipeLayerName = featureClass.AliasName,
                        CheckItem     = "坐标信息检查",
                        ErrDesc       = "几何图形为空",
                    });
                    continue;
                }

                object xValue = feature.Value[xIdx];
                object yValue = feature.Value[yIdx];
                object zValue = feature.Value[zIdx];
                double x = 0, y = 0, z = 0;
                bool   isX = true, isY = true, isZ = true;
                if (xValue == null || xValue is DBNull || !double.TryParse(xValue.ToString(), out x))
                {
                    isX = false;
                }
                if (yValue == null || yValue is DBNull || !double.TryParse(yValue.ToString(), out y))
                {
                    isY = false;
                }
                if (zValue == null || zValue is DBNull || !double.TryParse(zValue.ToString(), out z))
                {
                    isZ = false;
                }
                if (!isX || !isY || !isZ)
                {
                    list.Add(new FeatureItem(feature)
                    {
                        PipelineName  = pipelineName,
                        PipeLayerName = featureClass.AliasName,
                        CheckItem     = "坐标信息检查",
                        ErrDesc       = "字段 " + (isX ? "" : xFieldName + " ") + (isY ? "" : yFieldName + " ") + (isZ ? "" : zFieldName + " ") + "属性错误或为空",
                    });
                    continue;
                }
                IPoint virtualPoint = new PointClass();
                virtualPoint.PutCoords(x, y);
                string errDesc = "";
                if (GeometryHelper.GetDistance(point, virtualPoint) > _dataCheck.DataCheckConfig.SurfaceTolerance)
                {
                    errDesc += "平面误差超过容差值 ";
                }
                if (hasZ)
                {
                    if (Math.Abs(point.Z - z) > _dataCheck.DataCheckConfig.ElevationTolerance)
                    {
                        errDesc += "高程误差超过容差值";
                    }
                }
                list.Add(new FeatureItem(feature)
                {
                    PipelineName  = pipelineName,
                    PipeLayerName = featureClass.AliasName,
                    CheckItem     = "坐标信息检查",
                    ErrDesc       = errDesc,
                });
            }

            return(list);
        }
Ejemplo n.º 2
0
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (_feature == null)
            {
                return;
            }
            IPoint       mapPoint         = _context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            IInvalidArea invalidAreaClass = new InvalidAreaClass()
            {
                Display = (_context.FocusMap as IActiveView).ScreenDisplay
            };

            invalidAreaClass.Add(_feature);
            Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(_feature.Class as IDataset);
            try
            {
                if (_codeSetting == null)
                {
                    _codeSetting = new FrmCode(_pointFeatureLayer, _gdbhFieldName);
                }
                _codeSetting.Next();
                if (_codeSetting.ShowDialog() == DialogResult.OK)
                {
                    ILineFeatureCalculate pCalculate = new LineFeatureCalculate(_feature, _lineFeatureLayer, _pointFeatureLayer);
                    pCalculate.LineFeatureLayer  = _lineFeatureLayer;
                    pCalculate.PointFeatureLayer = _pointFeatureLayer;
                    pCalculate.LineFeature       = _feature;
                    pCalculate.Point             = mapPoint;
                    pCalculate.IdxDMGCField      = _idxDmgcField;
                    pCalculate.IdxQDMSField      = _idxQdmsField;
                    pCalculate.IdxZDMSField      = _idxZdmsField;
                    double dmgcValue = pCalculate.GetGroundHeightByPoint();
                    double gxmsValue = pCalculate.GetDepthByPoint();
                    ISet   set       = (_feature as IFeatureEdit).Split(mapPoint);
                    set.Reset();

                    IFeature feature = set.Next() as IFeature;
                    if (CommonHelper.IsFromPoint(feature.Shape as IPolyline, mapPoint))
                    {
                        feature.Value[_idxQdbhField] = _codeSetting.Code;
                        feature.Value[_idxQdmsField] = gxmsValue.ToString("##0.0000");
                        feature.Value[_idxQdgcField] = (dmgcValue - gxmsValue).ToString("##0.0000");
                    }
                    else
                    {
                        feature.Value[_idxZdbhField] = _codeSetting.Code;
                        feature.Value[_idxZdmsField] = gxmsValue.ToString("##0.0000");
                        feature.Value[_idxZdgcField] = (dmgcValue - gxmsValue).ToString("##0.0000");
                    }
                    feature.Store();

                    feature = set.Next() as IFeature;
                    if (CommonHelper.IsFromPoint(feature.Shape as IPolyline, mapPoint))
                    {
                        feature.Value[_idxQdbhField] = _codeSetting.Code;
                        feature.Value[_idxQdmsField] = gxmsValue.ToString("##0.0000");
                        feature.Value[_idxQdgcField] = (dmgcValue - gxmsValue).ToString("##0.0000");
                    }
                    else
                    {
                        feature.Value[_idxZdbhField] = _codeSetting.Code;
                        feature.Value[_idxZdmsField] = gxmsValue.ToString("##0.0000");
                        feature.Value[_idxZdgcField] = (dmgcValue - gxmsValue).ToString("##0.0000");
                    }
                    feature.Store();


                    IFeature newFeature = _pointFeatureLayer.FeatureClass.CreateFeature();
                    newFeature.Value[_idxGdbhField] = _codeSetting.Code;
                    newFeature.Value[_idxDmgcField] = dmgcValue.ToString("##0.0000");
                    IPoint nearPoint = CommonHelper.GetNearestPoint(feature.Shape as IPolyline, mapPoint);
                    newFeature.Shape = GeometryHelper.CreatePoint(nearPoint.X, nearPoint.Y, nearPoint.Z, nearPoint.M, FeatureClassUtil.CheckHasZ(_pointFeatureLayer.FeatureClass), FeatureClassUtil.CheckHasM(_pointFeatureLayer.FeatureClass));
                    newFeature.Store();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(_feature.Class as IDataset);
            invalidAreaClass.Invalidate(-2);
            _context.ClearCurrentTool();
            _feature = null;
            _context.ActiveView.Refresh();
        }
Ejemplo n.º 3
0
        private void btnDetele_Click(object sender, EventArgs e)
        {
            try
            {
                if (_lineFeature1 == null)
                {
                    return;
                }
                if (_lineFeature2 == null)
                {
                    return;
                }
                IPolyline firstPolyline  = _lineFeature1.Shape as IPolyline;
                IPolyline secondPolyline = _lineFeature2.Shape as IPolyline;
                if (firstPolyline == null)
                {
                    return;
                }
                if (secondPolyline == null)
                {
                    return;
                }
                List <IPoint> points = new List <IPoint>()
                {
                    firstPolyline.FromPoint,
                    firstPolyline.ToPoint,
                    secondPolyline.FromPoint,
                    secondPolyline.ToPoint
                };
                IPoint        startPoint          = CommonHelper.GetFarthestPoint(firstPolyline, _linkPoint);
                IPoint        endPoint            = CommonHelper.GetFarthestPoint(secondPolyline, _linkPoint);
                int           firstfrompointcount = points.Count(point1 => Math.Abs(firstPolyline.FromPoint.X - point1.X) < 0.01 && Math.Abs(firstPolyline.FromPoint.Y - point1.Y) < 0.01);
                IFeatureClass pFeatureClass       = _featureLayer.FeatureClass;
                bool          hasZ     = FeatureClassUtil.CheckHasZ(pFeatureClass);
                bool          hasM     = FeatureClassUtil.CheckHasM(pFeatureClass);
                IFeature      pFeature = pFeatureClass.CreateFeature();

                startPoint = GeometryHelper.CreatePoint(startPoint.X, startPoint.Y, startPoint.Z, startPoint.M, hasZ, hasM);
                endPoint   = GeometryHelper.CreatePoint(endPoint.X, endPoint.Y, endPoint.Z, endPoint.M, hasZ, hasM);

                pFeature.Shape = GeometryHelper.CreatePointCollection(startPoint, endPoint, hasZ, hasM) as IPolyline;

                foreach (TreeRecord treeRecord in _treeRecords)
                {
                    if (treeRecord.IsDomain)
                    {
                        List <CodeValuePair> pairs = treeRecord.DoaminValue as List <CodeValuePair>;
                        CodeValuePair        pair  = pairs.FirstOrDefault(p => p.Name == treeRecord.FirstValue.ToString());
                        pFeature.Value[treeRecord.FieldId] = pair == null ? null : pair.Value;
                    }
                    pFeature.Value[treeRecord.FieldId] = treeRecord.MergeValue;
                }
                pFeature.Store();
                _featureoid       = pFeature.OID;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }