public static void ChangeCoordinateSystem(IGeodatabaseRelease igeodatabaseRelease_0,
                                           ISpatialReference ispatialReference_0, bool bool_0)
 {
     if (ispatialReference_0 != null)
     {
         bool geoDatasetPrecision            = GeodatabaseTools.GetGeoDatasetPrecision(igeodatabaseRelease_0);
         IControlPrecision2 controlPrecision = ispatialReference_0 as IControlPrecision2;
         if (controlPrecision.IsHighPrecision != geoDatasetPrecision)
         {
             controlPrecision.IsHighPrecision = geoDatasetPrecision;
             double num;
             double num2;
             double num3;
             double num4;
             ispatialReference_0.GetDomain(out num, out num2, out num3, out num4);
             if (bool_0)
             {
                 ISpatialReferenceResolution spatialReferenceResolution =
                     ispatialReference_0 as ISpatialReferenceResolution;
                 spatialReferenceResolution.ConstructFromHorizon();
                 spatialReferenceResolution.SetDefaultXYResolution();
                 ISpatialReferenceTolerance spatialReferenceTolerance =
                     ispatialReference_0 as ISpatialReferenceTolerance;
                 spatialReferenceTolerance.SetDefaultXYTolerance();
             }
         }
     }
 }
Exemple #2
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog
            {
                Filter = "空间参考文件 (*.prj)|*.prj"
            };

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string fileName = dialog.FileName;
                this.ispatialReference_0 =
                    ((ISpatialReferenceFactory2)this.ispatialReferenceFactory_0).CreateESRISpatialReferenceFromPRJFile(
                        fileName);
                IControlPrecision2 precision = this.ispatialReference_0 as IControlPrecision2;
                if (this.bool_2 != precision.IsHighPrecision)
                {
                    if (precision.IsHighPrecision)
                    {
                        (this.ispatialReference_0 as ISpatialReferenceResolution).ConstructFromHorizon();
                        precision.IsHighPrecision = this.bool_2;
                    }
                    else
                    {
                        precision.IsHighPrecision = this.bool_2;
                    }
                }
                this.method_1(this.ispatialReference_0);
                this.method_0();
            }
            dialog.Dispose();
        }
Exemple #3
0
        private ISpatialReference GetSpatialReference(int xyCoordinateSystem)
        {
            const bool IsHighPrecision = true;

            ISpatialReference spatialReference;

            ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();

            spatialReference = spatialReferenceFactory.CreateSpatialReference(xyCoordinateSystem);

            IControlPrecision2 controlPrecision = spatialReference as IControlPrecision2;

            controlPrecision.IsHighPrecision = IsHighPrecision;

            ISpatialReferenceResolution spatialReferenceResolution = spatialReference as ISpatialReferenceResolution;

            spatialReferenceResolution.ConstructFromHorizon();
            spatialReferenceResolution.SetDefaultXYResolution();
            spatialReferenceResolution.SetDefaultZResolution();
            spatialReferenceResolution.SetDefaultMResolution();

            ISpatialReferenceTolerance spatialReferenceTolerance = spatialReference as ISpatialReferenceTolerance;

            spatialReferenceTolerance.SetDefaultXYTolerance();
            spatialReferenceTolerance.SetDefaultZTolerance();
            spatialReferenceTolerance.SetDefaultMTolerance();

            return(spatialReference);
        }
