RFC: Astro::ECI (or Astro::Coord::ECI, or ...)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I have been attempting to put together some satellite tracking (or at
least observing) modules in Perl. The code has fallen into three (so
far) modules: one representing the satellite, one representing the Sun,
and a superclass representing "static" (i.e. Earthbound) coordinates and
providing all the coordinate transformations. For the sake of
discussion, call the superclass Astro::ECI (for Earth-Centered
Inertial), and the subclasses Astro::ECI::TLE (for Two- (or three-, both
are handled) Line Element), and Astro::ECI::Sun (an exercise for the

The question is, what should I actually call these things? Does
Astro::TLE cut it, or do people think something like Astro::Coord::TLE
would be better? Or something else? I assume that if the superclass
changes names the subclasses will too, though Perl does not require it.

There's about 50% overlap between Astro::ECI (or whatever) and
Astro::Coords. The differences that come to mind are:

* Astro::Coords doesn't seem to be interested in the Earthbound side of
things. Astro::ECI does ECI (of course), geocentric Cartesian,
geocentric latitude/longitude, and geodetic latitude/longitude, with a
mechanism for user-defined reference ellipsoids. Different objects can
use different ellipsoids

* Astro::Coords relies on Astro::SLA and SLALIB, whereas Astro::ECI is
pure Perl.

* Astro::ECI is designed to be the superclass for a position predictor.
I can't really say about Astro::Coords.

* Astro::Coords spends a fair amount of time and effort worrying about
alternate representations of data (hour angles, degrees/minutes/seconds
of arc ...). Astro::ECI is radians and kilometers, period.

* Astro::Coords uses either Time::Piece or DateTime objects. Currently,
Astro::TLE uses scalar times, though it may support DateTime in the
future (and the check is in the mail ...).

* Astro::Coords is published under the GPL. I intend to publish under
the Perl Artistic License.

There's not as much overlap between the proposed Astro::ECI::Sun (or
whatever) and the Astro::Sun.* modules as might appear. Astro::ECI::Sun
calculates the position of the Sun at any given time, whereas the
Astro::Sun.* modules calculate local sunrise/sunset. The superclass
provides a method that gets you sunrise and sunset (or begin/end
twilight), and another for meridian passage (local noon, local
midnight). I _think_ that Astro::Coords will give the position of the
Sun and Moon, at least.

Astro::ECI::TLE implements the NORAD SGP.* and SDP.* orbital models. If
there's anything remotely similar in CPAN, I haven't found it.

Both suggestions and metasuggestions (i.e. possible additional or
alternate places to take the questions) are welcome. I can't guarantee
what will come out of all this, because I still need to figure out what
permissions I need before I publish, and whether I can get them.

Tom Wyant (mailing address to the contrary notwithstanding)

Modules with several packages

Hi list,

I'm trying to develop a mod_perl module with several packages.

At first, I created to separate modules called 'Skjaerlund::Apache' and
'Skjaerlund::Apache::Authenticate'. The first module is mandatory and
includes all the definitions for the Apache configuration file, whereas the
second module authenticates users against Novells eDir database through

In our world, that means Net::LDAP, of course. When done as described above,
everything works fine, but whenever I move the code of the second module
into the first module, things start acting weird - or maybe it's just my
lack of understanding ;-).

Anyway: Everything works fine when I have the two packages in two separate
files. When I run them from one module file, Net::LDAP works exactly four
times. I know because I log a line of the LDAP return code everytime I call
the authentication routine. The fifth time Net::LDAP is called, it returns
'Operations error' - which usually means some syntax error, but the code is
exactly the same as in the preceding four calls - and the sixth time it
returns "Can't contact LDAP server" and Apache dies.

Can anyone shed some light on this mystery?

The code goes here:

package Skjaerlund::Apache;

use strict;
use warnings;

require Exporter;

use Apache::Constants qw(:common);
use Apache::ModuleConfig ();
use DynaLoader ();

use Net::LDAP;

our @ISA = qw(DynaLoader Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS } );
our @EXPORT = qw(handler);

our $VERSION = '1.00';

if ($ENV) {

sub new {
  return bless {}, shift;

sub handler {
  return OK;

sub NDS_Context ($$$) {
  my ($cfg, $parms, $arg) = @_;
  my $scfg = Apache::ModuleConfig->get($parms->server);
  $scfg-> = $arg;

sub NDS_LDAPBindUser ($$$) {
  my ($cfg, $parms, $arg) = @_;
  my $scfg = Apache::ModuleConfig->get($parms->server);
  $scfg-> = $arg;

sub NDS_LDAPBindPassword ($$$) {
  my ($cfg, $parms, $arg) = @_;
  my $scfg = Apache::ModuleConfig->get($parms->server);
  $scfg-> = $arg;

sub NDS_LDAPServer ($$$) {
  my ($cfg, $parms, $arg) = @_;
  my $scfg = Apache::ModuleConfig->get($parms->server);
  $scfg-> = $arg;


package Skjaerlund::Apache::Authenticate;

use strict;

use Apache::Constants qw(:common);
use Net::LDAP;

my $ldap;

sub BEGIN {
  $ldap = Net::LDAP->new('localhost', version => 3);

  my $msg = $ldap->start_tls(verify => 'require', cafile =>
  $msg->code && die $msg->error;

  $msg = $ldap->bind('cn=admin,o=admin', password => '******');
  $msg->code && die $msg->error;

sub handler {
  my $r = shift;

  my($result, $password) = $r->get_basic_auth_pw;
  return $result if $result != OK;
  my $user = $r->connection->user;

  my $cfg = Apache::ModuleConfig->get($r->server, 'Skjaerlund::Apache');

  $user = 'cn=' . $user . ',' . $cfg->;

  my $msg = $ldap->compare($user, attr => 'userpassword', value =>

  warn "LDAP returned ", $msg->error, " code ", $msg->code;

  if ($msg->code == 6) {
    return OK;
  } else {
    return AUTH_REQUIRED;



Debat om jernbaner i stort og smt
Min private bane

Site Timeline