move EGM96 model in separated file

This commit is contained in:
Pascal Brisset
2009-11-16 16:42:55 +00:00
parent c3293d5dea
commit 270ba7be4d
5 changed files with 85 additions and 33 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ OCAMLOPT=ocamlopt
OCAMLLIBDIR=$(shell ocamlc -where)
SRC = debug.ml base64.ml serial.ml ocaml_tools.ml extXml.ml env.ml xml2h.ml latlong.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o convert.o ubx.ml pprz.ml xbee.ml logpprz.ml xmlCom.ml editAirframe.ml
SRC = debug.ml base64.ml serial.ml ocaml_tools.ml extXml.ml env.ml xml2h.ml latlong.ml egm96.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o convert.o ubx.ml pprz.ml xbee.ml logpprz.ml xmlCom.ml editAirframe.ml
CMO = $(SRC:.ml=.cmo)
CMX = $(SRC:.ml=.cmx)
+56
View File
@@ -0,0 +1,56 @@
(*
* $Id$
*
* EGM96 geoid model
*
* Copyright (C) 2009 ENAC, Pascal Brisset
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*)
open Latlong
let (//) = Filename.concat
let ncols = 1440
let nrows = 721
let data =
lazy (
let path = [Env.paparazzi_home // "data" // "srtm"] in
let f = Ocaml_tools.open_compress (Ocaml_tools.find_file path "WW15MGH.DAC") in
let n = ncols * nrows * 2 in
let buf = String.create n in
really_input f buf 0 n;
buf)
(* http://earth-info.nima.mil/GandG/wgs84/gravitymod/egm96/binary/binarygeoid.html *)
let of_wgs84 = fun geo ->
let egm96_data = Lazy.force data in
let lat = truncate ((Rad>>Deg) (norm_angle geo.posn_lat))
and lon = truncate ((Rad>>Deg) (norm_angle geo.posn_long)) in
let ilat = (90-lat)*4 (* 15' == 4 entries per degree *)
and ilon = (lon+if lon < 0 then 360 else 0)*4 in
let i = (2*(ilat*ncols+ilon)) in
let x = Char.code egm96_data.[i] lsl 8 + Char.code egm96_data.[i+1] in
float ((x lsl 16) asr 16) /. 100.
+28
View File
@@ -0,0 +1,28 @@
(*
* $Id$
*
* EGM96 geoid model
*
* Copyright (C) 2009 ENAC, Pascal Brisset
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*)
val of_wgs84 : Latlong.geographic -> Latlong.fmeter
(** Return geoid height from 15' precomputed file *)
-29
View File
@@ -714,32 +714,3 @@ let wgs84_hmsl = fun geo ->
(float geoid_data.(ilat1).(ilon2))
(float geoid_data.(ilat2).(ilon1))
(float geoid_data.(ilat2).(ilon2))
let egm96_ncols = 1440
let egm96_nrows = 721
let egm96_data =
lazy (
let path = [Env.paparazzi_home // "data" // "srtm"] in
let f = Ocaml_tools.open_compress (Ocaml_tools.find_file path "WW15MGH.DAC") in
let n = egm96_ncols * egm96_nrows * 2 in
let buf = String.create n in
really_input f buf 0 n;
buf)
(* http://earth-info.nima.mil/GandG/wgs84/gravitymod/egm96/binary/binarygeoid.html *)
let egm96 = fun geo ->
let egm96_data = Lazy.force egm96_data in
let lat = truncate ((Rad>>Deg) (norm_angle geo.posn_lat))
and lon = truncate ((Rad>>Deg) (norm_angle geo.posn_long)) in
let ilat = (90-lat)*4 (* 15' == 4 entries per degree *)
and ilon = (lon+if lon < 0 then 360 else 0)*4 in
let i = (2*(ilat*egm96_ncols+ilon)) in
let x = Char.code egm96_data.[i] lsl 8 + Char.code egm96_data.[i+1] in
float ((x lsl 16) asr 16) /. 100.
-3
View File
@@ -199,6 +199,3 @@ val geo_of_ecef : geodesic -> ecef -> geographic * float
(** [geo_of_ecef ellipsoid geo ecef] Returns llh *)
val wgs84_hmsl : geographic -> fmeter
val egm96 : geographic -> fmeter
(** Return geoid height from 15' precomputed file *)