Ejemplo n.º 1
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            FrmCoordinateSystem frm = new FrmCoordinateSystem(m_mapControl, m_mapCtlHide);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                pSpaReference = frm.pSpaReference;

                richTextReference.Text = ClsGDBDataCommon.GetReferenceString(frm.pSpaReference);
            }
        }
Ejemplo n.º 2
0
        //直接更改图层坐标系统,并不重投影数据值
        private void btnChangeCoordinate_Click(object sender, EventArgs e)
        {
            ISpatialReference   pSpatialReference = null;
            FrmCoordinateSystem frm = new FrmCoordinateSystem(m_pLayer);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                pSpatialReference = frm.pSpaReference;

                if (m_pLayer is IFeatureLayer)
                {
                    IFeatureLayer pFLayer = m_pLayer as IFeatureLayer;
                    IFeatureClass pFClass = pFLayer.FeatureClass;
                    if (pFClass == null)
                    {
                        return;
                    }
                    IFeatureDataset pFDataset = pFClass.FeatureDataset;
                    if (pFDataset == null)
                    {
                        IGeoDatasetSchemaEdit geoSchemaEdit = pFClass as IGeoDatasetSchemaEdit;
                        if (geoSchemaEdit == null)
                        {
                            return;
                        }

                        if (geoSchemaEdit.CanAlterSpatialReference == true)
                        {
                            geoSchemaEdit.AlterSpatialReference(pSpatialReference);
                        }
                    }
                    else
                    {
                        IGeoDatasetSchemaEdit geoSchemaEdit = pFDataset as IGeoDatasetSchemaEdit;
                        if (geoSchemaEdit == null)
                        {
                            return;
                        }

                        if (geoSchemaEdit.CanAlterSpatialReference == true)
                        {
                            geoSchemaEdit.AlterSpatialReference(pSpatialReference);
                        }
                    }
                }
                else if (m_pLayer is IRasterLayer)
                {
                    IRasterLayer          pRLayer       = m_pLayer as IRasterLayer;
                    IRaster               pRaster       = pRLayer.Raster;
                    IRaster2              pRaster2      = pRaster as IRaster2;
                    IRasterDataset        pRDataset     = pRaster2.RasterDataset;
                    IGeoDatasetSchemaEdit geoSchemaEdit = pRDataset as IGeoDatasetSchemaEdit;
                    if (geoSchemaEdit == null)
                    {
                        return;
                    }

                    if (geoSchemaEdit.CanAlterSpatialReference == true)
                    {
                        geoSchemaEdit.AlterSpatialReference(pSpatialReference);
                        pRLayer.CreateFromDataset(pRDataset);
                    }
                }


                string strCoord = string.Empty;
                if (m_pLayer is IGeoDataset)
                {
                    IGeoDataset geoDataset = m_pLayer as IGeoDataset;
                    if (geoDataset == null)
                    {
                        this.txtCoordinateSystem.Text = string.Empty;
                    }
                    else
                    {
                        ISpatialReference reference = geoDataset.SpatialReference;

                        strCoord = ClsGDBDataCommon.GetReferenceString(reference);
                        txtCoordinateSystem.Text = strCoord;
                        txtCoordinateSystem.Update();
                    }
                }
            }
        }