码迷,mamicode.com
首页 > 其他好文 > 详细

ArcGIS Engine——坐标系相关

时间:2019-12-27 18:14:39      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:alter   span   static   class   edit   空间   vat   project   sha   

    public class SpatialReferenceHelpers
    {
/// <summary> /// 创建地理坐标系 /// </summary> /// <param name="FactoryCode"></param> /// <returns></returns> public ISpatialReference CreateGeographicSpatialReference(ESRI.ArcGIS.Geometry.esriSRGeoCSType FactoryCode) { return CreateGeographicSpatialReference((int)FactoryCode); } public ISpatialReference CreateGeographicSpatialReference(int FactoryCode) { ISpatialReferenceFactory2 oSpatialReferenceFactory; ISpatialReference oCS; try { Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); oSpatialReferenceFactory = (ISpatialReferenceFactory2)Activator.CreateInstance(t); oCS = oSpatialReferenceFactory.CreateSpatialReference(FactoryCode); return oCS; } catch { return null; } }


/// <summary> /// 创建投影坐标系 /// </summary> /// <param name="pcsType"></param> /// <returns></returns> public ISpatialReference CreateProjectSpatialReference(esriSRProjCS4Type pcsType) { return CreateProjectSpatialReference((int)pcsType); } public ISpatialReference CreateProjectSpatialReference(int FactoryCode) { ISpatialReferenceFactory2 oSpatialReferenceFactory; ISpatialReference oCS; try { Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); oSpatialReferenceFactory = (ISpatialReferenceFactory2)Activator.CreateInstance(t); oCS = oSpatialReferenceFactory.CreateProjectedCoordinateSystem(FactoryCode); return oCS; } catch { return null; } }
/// <summary> /// 图形坐标系变换 /// </summary> /// <param name="pGeometry"></param> /// <param name="pInputSR"></param> /// <param name="pOutputSR"></param> /// <returns></returns> public IGeometry TransformShapeCS(IGeometry pGeometry, ISpatialReference pInputSR, ISpatialReference pOutputSR) { IGeometry oGeometry; try { oGeometry = pGeometry; oGeometry.SpatialReference = pInputSR; oGeometry.Project(pOutputSR); return oGeometry; } catch { return pGeometry; } } /// <summary> /// 修改要素集空间参考 /// </summary> /// <param name="pFeatureDataset">要素集</param> /// <param name="pSpatialReference">新空间参考</param> public static void AlterSpatialReference(IFeatureDataset pFeatureDataset, ISpatialReference pSpatialReference) { IGeoDataset pGeoDataset = pFeatureDataset as IGeoDataset; IGeoDatasetSchemaEdit pGeoDatasetSchemaEdit = pGeoDataset as IGeoDatasetSchemaEdit; if (pGeoDatasetSchemaEdit.CanAlterSpatialReference == true) pGeoDatasetSchemaEdit.AlterSpatialReference(pSpatialReference); }

/// <summary> /// 获取要素集空间参考 /// </summary> /// <param name="pGeoDataset">要素集</param> /// <returns></returns> public static ISpatialReference GetSpatialReference(IGeoDataset pGeoDataset) { return pGeoDataset.SpatialReference; } public static ISpatialReference GetSpatialReference(IFeatureDataset pFeatureDataset) { return GetSpatialReference(pFeatureDataset as IGeoDataset); } public static ISpatialReference GetSpatialReference(IFeatureLayer pFeatureLayer) { return GetSpatialReference(pFeatureLayer.FeatureClass); } public static ISpatialReference GetSpatialReference(IFeatureClass pFeatureClass) { return GetSpatialReference(pFeatureClass as IGeoDataset); } }

ArcGIS Engine——坐标系相关

标签:alter   span   static   class   edit   空间   vat   project   sha   

原文地址:https://www.cnblogs.com/zwcoding/p/12108600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!