1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3
Gpredict: Real-time satellite tracking and orbit prediction program
5
Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC.
6
Parts are Copyright John A. Magliacane, KD2BD 1991-2003 (indicated below)
8
Authors: Alexandru Csete <oz9aec@gmail.com>
9
John A. Magliacane, KD2BD.
11
Comments, questions and bugreports should be submitted via
12
http://sourceforge.net/projects/gpredict/
13
More details can be found at the project home page:
15
http://gpredict.oz9aec.net/
17
This program is free software; you can redistribute it and/or modify
18
it under the terms of the GNU General Public License as published by
19
the Free Software Foundation; either version 2 of the License, or
20
(at your option) any later version.
22
This program is distributed in the hope that it will be useful,
23
but WITHOUT ANY WARRANTY; without even the implied warranty of
24
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
GNU General Public License for more details.
27
You should have received a copy of the GNU General Public License
28
along with this program; if not, visit http://www.fsf.org/
32
#include <glib/gi18n.h>
33
#include "sgpsdp/sgp4sdp4.h"
36
# include <build-config.h>
38
#include "tle-tools.h"
43
/** \brief Convert NASA 2-line orbital element set to tle_t structure.
44
* \param line1 The first line containing the satellite name.
45
* \param line2 The second line.
46
* \param line3 The third line.
47
* \param checksum Flag indicating whether to perform checksum check.
48
* \param tle Pointer to a tle_t structure where the TLE data will be put.
49
* \return TLE_CONV_SUCCESS if the conversion is successful or TLE_CONV_ERROR
50
* if an error has occurred during the conversion.
52
* This function converts NASA 2-line orbital element data (as read from a tle
53
* file) into a tle_t structure, which is used all over in gpredict. Note that
54
* a standard 2-line data actually consists of three lines, the extra line
55
* containing the name of the satellite in a field of 25 characters.
57
* The flag checksum can be used to control whether verification of the checksum
58
* should be fperformed or not. If the flag is TRUE and the checksum is invalid,
59
* an error message is logged and the function returns TLE_CONV_ERROR. The caller
60
* can still ignore the error code since the tle structure will be populated;
61
* however, the data may be nonsense.
64
twoline2tle (gchar *line1, gchar *line2, gchar *line3,
65
gboolean checksum, tle_t *tle)
68
/* check function parameters */
69
if G_UNLIKELY((line1 == NULL) || (line2 == NULL) || (line3 == NULL)) {
70
sat_log_log (SAT_LOG_LEVEL_BUG,
71
_("%s: NULL input data!"), __FUNCTION__);
72
return TLE_CONV_ERROR;
74
if G_UNLIKELY(tle == NULL) {
75
sat_log_log (SAT_LOG_LEVEL_BUG,
76
_("%s: NULL output storage!"), __FUNCTION__);
77
return TLE_CONV_ERROR;
82
return TLE_CONV_SUCCESS;
87
/** \brief Convert internal tle_t structure to NASA 2-line oribital element set.
88
* \param tle Pointer to the tle_t structure that holds the data to be
90
* \param line1 Pointer to unallocated memory where the first line will be
91
* stored. The pointer should be freed when no longer needed.
92
* \param line2 Pointer to unallocated memory where the second line will be
93
* stored. The pointer should be freed when no longer needed.
94
* \param line3 Pointer to unallocated memory where the third line will be
95
* stored. The pointer should be freed when no longer needed.
96
* \return TLE_CONV_SUCCESS if conversion went OK, TLE_CONV_ERROR otherwise.
98
* \note An error message will be logged if an error occurs.
101
tle2twoline (tle_t *tle, gchar *line1, gchar *line2, gchar *line3)
103
return TLE_CONV_SUCCESS;