Exemple #4
0
        /// <summary>
        // 创建要素数据集
        /// </summary>
        /// <param name="workspace"></param>
        /// <param name="code"></param>
        /// <param name="datasetName"></param>
        /// <returns></returns>
        public IFeatureDataset CreateFeatureClass(IWorkspace workspace, int code, string datasetName)
        {
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
            //创建一个要素集创建一个投影
            ISpatialReferenceFactory spatialRefFactory = new SpatialReferenceEnvironmentClass();
            ISpatialReference        spatialReference  = spatialRefFactory.CreateProjectedCoordinateSystem(code);
            //确定是否支持高精度存储空间
            Boolean supportsHighPrecision            = false;
            IWorkspaceProperties workspaceProperties = (IWorkspaceProperties)workspace;
            IWorkspaceProperty   workspaceProperty   = workspaceProperties.get_Property
                                                           (esriWorkspacePropertyGroupType.esriWorkspacePropertyGroup,
                                                           (int)esriWorkspacePropertyType.esriWorkspacePropSupportsHighPrecisionStorage);

            if (workspaceProperty.IsSupported)
            {
                supportsHighPrecision = Convert.ToBoolean(workspaceProperty.PropertyValue);
            }
            //设置投影精度
            IControlPrecision2 controlPrecision = (IControlPrecision2)spatialReference;

            controlPrecision.IsHighPrecision = supportsHighPrecision;
            //设置容差
            ISpatialReferenceResolution spatialRefResolution = (ISpatialReferenceResolution)spatialReference;

            spatialRefResolution.ConstructFromHorizon();
            spatialRefResolution.SetDefaultXYResolution();
            ISpatialReferenceTolerance spatialRefTolerance = (ISpatialReferenceTolerance)spatialReference;

            spatialRefTolerance.SetDefaultXYTolerance();
            //创建要素集
            IFeatureDataset featureDataset = featureWorkspace.CreateFeatureDataset(datasetName, spatialReference);

            return(featureDataset);
        }
Exemple #5
0
        /// <summary>
        /// 根据某一图层的范围,创建mdb文件中的featuredataset及其空间范围
        /// </summary>
        /// <param name="motherWs">要创建featuredataset的工作空间</param>
        /// <param name="pGeoDataset">featuredataset所要依据的空间参考和空间范围</param>
        /// 这个函数要改!!
        public static void CreateDatasetInWs(IWorkspace motherWs, IGeoDataset pGeoDataset, string datasetName)
        {
            try
            {
                ISpatialReference pSpatialRef = null;
                IFeatureDataset   pFtDs       = null;


                if (pGeoDataset != null)
                {
                    pSpatialRef = pGeoDataset.SpatialReference;

                    IControlPrecision2 controlPrecision2 = pSpatialRef as IControlPrecision2;
                    if (!controlPrecision2.IsHighPrecision)
                    {
                        controlPrecision2.IsHighPrecision = true;
                    }

                    IEnvelope pEnv = pGeoDataset.Extent;
                    pEnv.Expand(1.5, 1.5, true);
                    pSpatialRef.SetDomain(pEnv.XMin, pEnv.XMax, pEnv.YMin, pEnv.YMax);

                    ISpatialReferenceTolerance pSpatialTolerance = (ISpatialReferenceTolerance)pSpatialRef;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance  = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = (ISpatialReferenceResolution)pSpatialRef;
                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;

                    pFtDs = ((IFeatureWorkspace)motherWs).CreateFeatureDataset(datasetName, pSpatialRef);
                }
                else
                {
                    pSpatialRef = new UnknownCoordinateSystemClass();

                    ISpatialReferenceTolerance pSpatialTolerance = (ISpatialReferenceTolerance)pSpatialRef;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance  = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = (ISpatialReferenceResolution)pSpatialRef;
                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;

                    pFtDs = ((IFeatureWorkspace)motherWs).CreateFeatureDataset(datasetName, pSpatialRef);
                }
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
            }
        }
Exemple #6
0
        private ISpatialReference method_0(bool bool_5)
        {
            ISpatialReference  reference = new UnknownCoordinateSystemClass();
            IControlPrecision2 precision = reference as IControlPrecision2;

            precision.IsHighPrecision = bool_5;
            ISpatialReferenceResolution resolution = reference as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (reference as ISpatialReferenceTolerance).SetDefaultXYTolerance();
            return(reference);
        }
Exemple #7
0
        private void method_0(ISpatialReference ispatialReference_0)
        {
            bool geoDatasetPrecision      = false;
            IGeodatabaseRelease release   = this.iworkspace_0 as IGeodatabaseRelease;
            IControlPrecision2  precision = ispatialReference_0 as IControlPrecision2;

            geoDatasetPrecision       = GeodatabaseTools.GetGeoDatasetPrecision(release);
            precision.IsHighPrecision = geoDatasetPrecision;
            ISpatialReferenceResolution resolution = ispatialReference_0 as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (ispatialReference_0 as ISpatialReferenceTolerance).SetDefaultXYTolerance();
        }
