Display Az and Dist when "hisGrid" is known and valid.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3075 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2013-03-23 15:41:31 +00:00
parent c1126bcb88
commit 75f68cc07a
5 changed files with 244 additions and 5 deletions

107
lib/azdist.f90 Normal file
View File

@ -0,0 +1,107 @@
subroutine azdist(MyGrid,HisGrid,utch,nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter)
character*6 MyGrid,HisGrid,mygrid0,hisgrid0
real*8 utch,utch0
logical HotABetter,IamEast
real eltab(22),daztab(22)
data eltab/18.,15.,13.,11.,9.,8.,7.,6.,5.3,4.7,4.,3.3,2.7, &
2.,1.5,1.,0.8,0.6,0.4,0.2,0.0,0.0/
data daztab/21.,18.,16.,15.,14.,13.,12.,11.,10.7,10.3,10., &
10.,10.,10.,10.,10.,10.,9.,9.,9.,8.,8./
data mygrid0/" "/,hisgrid0/" "/,utch0/-999.d0/
save
if(MyGrid.eq.HisGrid) then
naz=0
nel=0
ndmiles=0
ndkm=0
nhotaz=0
nhotabetter=1
go to 999
endif
if(mygrid.eq.mygrid0 .and. hisgrid.eq.hisgrid0 .and. &
abs(utch-utch0).lt.0.1666667d0) go to 900
utch0=utch
mygrid0=mygrid
hisgrid0=hisgrid
utchours=utch
if(MyGrid(5:5).eq.' ') MyGrid(5:5)='m'
if(MyGrid(6:6).eq.' ') MyGrid(6:6)='m'
if(HisGrid(5:5).eq.' ') HisGrid(5:5)='m'
if(HisGrid(6:6).eq.' ') HisGrid(6:6)='m'
if(MyGrid.eq.HisGrid) then
Az=0.
Dmiles=0.
Dkm=0.0
El=0.
HotA=0.
HotB=0.
HotABetter=.true.
go to 900
endif
call grid2deg(MyGrid,dlong1,dlat1)
call grid2deg(HisGrid,dlong2,dlat2)
call geodist(dlat1,dlong1,dlat2,dlong2,Az,Baz,Dkm)
ndkm=Dkm/100
j=ndkm-4
if(j.lt.1) j=1
if(j.gt.21)j=21
if(Dkm.lt.500.0) then
El=18.0
else
u=(Dkm-100.0*ndkm)/100.0
El=(1.0-u)*eltab(j) + u*eltab(j+1)
endif
daz=daztab(j) + u * (daztab(j+1)-daztab(j))
Dmiles=Dkm/1.609344
tmid=mod(UTChours-0.5*(dlong1+dlong2)/15.0+48.0,24.0)
IamEast=.false.
if(dlong1.lt.dlong2) IamEast=.true.
if(dlong1.eq.dlong2 .and. dlat1.gt.dlat2) IamEast=.false.
azEast=baz
if(IamEast) azEast=az
if((azEast.ge.45.0 .and. azEast.lt.135.0) .or. &
(azEast.ge.225.0 .and. azEast.lt.315.0)) then
! The path will be taken as "east-west".
HotABetter=.true.
if(abs(tmid-6.0).lt.6.0) HotABetter=.false.
if((dlat1+dlat2)/2.0 .lt. 0.0) HotABetter=.not.HotABetter
else
! The path will be taken as "north-south".
HotABetter=.false.
if(abs(tmid-12.0).lt.6.0) HotABetter=.true.
endif
if(IamEast) then
HotA = Az - daz
HotB = Az + daz
else
HotA = Az + daz
HotB = Az - daz
endif
if(HotA.lt.0.0) HotA=HotA+360.0
if(HotA.gt.360.0) HotA=HotA-360.0
if(HotB.lt.0.0) HotB=HotB+360.0
if(HotB.gt.360.0) HotB=HotB-360.0
900 continue
naz=nint(Az)
nel=nint(el)
nDmiles=nint(Dmiles)
nDkm=nint(Dkm)
nHotAz=nint(HotB)
nHotABetter=0
if(HotABetter) then
nHotAz=nint(HotA)
nHotABetter=1
endif
999 return
end subroutine azdist

