From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,960d1cb75613cad X-Google-Attributes: gid103376,public From: Gary Scott Subject: Re: Earth map transformation in Ada ? Date: 2000/05/07 Message-ID: <3914BC75.BB2A9DE1@flash.net>#1/1 X-Deja-AN: 620129389 Content-Transfer-Encoding: 7bit References: <8eudi9$ck7$1@news.uit.no> <3914B7DE.3CCEF170@acenet.com.au> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flash.net X-Trace: news.flash.net 957660196 216.215.89.253 (Sat, 06 May 2000 19:43:16 CDT) Organization: Home MIME-Version: 1.0 Reply-To: scottg@flash.net NNTP-Posting-Date: Sat, 06 May 2000 19:43:16 CDT Newsgroups: comp.lang.ada Date: 2000-05-07T00:00:00+00:00 List-Id: If not too much trouble (or rude of me to ask), I would be overjoyed to receive such a package. I've been working on the same thing and have searched high and low for one so that I didn't have to reinvent the wheel. Geoff Bull wrote: > > Reinert Korsnes wrote: > > > > Does someone know about available (Earth) map stransformations in Ada ? > > > > like: > > > > lat,long <-> x,y (Polar Stereographic) > > > > reinert > > I have a package for doing wgs84 calculations, which you may find useful > as a starting point. I can't remember wehther it produces > correct answers. Here is an excerpt, I can mail you the whole > package if you like: > > generic > type Float_Type is digits <>; > package WGS84_Package is > > -- first numerical eccentricity > e1sqr : constant := (a ** 2 - b ** 2) / (a ** 2) ; > > -- second numerical eccentricity > e2sqr : constant := (a ** 2 - b ** 2) / (b ** 2); > > ... > subtype Metres is Float_Type; > subtype Radians is Float_Type; > subtype Degrees is Float_Type; > > type ECEF is -- earth centreed earth fixed rectangular coordinate > system > record > X : Metres; -- though equator at prime meridian > Y : Metres; -- though equator 90 degrees east of prime > meridian > Z : Metres; -- through north pole > end record; > > > type Polar is > record > Latitude : Radians; > Longitude : Radians; > Altitude : Metres; > end record; > > type Azimuth_Elevation is > record > Azimuth : Radians; > Elevation : Radians; > Distance : Metres; > end record; > > ... > > package body WGS84_Package is > > -- converts Latitude, Longitude and Altitude (above ellipsoid) to > XYZ > function To_ECEF (From : in Polar) return ECEF is > N : Float_Type := a / sqrt (1.0 - e1sqr * sin (From.Latitude) ** > 2); > begin -- To_ECEF > return > (X => (N + From.Altitude) * cos (From.Latitude) * cos > (From.Longitude), > > Y => (N + From.Altitude) * cos (From.Latitude) * sin > (From.Longitude), > > Z => (N * (1.0 - e1sqr) + From.Altitude) * sin (From.Latitude) > ); > end To_ECEF; > > -- converts XYZ to Latitude, Longitude, Altitude (above ellipsoid) > function To_Polar (From : in ECEF) return Polar is > -- length projected onto equatorial plane; > P : Metres := sqrt (From.X ** 2 + From.Y ** 2); > > T : Float_Type := arctan ((From.Z * a) / (p * b)); > > N : Float_Type; > > Latitude, Longitude : Radians; > Altitude : Metres; > begin -- To_Polar > Latitude := arctan ((From.Z + e2sqr * b * Sin (T) ** 3) > / (P - e1sqr * a * Cos (T) ** 3)); > > if From.X = 0.0 then > Longitude := Pi / 2.0; > else > Longitude := arctan (From.Y / From.X); > end if; > > N := A / Sqrt (1.0 - e1sqr * sin (Latitude) ** 2); > Altitude := P / cos (Latitude) - N; > > return (Latitude, Longitude, Altitude); > > end To_Polar; > > ... -- Gary Scott mailto:scottg@flash.net mailto:webmaster@fortranlib.com http://www.fortranlib.com Support the GNU Fortran G95 Project: http://xena.eas.asu.edu/~andy/