Exemple #8
0
        /// <summary>
        /// Converts an existing low precision spatial reference and returns a new high precision spatial reference.
        /// </summary>
        /// <param name="lowSpatialReference">An ISpatialReference interface that is the low spatial reference to be converted.</param>
        /// <param name="xyDoubler">A System.Int32 that is the amount of doubling (2^x) based on the input resolution; -1 produces a value close to the default resolution. Example: -1</param>
        /// <param name="mDoubler">A System.Int32 that determines doubling of m-resolution based on input m-resolution; the default is 0. Example: 0</param>
        /// <param name="zDoubler">A System.Int32 that determines doubling of z-resolution based on input z-resolution; default is 0. Example: 0</param>
        /// <returns>An ISpatialReference interface that is the new high precision spatial reference.</returns>
        public static ISpatialReference ConvertSpatialReferenceFromLowToHighPrecision(ISpatialReference lowSpatialReference, int xyDoubler, int mDoubler, int zDoubler)
        {
            IControlPrecision2 controlPrecision2 = lowSpatialReference as IControlPrecision2;

            if (controlPrecision2.IsHighPrecision)
            {
                throw new ArgumentException("Expected a low precision spatial reference.", "lowSpatialReference");
            }

            ISpatialReferenceFactory3 spatialReferenceFactory3 = new SpatialReferenceEnvironmentClass();
            ISpatialReference         highSpatialReference     = spatialReferenceFactory3.ConstructHighPrecisionSpatialReference(lowSpatialReference, xyDoubler, zDoubler, mDoubler);

            return(highSpatialReference);
        }
Exemple #9
0
        private ISpatialReference method_0(bool bool_1)
        {
            new SpatialReferenceEnvironmentClass();
            ISpatialReference   reference = new UnknownCoordinateSystemClass();
            IGeodatabaseRelease release   = this.ifeatureWorkspace_0 as IGeodatabaseRelease;
            IControlPrecision2  precision = reference as IControlPrecision2;

            bool_1 = GeodatabaseTools.GetGeoDatasetPrecision(release);
            precision.IsHighPrecision = bool_1;
            ISpatialReferenceResolution resolution = reference as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (reference as ISpatialReferenceTolerance).SetDefaultXYTolerance();
            return(reference);
        }
        public static ISpatialReference ConstructCoordinateSystem(IGeodatabaseRelease igeodatabaseRelease_0)
        {
            bool geoDatasetPrecision = GeodatabaseTools.GetGeoDatasetPrecision(igeodatabaseRelease_0);

            ISpatialReference  spatialReference = new UnknownCoordinateSystem() as ISpatialReference;
            IControlPrecision2 controlPrecision = spatialReference as IControlPrecision2;

            controlPrecision.IsHighPrecision = geoDatasetPrecision;
            ISpatialReferenceResolution spatialReferenceResolution = spatialReference as ISpatialReferenceResolution;

            spatialReferenceResolution.ConstructFromHorizon();
            spatialReferenceResolution.SetDefaultXYResolution();
            ISpatialReferenceTolerance spatialReferenceTolerance = spatialReference as ISpatialReferenceTolerance;

            spatialReferenceTolerance.SetDefaultXYTolerance();
            return(spatialReference);
        }
Exemple #11
0
        /// <summary>
        /// 创建几何空间参考
        /// </summary>
        /// <param name="LoadPath">空间参考文件</param>
        /// <param name="eError"></param>
        /// <returns></returns>
        public ISpatialReference GetSpatialRef(string LoadPath, out Exception eError)
        {
            eError = null;
            try
            {
                ISpatialReference        pSR            = null;
                ISpatialReferenceFactory pSpatialRefFac = new SpatialReferenceEnvironmentClass();

                if (!File.Exists(LoadPath))
                {
                    //eError = new Exception("空间参考文件不存在!");
                    return(null);
                }
                pSR = pSpatialRefFac.CreateESRISpatialReferenceFromPRJFile(LoadPath);

                ISpatialReferenceResolution pSRR = pSR as ISpatialReferenceResolution;
                ISpatialReferenceTolerance  pSRT = (ISpatialReferenceTolerance)pSR;
                IControlPrecision2          pSpatialPrecision = (IControlPrecision2)pSR;

                pSRR.ConstructFromHorizon();//Defines the XY resolution and domain extent of this spatial reference based on the extent of its horizon
                pSRR.SetDefaultXYResolution();
                pSRT.SetDefaultXYTolerance();
                return(pSR);
            }
            catch (Exception ex)
            {
                //*******************************************************************
                //guozheng added
                if (ModData.SysLog != null)
                {
                    ModData.SysLog.Write(ex, null, DateTime.Now);
                }
                else
                {
                    ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                    ModData.SysLog.Write(ex, null, DateTime.Now);
                }
                //********************************************************************

                eError = ex;
                return(null);
            }
        }