96
lib/geodist.f90 Normal file
View File

@ -0,0 +1,96 @@
subroutine geodist(Eplat,Eplon,Stlat,Stlon,Az,Baz,Dist)
implicit none
real eplat, eplon, stlat, stlon, az, baz, dist
! JHT: In actual fact, I use the first two arguments for "My Location",
! the second two for "His location"; West longitude is positive.
! Taken directly from:
! Thomas, P.D., 1970, Spheroidal geodesics, reference systems,
! & local geometry, U.S. Naval Oceanographi!Office SP-138,
! 165 pp.
! assumes North Latitude and East Longitude are positive
! EpLat, EpLon = End point Lat/Long
! Stlat, Stlon = Start point lat/long
! Az, BAz = direct & reverse azimuith
! Dist = Dist (km); Deg = central angle, discarded
real BOA, F, P1R, P2R, L1R, L2R, DLR, T1R, T2R, TM, &
DTM, STM, CTM, SDTM,CDTM, KL, KK, SDLMR, L, &
CD, DL, SD, T, U, V, D, X, E, Y, A, FF64, TDLPM, &
HAPBR, HAMBR, A1M2, A2M1
real AL,BL,D2R,Pi2
data AL/6378206.4/ ! Clarke 1866 ellipsoid
data BL/6356583.8/
! real pi /3.14159265359/
data D2R/0.01745329251994/ ! degrees to radians conversion factor
data Pi2/6.28318530718/
BOA = BL/AL
F = 1.0 - BOA
! Convert st/end pts to radians
P1R = Eplat * D2R
P2R = Stlat * D2R
L1R = Eplon * D2R
L2R = StLon * D2R
DLR = L2R - L1R ! DLR = Delta Long in Rads
T1R = ATan(BOA * Tan(P1R))
T2R = ATan(BOA * Tan(P2R))
TM = (T1R + T2R) / 2.0
DTM = (T2R - T1R) / 2.0
STM = Sin(TM)
CTM = Cos(TM)
SDTM = Sin(DTM)
CDTM = Cos(DTM)
KL = STM * CDTM
KK = SDTM * CTM
SDLMR = Sin(DLR/2.0)
L = SDTM * SDTM + SDLMR * SDLMR * (CDTM * CDTM - STM * STM)
CD = 1.0 - 2.0 * L
DL = ACos(CD)
SD = Sin(DL)
T = DL/SD
U = 2.0 * KL * KL / (1.0 - L)
V = 2.0 * KK * KK / L
D = 4.0 * T * T
X = U + V
E = -2.0 * CD
Y = U - V
A = -D * E
FF64 = F * F / 64.0
Dist = AL*SD*(T -(F/4.0)*(T*X-Y)+FF64*(X*(A+(T-(A+E) &
/2.0)*X)+Y*(-2.0*D+E*Y)+D*X*Y))/1000.0
TDLPM = Tan((DLR+(-((E*(4.0-X)+2.0*Y)*((F/2.0)*T+FF64* &
(32.0*T+(A-20.0*T)*X-2.0*(D+2.0)*Y))/4.0)*Tan(DLR)))/2.0)
HAPBR = ATan2(SDTM,(CTM*TDLPM))
HAMBR = Atan2(CDTM,(STM*TDLPM))
A1M2 = Pi2 + HAMBR - HAPBR
A2M1 = Pi2 - HAMBR - HAPBR
1 If ((A1M2 .ge. 0.0) .AND. (A1M2 .lt. Pi2)) GOTO 5
If (A1M2 .lt. Pi2) GOTO 4
A1M2 = A1M2 - Pi2
GOTO 1
4 A1M2 = A1M2 + Pi2
GOTO 1
! All of this gens the proper az, baz (forward and back azimuth)
5 If ((A2M1 .ge. 0.0) .AND. (A2M1 .lt. Pi2)) GOTO 9
If (A2M1 .lt. Pi2) GOTO 8
A2M1 = A2M1 - Pi2
GOTO 5
8 A2M1 = A2M1 + Pi2
GOTO 5
9 Az = A1M2 / D2R
BAZ = A2M1 / D2R
!Fix the mirrored coords here.
az = 360.0 - az
baz = 360.0 - baz
end subroutine geodist

