标签: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); } }
标签:alter span static class edit 空间 vat project sha
原文地址:https://www.cnblogs.com/zwcoding/p/12108600.html