本代码实现在WGS84系统的大地坐标(BLH)和空间直角坐标(XYZ)的互相转换,符合标准语法,可直接使用

如下代码,输出为:
 WGS84:  -2175790.73969891    4461032.11207734     3992337.79032463
 BLH:   38.9999999999998    116.000000000000    33.0000069718808

Module CorrTrans
!// WGS84 系统BLH坐标与空间直角坐标转换
!// Fortran Coder http://fcode.cn
!// Adapted from Acheng's C++ code
Implicit None
Integer , parameter :: DP = Selected_Real_Kind( 12 )
Real(kind=DP) , parameter :: PI = 3.14159265358979323846_DP
Real(kind=DP) , parameter , private :: a = 6378137._DP
Real(kind=DP) , parameter , private :: f = 1.0_DP / 298.257223563_DP
Real(kind=DP) , parameter , private :: t = a * ( 1.0_DP - f )
Real(kind=DP) , parameter , private :: e = sqrt( (a*a - t*t) / (a*a) )
contains
Subroutine XYZ2BLH( x , y , z , B , L , H )
Real(Kind=DP) , Intent( IN ) :: x , y , z
Real(Kind=DP) , Intent( OUT ) :: B , L , H
real(kind=DP) :: N
integer :: i
L = atan( abs(y/x) )
B = atan( abs(z/sqrt(x*x+y*y) ) )
do i = 1 , 5
N = a / sqrt( 1.0_DP - e*e*sin(B)*sin(B) )
H = z / sin(B) - N * ( 1.0_DP - e*e )
B = atan( z*(N+H) / ( sqrt(x*x+y*y)*(N*(1.0_DP-e*e)+H) ) )
end do
if ( x < 0._DP .and. y > 0._DP ) L = PI - L
if ( x > 0._DP .and. y < 0._DP ) L = -1.0_DP * L
if ( x < 0._DP .and. y < 0._DP ) L = -1.0 * PI + L
B = B * 180._DP / PI
L = L * 180._DP / PI
End Subroutine XYZ2BLH Subroutine BLH2XYZ( B , L , H , x , y , z )
Real(Kind=DP) , Intent( IN ) :: B , L , H
Real(Kind=DP) , Intent( OUT ) :: x , y , z
real(kind=DP) :: N , Br , Lr
Br = B * PI / 180._DP
Lr = L * PI / 180._DP
N = a / sqrt( 1.0_DP - e*e*sin(Br)*sin(Br) )
x = ( N + H ) * cos(Br)*cos(Lr)
y = ( N + H ) * cos(Br)*sin(Lr)
z = ( N*(1.0_DP - e*e ) + H ) * sin(Br);
End Subroutine BLH2XYZ End Module CorrTrans Program www_fcode_cn
Use CorrTrans
Implicit None
Real(Kind=DP) :: x , y , z
Real(Kind=DP) :: B , L , H
B = 39._DP ; L = 116._DP ; H = 33._DP
call BLH2XYZ( B , L , H , x , y , z )
write(*,*) 'WGS84:' , x , y , z
call XYZ2BLH( x , y , z , B , L , H )
write(*,*) 'BLH:' , B , L , H
End Program www_fcode_cn

转自:http://fcode.cn/code_prof-89-1.html

[转载]:经纬度与WGS84坐标转换的更多相关文章

  1. 火星坐标、百度坐标、WGS84坐标转换代码(JS、python版)

    火星坐标.百度坐标.WGS84坐标转换代码(JS.python版) 一.JS版本源码 github:https://github.com/wandergis/coordTransform /** * ...

  2. 火星坐标、百度坐标、WGS84坐标转换代码(JS)

    JS版本源码 /** * Created by Wandergis on 2015/7/8. * 提供了百度坐标(BD09).国测局坐标(火星坐标,GCJ02).和WGS84坐标系之间的转换 */ / ...

  3. C# UTM坐标和WGS84坐标转换小工具

    工具根据:http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html js代码改编 工具源码github:https://github. ...

  4. WGS84,GCJ02, BD09坐标转换

    public class Gps { private double wgLat; private double wgLon; public Gps(double wgLat, double wgLon ...

  5. python 编写的经纬度坐标转换类

    # -*- coding: utf-8 -*- # /** # * 各地图API坐标系统比较与转换; # * WGS84坐标系:即地球坐标系,国际上通用的坐标系.设备一般包含GPS芯片或者北斗芯片获取 ...

  6. 简谈百度坐标反转至WGS84的三种思路

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 基于百度地图进行数据展示是目前项目中常见场景,但是因为百度地图 ...

  7. IDL通过经纬度定位获取DN值

    以前就想写,但是因为envi可以就一直没弄.今天正好有个机会,就做了这个事情.ENVI中在主窗口中pixel locator可以实现,但是当我们需要读入很多的数据的时候,也就是批量处理的时候,显然编程 ...

  8. WGS84、GCJ-02(火星坐标)、百度坐标,Web墨卡托坐标

    GCJ-02坐标系统(火星坐标)简介:http://blog.csdn.net/giswens/article/details/8775121(存档:http://mapbd.com/cms/2012 ...

  9. BD09坐标(百度坐标) WGS84(GPS坐标) GCJ02(国测局坐标) 的相互转换

    BD09坐标(百度坐标) WGS84(GPS坐标) GCJ02(国测局坐标) 的相互转换 http://www.cnphp6.com/archives/24822 by root ⋅ Leave a ...

随机推荐

  1. 2014年5月份第3周51Aspx源码发布详情

    HGM简单连连看游戏源码  2014-5-19 [VS2010]源码描述:这是一款基于WinForm窗体程序的简单水果连连看的小游戏.界面比较美观, 功能如下:该游戏可以显示当前关卡,还有剩余时间.重 ...

  2. Maven工程中的右键team

    与资源库同步(S):在需要合并版本时使用 提交(C):本地代码写入源码库 更新(U):本地代码升级到服务器端版本 在点击更新时,请注意: 如果当前项目有改动(甚至是比原来多了一个空格),则此时无法更新 ...

  3. cd hit使用

    ~~和唐老师一个实验室的人开发的~~ CD-HIT is a very widely used program for clustering and comparing protein or nucl ...

  4. 浅谈new operator、operator new和placement new 分类: C/C++ 2015-05-05 00:19 41人阅读 评论(0) 收藏

    浅谈new operator.operator new和placement new C++中使用new来产生一个存在于heap(堆)上对象时,实际上是调用了operator new函数和placeme ...

  5. JavaScript 中的window.event代表的是事件的状态,jquery事件对象属性,jquery中如何使用event.target

    http://wenda.haosou.com/q/1373868839069215 http://kylines.iteye.com/blog/1660236 http://www.cnblogs. ...

  6. Spring加载resource时classpath*:与classpath:的区别

    http://blog.csdn.net/kkdelta/article/details/5507799   classpath: 第一个匹配的 classpath*:多个组件中的可匹配的

  7. Docker run命令详解 转

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Usage: doc ...

  8. Mac OS X使用快捷键改善窗口管理的六个方法

    http://www.macx.cn/thread-2085916-1-1.html 窗口全屏 ctrl+command+f

  9. 各种数据分析图demo

    极地蛛网图:http://www.hcharts.cn/demo/index.php?p=61 各种数据分析图demo: http://www.hcharts.cn/demo/index.php?p= ...

  10. Qt 动画框架

    最近一个项目中的需要做动画效果,很自然就想起来用qt animation framework .这个框架真的很强大.支持多个动画组合,线性动画,并行动画等.在此总结一下使用该框架一些需要注意的地方: ...