public IPoint ProjectWgsToPulkovoWithGeoTransformation(IPoint inputPoint, CoordinateSystemModel coordinateSystemModel, esriTransformDirection transformationDirection) { if (inputPoint == null) { return(null); } var bufferPoint = new PointClass { X = inputPoint.X, Y = inputPoint.Y, SpatialReference = inputPoint.SpatialReference }; //Create Spatial Reference Factory var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); var targetSpatialReference = spatialReferenceFactory.CreateGeographicCoordinateSystem(coordinateSystemModel.ESRIWellKnownID); var coordinateFrameGeoTransformation = new CoordinateFrameTransformationClass(); coordinateFrameGeoTransformation.PutSpatialReferences(bufferPoint.SpatialReference, targetSpatialReference); coordinateFrameGeoTransformation.PutParameters(Constants.PulkovoToWGS.XAxisTranslation, Constants.PulkovoToWGS.YAxisTranslation, Constants.PulkovoToWGS.ZAxisTranslation, Constants.PulkovoToWGS.XAxisRotation, Constants.PulkovoToWGS.YAxisRotation, Constants.PulkovoToWGS.ZAxisRotation, Constants.PulkovoToWGS.ScaleDifference); var geometry = bufferPoint as IGeometry5; geometry.ProjectEx(targetSpatialReference, transformationDirection, coordinateFrameGeoTransformation, false, 0.0, 0.0); return(geometry as IPoint); }
private void CustomGT() { // Initialize a new spatial reference environment. // SpatialReferenceEnvironment is a singleton object and needs to use the Activator class. Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); System.Object obj = Activator.CreateInstance(factoryType); ISpatialReferenceFactory2 pSRF = obj as ISpatialReferenceFactory2; // Initialize and create the input and output coordinate systems. IProjectedCoordinateSystem2 pPCSin = new ESRI.ArcGIS.Geometry.ProjectedCoordinateSystemClass(); IProjectedCoordinateSystem2 pPCSout = new ESRI.ArcGIS.Geometry.ProjectedCoordinateSystemClass(); pPCSin = (IProjectedCoordinateSystem2)pSRF.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_Abidjan1987UTM_30N); pPCSout = (IProjectedCoordinateSystem2)pSRF.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_WGS1984UTM_30N); // Retrieve the geographic coordinate systems from the two projected // coordinate systems. IGeographicCoordinateSystem2 pGCSto = (IGeographicCoordinateSystem2)pPCSout.GeographicCoordinateSystem; IGeographicCoordinateSystem2 pGCSfrom = (IGeographicCoordinateSystem2)pPCSin.GeographicCoordinateSystem; // Initialize and create an appropriate geographic transformation. ICoordinateFrameTransformation pCFT = new CoordinateFrameTransformationClass(); pCFT.PutParameters(1.234, -2.345, 658.3, 4.3829, -2.48591, 2.18943, 2.48585); pCFT.PutSpatialReferences(pGCSfrom, pGCSto); pCFT.Name = "Custom GeoTran"; // The SpatialReferenceEnvironment has a GeoTransformationOperationSet that you // can use to maintain a list of active geographic transformations. // Once you add a geographic transformation to the operation set, many operations // can access the transformations. // Add the transformation to the operation set. IGeoTransformationOperationSet pGTSet = pSRF.GeoTransformationDefaults; // Always add a geographic transformation in both directions. pGTSet.Set(esriTransformDirection.esriTransformForward, pCFT); pGTSet.Set(esriTransformDirection.esriTransformReverse, pCFT); }
//step.2 创建坐标转换接口,为IGeometry2接口的ProjectEx()方法提供转换参数 /// <summary> /// 创建坐标转换接口,为IGeometry2接口的ProjectEx()方法提供转换参数 /// </summary> /// <returns>返回根据坐标转换参数创建的坐标转换接口</returns> private IGeoTransformation CreateSpatialRefTrans() { //转换和待转换的坐标系 IGeographicCoordinateSystem pGeoCoordSysFrom = (spatialRefFrom as IProjectedCoordinateSystem).GeographicCoordinateSystem; IGeographicCoordinateSystem pGeoCoordSysTo = (spatialRefTo as IProjectedCoordinateSystem).GeographicCoordinateSystem; //定义转换参数 ICoordinateFrameTransformation pCoordinateFrameTrans = new CoordinateFrameTransformationClass(); pCoordinateFrameTrans.PutParameters(Tx, Ty, Tz, Rx, Ry, Rz, SD); pCoordinateFrameTrans.PutSpatialReferences(pGeoCoordSysFrom, pGeoCoordSysTo); pCoordinateFrameTrans.Name = TransName; //geoTransformationOperationSet.Set(esriTransformDirection.esriTransformForward, pCoordinateFrameTrans); geoTransformation = pCoordinateFrameTrans as IGeoTransformation; return(geoTransformation); }
public IPoint ProjectWgsToUrkaine2000WithGeoTransformation( IPoint inputPoint, CoordinateSystemModel coordinateSystemModel, esriTransformDirection transformationDirection) { if (inputPoint == null) { return(null); } var bufferPoint = new PointClass { X = inputPoint.X, Y = inputPoint.Y, SpatialReference = inputPoint.SpatialReference }; //Create Spatial Reference Factory var spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); var targetSpatialReference = spatialReferenceFactory.CreateGeographicCoordinateSystem(coordinateSystemModel.ESRIWellKnownID); var compositeGeoTransformation = new CompositeGeoTransformationClass(); var predefinedGeoTransformation = spatialReferenceFactory.CreateGeoTransformation(Constants.ItrfToWgsGeoTransformationID) as IGeoTransformation; compositeGeoTransformation.Add(esriTransformDirection.esriTransformReverse, predefinedGeoTransformation); var coordinateFrameGeoTransformation = new CoordinateFrameTransformationClass(); var itrfSpatialReference = spatialReferenceFactory.CreateSpatialReference((int)esriSRGeoCS3Type.esriSRGeoCS_IERSTerrestrialReferenceFrame2000); coordinateFrameGeoTransformation.PutSpatialReferences(itrfSpatialReference, targetSpatialReference); coordinateFrameGeoTransformation.PutParameters( Constants.UkraineToItrf.XAxisTranslation, Constants.UkraineToItrf.YAxisTranslation, Constants.UkraineToItrf.ZAxisTranslation, Constants.UkraineToItrf.XAxisRotation, Constants.UkraineToItrf.YAxisRotation, Constants.UkraineToItrf.ZAxisRotation, Constants.UkraineToItrf.ScaleDifference); compositeGeoTransformation.Add(esriTransformDirection.esriTransformForward, coordinateFrameGeoTransformation); var geometry = bufferPoint as IGeometry5; geometry.ProjectEx(targetSpatialReference, transformationDirection, compositeGeoTransformation, false, 0.0, 0.0); return(geometry as IPoint); }