Documentation ¶
Overview ¶
Package gompcreader provides a simple method to read the Minor Planet Center data files.
Designed to load the files from http://www.minorplanetcenter.net/iau/MPCORB.html and http://www.minorplanetcenter.net/iau/ECS/MPCAT/MPCAT.html
This will not read the comets files or the observations files. If you try you will probably find the first call to ReadEntry() returns io.EOF as it has skipped all the records in the file.
This can handle both the gzipped and uncompressed versions of the files. If you need speed and don't care about space use the uncompressed versions.
To read a file first construct a MpcReader using the NewMpcReader(string) function. This requires the path to a file.
Each record is read using the ReadEntry() function. Note this may consume more than one line from the file if the next line is not the correct length. These are usually the comments at the top of the file or the blank section sperators. When you get to the end of the file this will return io.EOF.
Finaly when you are done with the reader you should Close() it. This should normally be defered.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MinorPlanet ¶
type MinorPlanet struct { ID string AbsoluteMagnitude float64 Slope float64 Epoch time.Time MeanAnomalyEpoch float64 ArgumentOfPerihelion float64 LongitudeOfTheAscendingNode float64 InclinationToTheEcliptic float64 OrbitalEccentricity float64 MeanDailyMotion float64 SemimajorAxis float64 UncertaintyParameter string Reference string NumberOfObservations int64 NumberOfOppositions int64 RMSResidual float64 CoarseIndicatorOfPerturbers string PreciseIndicatorOfPerturbers string ComputerName string HexDigitFlags int64 ReadableDesignation string DateOfLastObservation time.Time YearOfFirstObservation int64 YearOfLastObservation int64 ArcLength int64 }
MinorPlanet is the result of reading a record from a file
type MpcReader ¶
type MpcReader struct {
// contains filtered or unexported fields
}
MpcReader is a simple data structure to keep track of readers and scanners for reading the requested file. Should be constructed using NewMpcReader(string) and closed using Close() before disposal.
func NewMpcReader ¶
NewMpcReader is used to create a new minor planet center reader.
This takes a path as a string to the file and returns the reader structure.
If there is a problem opening the file it will return nil for the reader and an error indicating what went wrong.
This will automatically detect if the file extension suggests a gziped version of the file and open it correctly.
func (*MpcReader) Close ¶
func (reader *MpcReader) Close()
Close the reader down. This will clean up the open file handle.
This should be defered just after NewMpcReader has been called
func (*MpcReader) ReadEntry ¶
func (reader *MpcReader) ReadEntry() (*MinorPlanet, error)
ReadEntry returns the next minor planet from the file or error if there is a problem reading the record.
Note: this will return an io.EOF when the end of the file is reached.