Exemple #12
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterDatasets(), true);
            file.AllowMultiSelect = false;
            if (file.ShowDialog() == DialogResult.OK)
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    IGeoDataset dataset2 = dataset.Dataset as IGeoDataset;
                    if (dataset2 != null)
                    {
                        this.ispatialReference_0 = dataset2.SpatialReference;
                        this.textBoxName.Text    = this.ispatialReference_0.Name;
                        this.textBoxName.Tag     = this.ispatialReference_0;
                        if (this.ispatialReference_0 is IUnknownCoordinateSystem)
                        {
                            this.btnModify.Enabled = false;
                        }
                        else
                        {
                            this.btnModify.Enabled = true;
                        }
                        IControlPrecision2 precision = this.ispatialReference_0 as IControlPrecision2;
                        if (NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision != precision.IsHighPrecision)
                        {
                            if (precision.IsHighPrecision)
                            {
                                precision.IsHighPrecision = NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision;
                                (this.ispatialReference_0 as ISpatialReferenceResolution).ConstructFromHorizon();
                            }
                            else
                            {
                                precision.IsHighPrecision = NewObjectClassHelper.m_pObjectClassHelper.IsHighPrecision;
                            }
                        }
                    }
                }
            }
        }
Exemple #13
0
 private static void ChangeCoordinateSystem(IGeodatabaseRelease igeodatabaseRelease_0,
                                            ISpatialReference ispatialReference_0, bool bool_0)
 {
     if (ispatialReference_0 != null)
     {
         bool geoDatasetPrecision = GeodatabaseTools.GetGeoDatasetPrecision(igeodatabaseRelease_0);
         IControlPrecision2 ispatialReference0 = ispatialReference_0 as IControlPrecision2;
         if (ispatialReference0.IsHighPrecision != geoDatasetPrecision)
         {
             ispatialReference0.IsHighPrecision = geoDatasetPrecision;
             if (bool_0)
             {
                 ISpatialReferenceResolution spatialReferenceResolution =
                     ispatialReference_0 as ISpatialReferenceResolution;
                 spatialReferenceResolution.ConstructFromHorizon();
                 spatialReferenceResolution.SetDefaultXYResolution();
                 (ispatialReference_0 as ISpatialReferenceTolerance).SetDefaultXYTolerance();
             }
         }
     }
 }
Exemple #14
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterDatasets(), true);
            file.AllowMultiSelect = false;
            if (file.ShowDialog() == DialogResult.OK)
            {
                IGxDataset dataset = file.Items.get_Element(0) as IGxDataset;
                if (dataset != null)
                {
                    IGeoDataset dataset2 = dataset.Dataset as IGeoDataset;
                    if (dataset2 != null)
                    {
                        this.ispatialReference_0 = dataset2.SpatialReference;
                        IControlPrecision2 precision = this.ispatialReference_0 as IControlPrecision2;
                        if (this.bool_2 != precision.IsHighPrecision)
                        {
                            if (precision.IsHighPrecision)
                            {
                                precision.IsHighPrecision = this.bool_2;
                                (this.ispatialReference_0 as ISpatialReferenceResolution).ConstructFromHorizon();
                            }
                            else
                            {
                                precision.IsHighPrecision = this.bool_2;
                            }
                        }
                        this.method_1(this.ispatialReference_0);
                        if (this.SpatialReferenceChanged != null)
                        {
                            this.SpatialReferenceChanged(this.ispatialReference_0);
                        }
                        this.method_0();
                    }
                }
            }
        }
Exemple #15
0
        public static bool IsLowPrecisionSpatialReference(ISpatialReference sr)
        {
            IControlPrecision2 controlPrecision2 = sr as IControlPrecision2;

            return(!controlPrecision2.IsHighPrecision);
        }