View File

@ -133,6 +133,7 @@ MainWindow::MainWindow(QWidget *parent) :
decodeBusy(false);
ui->xThermo->setFillBrush(Qt::green);
ui->labAzDist->setStyleSheet("border: 0px;");
#ifdef WIN32
while(true) {
@ -1702,6 +1703,19 @@ void MainWindow::on_dxGridEntry_textChanged(const QString &t) //dxGrid changed
if(n==6) m_hisGrid=t.mid(0,2).toUpper() + t.mid(2,2) +
t.mid(4,2).toLower();
ui->dxGridEntry->setText(m_hisGrid);
if(gridOK(m_hisGrid)) {
qint64 nsec = QDateTime::currentMSecsSinceEpoch() % 86400;
double utch=nsec/3600.0;
int nAz,nEl,nDmiles,nDkm,nHotAz,nHotABetter;
azdist_(m_myGrid.toAscii().data(),m_hisGrid.toAscii().data(),&utch,
&nAz,&nEl,&nDmiles,&nDkm,&nHotAz,&nHotABetter,6,6);
QString t;
t.sprintf("Az: %d %d km",nAz,nDkm);
ui->labAzDist->setText(t);
} else {
ui->labAzDist->setText("");
}
}
void MainWindow::on_genStdMsgsPushButton_clicked() //genStdMsgs button
@ -1891,6 +1905,7 @@ void MainWindow::on_actionErase_wsjtx_log_adi_triggered()
void MainWindow::showMacros(const QPoint &pos)
{
if(m_macro.length()<10) return;
QPoint globalPos = ui->tx5->mapToGlobal(pos);
QMenu popupMenu;
QAction* popup1 = new QAction(m_macro[0],ui->tx5);

View File

@ -268,6 +268,10 @@ void genjt9_(char* msg, int* ichk, char* msgsent, int itone[],
int* itext, int len1, int len2);
bool stdmsg_(const char* msg);
void azdist_(char* MyGrid, char* HisGrid, double* utch, int* nAz, int* nEl,
int* nDmiles, int* nDkm, int* nHotAz, int* nHotABetter,
int len1, int len2);
}
#endif // MAINWINDOW_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>643</width>
<height>536</height>
<height>527</height>
</rect>
</property>
<property name="sizePolicy">
@ -321,7 +321,7 @@ p, li { white-space: pre-wrap; }
<property name="maximumSize">
<size>
<width>290</width>
<height>115</height>
<height>135</height>
</size>
</property>
<property name="styleSheet">
@ -355,7 +355,7 @@ p, li { white-space: pre-wrap; }
<x>8</x>
<y>14</y>
<width>128</width>
<height>87</height>
<height>113</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
@ -456,6 +456,22 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labAzDist">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="genStdMsgsPushButton">
<property name="maximumSize">
@ -478,7 +494,7 @@ p, li { white-space: pre-wrap; }
<property name="maximumSize">
<size>
<width>150</width>
<height>60</height>
<height>52</height>
</size>
</property>
<property name="font">
@ -499,7 +515,8 @@ p, li { white-space: pre-wrap; }
<number>0</number>
</property>
<property name="text">
<string> 01:23:45 </string>
<string>2013 Mar 23
01:23:45 </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>