~gpredict-team/gpredict/gpredict-packaging

« back to all changes in this revision

Viewing changes to src/tle-tools.c

  • Committer: Jan Simon
  • Date: 2011-12-04 19:31:47 UTC
  • Revision ID: jan.simon@gmx.de-20111204193147-qhwjxglv1f4i4442
rules: added autogen. Updated translation files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
 
/*
3
 
    Gpredict: Real-time satellite tracking and orbit prediction program
4
 
 
5
 
    Copyright (C)  2001-2009  Alexandru Csete, OZ9AEC.
6
 
    Parts are Copyright John A. Magliacane, KD2BD 1991-2003 (indicated below)
7
 
 
8
 
    Authors: Alexandru Csete <oz9aec@gmail.com>
9
 
             John A. Magliacane, KD2BD.
10
 
 
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:
14
 
 
15
 
            http://gpredict.oz9aec.net/
16
 
 
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.
21
 
  
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.
26
 
  
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/
29
 
*/
30
 
 
31
 
#include <glib.h>
32
 
#include <glib/gi18n.h>
33
 
#include "sgpsdp/sgp4sdp4.h"
34
 
#include "sat-log.h"
35
 
#ifdef HAVE_CONFIG_H
36
 
#  include <build-config.h>
37
 
#endif
38
 
#include "tle-tools.h"
39
 
 
40
 
 
41
 
 
42
 
 
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. 
51
 
 *
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.
56
 
 *
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.
62
 
 */
63
 
gint
64
 
twoline2tle (gchar *line1, gchar *line2, gchar *line3,
65
 
             gboolean checksum, tle_t *tle)
66
 
{
67
 
 
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;
73
 
    }
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;
78
 
    }
79
 
 
80
 
 
81
 
 
82
 
    return TLE_CONV_SUCCESS;
83
 
}
84
 
 
85
 
 
86
 
 
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
89
 
 *             converted.
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.
97
 
 *
98
 
 * \note An error message will be logged if an error occurs.
99
 
 */
100
 
gint
101
 
tle2twoline (tle_t *tle, gchar *line1, gchar *line2, gchar *line3)
102
 
{
103
 
    return TLE_CONV_SUCCESS;
104
 
}
105
 
 
106
 
 
107
 
 
108