Exemplo n.º 1
0
        private void MoveFeature(IFeature pFeature, IPoint lastpoint, IPoint firstpoint)
        {
            double        deltax; double deltay;
            IGeoDataset   pGeoDataSet;
            ITransform2D  transform;
            IGeometry     pGeometry;
            IFeatureClass pClass = pFeature.Class as IFeatureClass;

            pGeoDataSet = pClass as IGeoDataset;

            pGeometry = pFeature.Shape;
            if (pGeometry.GeometryType == esriGeometryType.esriGeometryMultiPatch ||
                pGeometry.GeometryType == esriGeometryType.esriGeometryPoint ||
                pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline ||
                pGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                pGeometry = pFeature.Shape;
                transform = pGeometry as ITransform2D;
                if (!MapManager.CalDistance(lastpoint, firstpoint, out deltax, out deltay))
                {
                    MessageBox.Show("计算距离出现错误", "提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                //根据两点在X轴和Y轴上的距离差,对要素进行移动
                transform.Move(deltax, deltay);
                pGeometry = (IGeometry)transform;
                if (pGeoDataSet.SpatialReference != null)
                {
                    pGeometry.Project(pGeoDataSet.SpatialReference);
                }
                pFeature.Shape = SupportZMFeatureClass.ModifyGeomtryZMValue(pClass, pGeometry);
                //保存移动后的对象
                pFeature.Store();
            }
        }