From: Dirk Koopman Date: Wed, 3 Jun 2020 19:42:27 +0000 (+0100) Subject: fix regex parse in sh/dx, add DXBearing::distance X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=8106275008346b0cceb090f7317ff4240a3ba44f;p=spider.git fix regex parse in sh/dx, add DXBearing::distance --- diff --git a/cmd/show/dx.pl b/cmd/show/dx.pl index c0c43fa3..655630ce 100644 --- a/cmd/show/dx.pl +++ b/cmd/show/dx.pl @@ -11,10 +11,20 @@ sub handle { my ($self, $line) = @_; + # disguise regexes + $line =~ s/\{(.*)\}/'{'. unpack('H*', $1) . '}'/eg; + dbg("sh/dx disguise any regex: '$line'") if isdbg('sh/dx'); + + # now space out brackets and ! $line =~ s/([\(\!\)])/ $1 /g; my @list = split /[\s]+/, $line; # split the line up + # put back the regexes + @list = map { my $l = $_; $l =~ s/\{([0-9a-fA-F]+)\}/'{' . pack('H*', $1) . '}'/eg; $l } @list; + + dbg("sh/dx after regex return: " . join(' ', @list)) if isdbg('sh/dx'); + my @out; my $f; my $call = $self->call; diff --git a/perl/DXBearing.pm b/perl/DXBearing.pm index b98d746a..db6f4686 100644 --- a/perl/DXBearing.pm +++ b/perl/DXBearing.pm @@ -101,6 +101,20 @@ sub bdist return (rd($az), $dx); } +# just the distance - parameters as above +sub distance +{ + my $hn = dr(shift); + my $he = dr(shift); + my $n = dr(shift); + my $e = dr(shift); + return (0, 0) if $hn == $n && $he == $e; + my $co = cos($he-$e)*cos($hn)*cos($n)+sin($hn)*sin($n); + my $ca = $co ? atan(abs(sqrt(1-$co*$co)/$co)) : $pi; + $ca = $pi-$ca if $co < 0; + my $dx = 6367*$ca; +} + # turn a lat long string into floating point lat and long sub stoll {