static void Main(string[] args) { //ESRI License Initializer generated code. m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeBasic }, new esriLicenseExtensionCode[] { }); //ESRI License Initializer generated code. Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); ISpatialReferenceFactory pSpatialReferenceFactory = (ISpatialReferenceFactory)Activator.CreateInstance(t); //シングルトン //日本測地系 ISpatialReference pGCS_Tokyo = pSpatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Tokyo); //日本測地系2000 ISpatialReference pGCS_JGD2000 = pSpatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCS3Type.esriSRGeoCS_JapanGeodeticDatum2000); //地理座標系変換 IGeoTransformation pGeo2000 = TKY2JGD2000(); IGeoTransformation pGeo2011 = TKY2JGD2011(); IPoint pPoint = new PointClass(); Console.WriteLine("GCS_Tokyo:" + pPoint.X.ToString() + "," + pPoint.Y.ToString()); pPoint.PutCoords(135,35); //元の座標値の設定 pPoint.SpatialReference = pGCS_Tokyo; //元の座標系の設定 IGeometry2 pGeometry2 = (IGeometry2)pPoint; pGeometry2.ProjectEx(pGCS_JGD2000, esriTransformDirection.esriTransformForward, pGeo2000, false, 0, 0); //測地系の変換 Console.WriteLine("GCS_JGD2000:" + pPoint.X.ToString() + "," + pPoint.Y.ToString()); Console.ReadLine(); //Do not make any call to ArcObjects after ShutDownApplication() m_AOLicenseInitializer.ShutdownApplication(); } //TKY2JGD(測地成果2000)の作成 static IGeoTransformation TKY2JGD2000() { IGridTransformation pGridTransformation = new NTv2TransformationClass(); pGridTransformation.Name = "Tokyo_To_JGD_2000_NTv2"; pGridTransformation.GridDatasetName = "Dataset_japan/tky2jgd.gsb"; pGridTransformation.Load(); return pGridTransformation; } //TKY2JGD(測地成果2011)の作成 static IGeoTransformation TKY2JGD2011() { IGridTransformation pGridTransformation = new NTv2TransformationClass(); pGridTransformation.Name = "JGD_2000_To_JGD_2011_NTv2_1"; pGridTransformation.GridDatasetName = "Dataset_japan/touhokutaiheiyouoki2011.gsb"; pGridTransformation.Load(); return pGridTransformation; }
' WGS84の図形をGCS_JGD2000に投影変換する。 ' @param pTarget 投影変換する図形 ' @return IGeometry 投影変換後の図形 Function Wgs84_to_Gcsjgd200(ByRef pTarget As IGeometry) Dim pGeometry2 As IGeometry2 Dim pSpatialReferenceFactory As ISpatialReferenceFactory Dim pGcsjgd2000 As ISpatialReference Dim pGeotransformation As IGeoTransformation Set pGeometry2 = pTarget ' GCS_JGD2000の投影法定義を作成 Set pSpatialReferenceFactory = New SpatialReferenceEnvironment Set pGcsjgd2000 = pSpatialReferenceFactory.CreateGeographicCoordinateSystem(esriSRGeoCS_JapanGeodeticDatum2000) ' 地理座標系(測地基準系)を考慮するため、JGD2000 -> WGS84の変換方法を作成する Set pGeotransformation = pSpatialReferenceFactory.CreateGeoTransformation(esriSRGeoTransformation_JGD_2000_To_WGS_1984) ' 地理座標系(測地基準系)を考慮した投影変換 pGeometry2.ProjectEx pGcsjgd2000, esriTransformReverse, pGeotransformation, False, 0, 0 End Function