[OSRS-PROJ] Using PROJ for location estimation in wireless environment

Bryan Ray bryan at jincsolutions.com
Fri May 30 16:09:34 PDT 2003


Hello,

I'm not sure on how to do this within Proj, but here are some Object
Pascal type functions that might help.

Bryan


//////////////////////////////////
/// this one will give you lat/lon of a away point based on input
lat/lon direction and distance.
//////////////////////////////////
Function LocationFromStation(incoordinates: GlobalCoordinate; direction:
Real;
  distance: Real): Real;
Var
  arcdistance, arcazimuth, arclat, r1, r2, tlat, tlong, azimuthlat,
azimuthlong: Real;
  s1, s2: String;
Begin
  arcdistance := ((distance / 60) * pi / 180);
  arcazimuth := (direction * pi / 180);
  arclat := (incoordinates.lat * pi / 180);
  r1 := sin(arclat) * cos(arcdistance);
  r2 := cos(arclat) * sin(arcdistance) * cos(arcazimuth);
  tlat := arcsin(r1 + r2);
  azimuthlat := tlat;
  tlong := arctan(sin(arcdistance) *
    sin(arcazimuth) / (cos(arclat) * cos(arcdistance) -
    sin(arclat) * sin(arcdistance) * cos(arcazimuth)));
  azimuthlong := incoordinates.lon + ((tlong / pi * 180));
  incoordinates.lat := azimuthlat;
  incoordinates.lon := azimuthlong;
  str(incoordinates.lat: 4: 2, s1);
  str(incoordinates.lon: 5: 2, s2);
End;

//////////////////////////////////
/// this one will give you distance based on 2 know lat/lon pairs
//////////////////////////////////
Function GlobeDistance(ic1, ic2: globalcoordinate): Real;
Var
  r1, r2, r3, r4, r5, r6: Real;
Begin
  If ((ic1.lat = ic2.lat) And (ic1.lon = ic2.lon)) Then
  Begin
    Result := 0;
  End
  Else
  Begin
    r1 := sin(ic1.lat * pi / 180) * sin(ic2.lat * pi / 180);
    r2 := cos(ic1.lat * pi / 180) * cos(ic2.lat * pi / 180);
    r3 := cos((ic2.lon * pi / 180) - (ic1.lon * pi / 180));
    r4 := r1 + (r2 * r3);
    r5 := arccos(r4);
    r6 := (r5 / pi * 180) * 60;
    Result := r6;
  End;
End;

//////////////////////////////////
/// this one will give you direction based on 2 know lat/lon pairs
//////////////////////////////////
//=========================================
{IC1 is the base point}
Function GlobeAngle(ic1, ic2: globalcoordinate): Real;
Var
  r1, r2, r3, r4, r5, r6, r7: Real;
Begin
  If ic2.lon <> ic1.lon Then
  Begin
    r1 := cos(ic2.lat * pi / 180);
    r2 := sin((ic2.lon * pi / 180) - (ic1.lon * pi / 180));
    r3 := cos(ic1.lat * pi / 180) * sin(ic2.lat * pi / 180);
    r4 := sin(ic1.lat * pi / 180) * cos(ic2.lat * pi / 180);
    r5 := cos((ic2.lon * pi / 180) - (ic1.lon * pi / 180));
    r6 := (r1 * r2) / (r3 - (r4 * r5));
    r7 := arctan(r6);
    r7 := r7 * 180 / pi;
    {IF TARGET POINT IS SOUTH OF BASE POINT, THEN THIS VALUE IS 91-269
DEG}
    //if (ic2.lat = ic1.lat) and (ic2.lon > ic1.lon) then r7 := 90;
    //if (ic2.lat = ic1.lat) and (ic2.lon < ic1.lon) then r7 := 270;
    If (ic2.lat < ic1.lat) Then
    Begin
      r7 := 180 + r7;
      If (ic2.lon > ic1.lon) And (r7 > 180) Then // number too big
        r7 := r7 - 180;
      If (ic2.lon < ic1.lon) And (r7 < 100) Then // number too small
        r7 := r7 + 180;
    End;
    If (r7 < 0) Then 
      r7 := r7 + 360;
    Result := r7;
  End;
End;


{----------------------------------------------}
// Input a ratio, output degrees
Function arcsin(sine: Real): Real;
Begin
  If (abs(sine) >= 1) Then
    sine := pi / 2
  Else
    sine := arctan(sine / sqrt(1 - sine * sine));
  sine := sine * 180 / pi;
  arcsin := sine;
End;

{---------------------------------------------------------}
Function arccos(cosine: Real): Real;
Var
  r1: Double;
Begin
  {
  r1 := pi/2-arcsin(cosine);
  }
  r1 := pi / 2 - (arcsin(cosine) * pi / 180);
  Result := r1;
End;

-----Original Message-----
From: owner-osrs-proj at remotesensing.org
[mailto:owner-osrs-proj at remotesensing.org] On Behalf Of Saxon
Robert-QA2183
Sent: Friday, May 30, 2003 3:48 PM
To: 'osrs-proj at remotesensing.org'
Subject: [OSRS-PROJ] Using PROJ for location estimation in wireless
environment


I am looking for a second method to use for location estimation. I am
working with a communication system that can provide some estimation on
distance. The setup is as follows:

 - I have 3 or more fixed positions in Lat/Long (GPS).
   Maximum distance between each point is under 30 miles.

 - I have a relative distance between my target location
   and each fixed point.

 - Goal is to provide estimate of Lat/Long of the target based
   on the fixed locations and the relative distance.

I have the following information:

  1. Lat/Long of fixed point F1.
  2. Distance in meter from target to F1.
  3. Lat/Long of fixed point F2.
  4. Distance in meter from target to F2.
  5. Lat/Long of fixed point F3.
  6. Distance in meter from target to F3

I am look for ideas on how to use "proj" software to guest-to-mate the
Lat/Long of my target location. I have software that does this but want
a "second opinion". Can I use "proj" commands to accomplish this goal?

Robert A. Saxon
----------------------------------------
PROJ.4 Discussion List
See http://www.remotesensing.org/proj for subscription, unsubscription
and other information.



----------------------------------------
PROJ.4 Discussion List
See http://www.remotesensing.org/proj for subscription, unsubscription
and other information.



More information about the Proj mailing list