diff --git a/.gitignore b/.gitignore index 3f3d4ec..378eac2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1 @@ -libgpredict.a -sgpsdp/*.o -sgpsdp/test-001 -sgpsdp/test-002 -iss-test -*.o +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9d5bf13 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,60 @@ +cmake_minimum_required(VERSION 2.8) + +# set to ON, to build libgpredict as .so +option(BUILD_SHARED_LIBS "Build shared libraries" OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +project (gpredict) +set(CMAKE_BUILD_TYPE Release) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + +if(APPLE) + set(CMAKE_MACOSX_RPATH ON) +endif() + +# Glib +# cmake/FindGlib.cmake is taken from https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGLIB.cmake +find_package(Glib REQUIRED) +include_directories(${GLIB_INCLUDE_DIR}) +include_directories(${GLIBCONFIG_INCLUDE_DIR}) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +add_library(gpredict + sgpsdp/solar.c + sgpsdp/sgp_obs.c + sgpsdp/sgp_in.c + sgpsdp/sgp_time.c + sgpsdp/sgp_math.c + sgpsdp/sgp4sdp4.c + predict-tools.c + time-tools.c + orbit-tools.c + gtk-sat-data.c + qth-data.c + sat-vis.c +) + +# link glib +target_link_libraries(gpredict ${GLIB_LIBRARIES}) + +install (TARGETS gpredict + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) + +INSTALL(FILES + gpredict.h + gtk-sat-data.h + orbit-tools.h + predict-tools.h + qth-data.h + sat-vis.h + time-tools.h + DESTINATION "include/gpredict" + ) +INSTALL(FILES + sgpsdp/sgp4sdp4.h + DESTINATION "include/gpredict/sgpsdp" + ) diff --git a/Makefile b/Makefile deleted file mode 100644 index d76512c..0000000 --- a/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -all: all-components libgpredict.a -all-components: sgpsdp/sgp_time.o sgpsdp/sgp_math.o sgpsdp/sgp4sdp4.o sgpsdp/sgp_in.o sgpsdp/sgp_obs.o sgpsdp/solar.o time-tools.o predict-tools.o gtk-sat-data.o orbit-tools.o qth-data.o sat-vis.o -sgpsdp/solar.o: - gcc -c sgpsdp/solar.c -Wall -o sgpsdp/solar.o `pkg-config --cflags --libs glib-2.0` -lm -sgpsdp/sgp_obs.o: - gcc -c sgpsdp/sgp_obs.c -Wall -o sgpsdp/sgp_obs.o `pkg-config --cflags --libs glib-2.0` -lm -sgpsdp/sgp_in.o: - gcc -c sgpsdp/sgp_in.c -Wall -o sgpsdp/sgp_in.o `pkg-config --cflags --libs glib-2.0` -lm -sgpsdp/sgp_time.o: - gcc -c sgpsdp/sgp_time.c -Wall -o sgpsdp/sgp_time.o `pkg-config --cflags --libs glib-2.0` -lm -sgpsdp/sgp_math.o: - gcc -c sgpsdp/sgp_math.c -Wall -o sgpsdp/sgp_math.o `pkg-config --cflags --libs glib-2.0` -lm -sgpsdp/sgp4sdp4.o: sgpsdp/sgp_math.o - gcc -c sgpsdp/sgp4sdp4.c -Wall -o sgpsdp/sgp4sdp4.o `pkg-config --cflags --libs glib-2.0` -lm -predict-tools.o: sgpsdp/sgp4sdp4.o - gcc -c predict-tools.c -Wall -o predict-tools.o `pkg-config --cflags --libs glib-2.0` -time-tools.o: sgpsdp/sgp4sdp4.o - gcc -c time-tools.c -Wall -o time-tools.o `pkg-config --cflags --libs glib-2.0` -orbit-tools.o: - gcc -c orbit-tools.c -Wall -o orbit-tools.o `pkg-config --cflags --libs glib-2.0` -gtk-sat-data.o: - gcc -c gtk-sat-data.c -Wall -o gtk-sat-data.o `pkg-config --cflags --libs glib-2.0` -qth-data.o: - gcc -c qth-data.c -Wall -o qth-data.o `pkg-config --cflags --libs glib-2.0` -sat-vis.o: - gcc -c sat-vis.c -Wall -o sat-vis.o `pkg-config --cflags --libs glib-2.0` -sgpsdp/test-001: libgpredict.a - gcc sgpsdp/test-001.c -Wall -o sgpsdp/test-001 -L. -lgpredict `pkg-config --cflags --libs glib-2.0` -lm -sgpsdp/test-002: libgpredict.a - gcc sgpsdp/test-002.c -Wall -o sgpsdp/test-002 -L. -lgpredict `pkg-config --cflags --libs glib-2.0` -lm -iss-test: libgpredict.a - gcc iss-test.c -Wall -o iss-test -L. -lgpredict `pkg-config --cflags --libs glib-2.0` -lm -test: sgpsdp/test-001 sgpsdp/test-002 iss-test - (cd sgpsdp; ./test-001; ./test-002; ../iss-test) -libgpredict.a: all-components - ar rcs libgpredict.a sgpsdp/sgp_time.o sgpsdp/sgp_math.o sgpsdp/sgp4sdp4.o sgpsdp/sgp_in.o sgpsdp/sgp_obs.o sgpsdp/solar.o predict-tools.o time-tools.o gtk-sat-data.o orbit-tools.o qth-data.o sat-vis.o - -clean: - rm -f `find . | egrep '(\.o$$|\.a$$)'` - rm -f sgpsdp/test-001 sgpsdp/test-002 iss-test diff --git a/README.md b/README.md index 25bbe28..5f08eef 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,47 @@ -This is an attempt to take the prediction code from Gpredict and make it a -library for use with a PHP extension or other things. Not ready for consumption yet. +# libgpredict -Dependencies: +This is an attempt to take the prediction code out of Gpredict and make it a standalone dynamic +library. -On a stock ubuntu system, you may need to run: +## dependencies +### mac os x - sudo apt-get install make pkg-config libgtk2.0-dev + brew install glib -Once that's done, you should be able to run +### linux - make test + sudo apt-get install libglib2.0-dev + +## install + + git clone https://github.com/cubehub/libgpredict.git + cd libgpredict + mkdir build + cd build + cmake ../ + make + make install + sudo ldconfig # for linux + +## test + + cd test + mkdir build + cd build + cmake ../ + make + ./iss-test + +It should print this: + +``` +Testing a single ISS prediction + +TLE Data OK + +Lat: 18.389813558938 (expected: 18.389606541458) +Lon: -36.880015960342 (expected: -36.879846099166) +Alt: 409.7429431026 (expected: 409.7429029679) +Footprint: 4454.9076239034 (expected: 4454.9074167831) +Velocity: 7.6691931516 (expected: 7.66919316690) +``` diff --git a/cmake/FindGlib.cmake b/cmake/FindGlib.cmake new file mode 100644 index 0000000..599a4e3 --- /dev/null +++ b/cmake/FindGlib.cmake @@ -0,0 +1,120 @@ +# - Try to find Glib and its components (gio, gobject etc) +# Once done, this will define +# +# GLIB_FOUND - system has Glib +# GLIB_INCLUDE_DIRS - the Glib include directories +# GLIB_LIBRARIES - link these to use Glib +# +# Optionally, the COMPONENTS keyword can be passed to find_package() +# and Glib components can be looked for. Currently, the following +# components can be used, and they define the following variables if +# found: +# +# gio: GLIB_GIO_LIBRARIES +# gobject: GLIB_GOBJECT_LIBRARIES +# gmodule: GLIB_GMODULE_LIBRARIES +# gthread: GLIB_GTHREAD_LIBRARIES +# +# Note that the respective _INCLUDE_DIR variables are not set, since +# all headers are in the same directory as GLIB_INCLUDE_DIRS. +# +# Copyright (C) 2012 Raphael Kubo da Costa +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS +# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +find_package(PkgConfig) +pkg_check_modules(PC_GLIB QUIET glib-2.0) + +find_library(GLIB_LIBRARIES + NAMES glib-2.0 + HINTS ${PC_GLIB_LIBDIR} + ${PC_GLIB_LIBRARY_DIRS} +) + +# Files in glib's main include path may include glibconfig.h, which, +# for some odd reason, is normally in $LIBDIR/glib-2.0/include. +get_filename_component(_GLIB_LIBRARY_DIR ${GLIB_LIBRARIES} PATH) +find_path(GLIBCONFIG_INCLUDE_DIR + NAMES glibconfig.h + HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${_GLIB_LIBRARY_DIR} + ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} + PATH_SUFFIXES glib-2.0/include +) + +find_path(GLIB_INCLUDE_DIR + NAMES glib.h + HINTS ${PC_GLIB_INCLUDEDIR} + ${PC_GLIB_INCLUDE_DIRS} + PATH_SUFFIXES glib-2.0 +) + +set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIBCONFIG_INCLUDE_DIR}) + +# Version detection +file(READ "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h" GLIBCONFIG_H_CONTENTS) +string(REGEX MATCH "#define GLIB_MAJOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") +set(GLIB_VERSION_MAJOR "${CMAKE_MATCH_1}") +string(REGEX MATCH "#define GLIB_MINOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") +set(GLIB_VERSION_MINOR "${CMAKE_MATCH_1}") +string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}") +set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}") +set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}") + +# Additional Glib components. We only look for libraries, as not all of them +# have corresponding headers and all headers are installed alongside the main +# glib ones. +foreach (_component ${GLIB_FIND_COMPONENTS}) + if (${_component} STREQUAL "gio") + find_library(GLIB_GIO_LIBRARIES NAMES gio-2.0 HINTS ${_GLIB_LIBRARY_DIR}) + set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GIO_LIBRARIES) + elseif (${_component} STREQUAL "gobject") + find_library(GLIB_GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${_GLIB_LIBRARY_DIR}) + set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GOBJECT_LIBRARIES) + elseif (${_component} STREQUAL "gmodule") + find_library(GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 HINTS ${_GLIB_LIBRARY_DIR}) + set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GMODULE_LIBRARIES) + elseif (${_component} STREQUAL "gthread") + find_library(GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 HINTS ${_GLIB_LIBRARY_DIR}) + set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GTHREAD_LIBRARIES) + elseif (${_component} STREQUAL "gio-unix") + # gio-unix is compiled as part of the gio library, but the include paths + # are separate from the shared glib ones. Since this is currently only used + # by WebKitGTK+ we don't go to extraordinary measures beyond pkg-config. + pkg_check_modules(GIO_UNIX QUIET gio-unix-2.0) + endif () +endforeach () + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS} + VERSION_VAR GLIB_VERSION) + +mark_as_advanced( + GLIBCONFIG_INCLUDE_DIR + GLIB_GIO_LIBRARIES + GLIB_GIO_UNIX_LIBRARIES + GLIB_GMODULE_LIBRARIES + GLIB_GOBJECT_LIBRARIES + GLIB_GTHREAD_LIBRARIES + GLIB_INCLUDE_DIR + GLIB_INCLUDE_DIRS + GLIB_LIBRARIES +) \ No newline at end of file diff --git a/libgpredict.h b/gpredict.h similarity index 100% rename from libgpredict.h rename to gpredict.h diff --git a/gtk-sat-data.c b/gtk-sat-data.c index d7b3770..0e9e453 100644 --- a/gtk-sat-data.c +++ b/gtk-sat-data.c @@ -11,30 +11,28 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ #include -#include #include "sgpsdp/sgp4sdp4.h" #include "gtk-sat-data.h" #include "orbit-tools.h" #include "time-tools.h" - /** \brief Initialise satellite data. * \param sat The satellite to initialise. * \param qth Optional QTH info, use (0,0) if NULL. @@ -86,7 +84,7 @@ gtk_sat_data_init_sat (sat_t *sat, qth_t *qth) while (sat_geodetic.lon < -pi) sat_geodetic.lon += twopi; - + while (sat_geodetic.lon > (pi)) sat_geodetic.lon -= twopi; @@ -182,7 +180,7 @@ void gtk_sat_data_copy_sat (const sat_t *source, sat_t *dest, qth_t *qth) /** \brief Free satellite data * \param sat Pointer to the satellite data to free - * + * * This function frees the memory that has been dyunamically allocated * when creating a new satellite object. */ @@ -202,7 +200,7 @@ void gtk_sat_data_free_sat(sat_t *sat) g_free(sat->website); sat->website=NULL; } - + g_free(sat); } } diff --git a/orbit-tools.c b/orbit-tools.c index 7004ce8..881ab05 100644 --- a/orbit-tools.c +++ b/orbit-tools.c @@ -13,28 +13,26 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ #include -#include #include "sgpsdp/sgp4sdp4.h" #include "orbit-tools.h" - orbit_type_t get_orbit_type (sat_t *sat) { @@ -92,13 +90,13 @@ gboolean decayed (sat_t *sat) { - /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the + /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the value matches up with the value in predict 2.2.3 */ - /*** FIXME decayed is treated as a static quantity. - It is time dependent. Also sat->jul_utc is often zero + /*** FIXME decayed is treated as a static quantity. + It is time dependent. Also sat->jul_utc is often zero when this function is called ***/ - if (sat->jul_epoch + ((16.666666 - sat->meanmo) / + if (sat->jul_epoch + ((16.666666 - sat->meanmo) / (10.0 * fabs (sat->tle.xndt2o/(twopi/xmnpda/xmnpda)))) < sat->jul_utc) return TRUE; else diff --git a/predict-tools.c b/predict-tools.c index 4647fbf..ede8464 100644 --- a/predict-tools.c +++ b/predict-tools.c @@ -13,33 +13,27 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ #include -#include #include "sgpsdp/sgp4sdp4.h" -/* #ifdef HAVE_CONFIG_H -# include -#endif */ #include "gtk-sat-data.h" #include "time-tools.h" -/* #include "sat-cfg.h" */ #include "orbit-tools.h" #include "predict-tools.h" -/* #include "sat-log.h" */ /** \brief SGP4SDP4 driver for doing AOS/LOS calculations. @@ -135,7 +129,7 @@ find_aos (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt) predict_calc (sat, qth, start); /* check whether satellite has aos */ - if ((sat->otype == ORBIT_TYPE_GEO) || + if ((sat->otype == ORBIT_TYPE_GEO) || (sat->otype == ORBIT_TYPE_DECAYED) || !has_aos (sat, qth)) { @@ -234,7 +228,7 @@ find_los (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt) predict_calc (sat, qth, start); /* check whether satellite has aos */ - if ((sat->otype == ORBIT_TYPE_GEO) || + if ((sat->otype == ORBIT_TYPE_GEO) || (sat->otype == ORBIT_TYPE_DECAYED) || !has_aos (sat, qth)) { @@ -265,10 +259,10 @@ find_los (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt) /* fine steps */ while ((lostime == 0.0) && (t <= (start + maxdt))) { - + t += sat->el * sqrt(sat->alt)/502500.0; predict_calc (sat, qth, t); - + if (fabs(sat->el) < 0.005) lostime = t; } @@ -285,10 +279,10 @@ find_los (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt) /* fine steps */ while (lostime == 0.0) { - + t += sat->el * sqrt(sat->alt)/502500.0; predict_calc (sat, qth, t); - + if (fabs(sat->el) < 0.005) lostime = t; } @@ -320,7 +314,7 @@ find_prev_aos (sat_t *sat, qth_t *qth, gdouble start) predict_calc (sat, qth, start); /* check whether satellite has aos */ - if ((sat->otype == ORBIT_TYPE_GEO) || + if ((sat->otype == ORBIT_TYPE_GEO) || (sat->otype == ORBIT_TYPE_DECAYED) || !has_aos (sat, qth)) { @@ -491,7 +485,7 @@ get_pass (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) /* create a pass_t entry; FIXME: g_try_new in 2.8 */ pass = g_new (pass_t, 1); - + pass->aos = aos; pass->los = los; pass->max_el = 0.0; @@ -507,7 +501,7 @@ get_pass (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) /* iterate over each time step */ for (t = pass->aos; t <= pass->los; t += step) { - + /* calculate satellite data */ predict_calc (sat, qth, t); @@ -693,7 +687,7 @@ copy_pass (pass_t *pass) new->vis[2] = pass->vis[2]; new->vis[3] = pass->vis[3]; new->details = copy_pass_details (pass->details); - + if (pass->satname != NULL) new->satname = g_strdup (pass->satname); else @@ -713,7 +707,7 @@ copy_pass_details (GSList *details) n = g_slist_length (details); for (i = 0; i < n; i++) { - new = g_slist_prepend (new, + new = g_slist_prepend (new, copy_pass_detail (PASS_DETAIL (g_slist_nth_data (details, i)))); } @@ -765,12 +759,12 @@ free_pass (pass_t *pass) { if (pass!=NULL){ free_pass_details (pass->details); - + if (pass->satname != NULL) { g_free (pass->satname); pass->satname = NULL; } - + g_free (pass); pass = NULL; } else { @@ -924,7 +918,7 @@ get_pass_no_min_el (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) /* create a pass_t entry; FIXME: g_try_new in 2.8 */ pass = g_new (pass_t, 1); - + pass->aos = aos; pass->los = los; pass->max_el = 0.0; @@ -940,7 +934,7 @@ get_pass_no_min_el (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) /* iterate over each time step */ for (t = pass->aos; t <= pass->los; t += step) { - + /* calculate satellite data */ predict_calc (sat, qth, t); @@ -991,7 +985,7 @@ get_pass_no_min_el (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt) default: break; } - + pass->details = g_slist_prepend (pass->details, detail); /* store elevation if greater than the @@ -1045,7 +1039,7 @@ get_current_pass (sat_t *sat_in, qth_t *qth, gdouble start) { gdouble t; sat_t *sat,sat_working; - + /*copy sat_in to a working structure*/ sat = memcpy(&sat_working,sat_in,sizeof(sat_t)); @@ -1053,15 +1047,15 @@ get_current_pass (sat_t *sat_in, qth_t *qth, gdouble start) t = start; else t = get_current_daynum (); - predict_calc (sat, qth, t); + predict_calc (sat, qth, t); /* check whether satellite has aos */ - if ((sat->otype == ORBIT_TYPE_GEO) || + if ((sat->otype == ORBIT_TYPE_GEO) || (sat->otype == ORBIT_TYPE_DECAYED) || !has_aos (sat, qth)) { - + return NULL; - + } /* find a time before AOS */ diff --git a/predict-tools.h b/predict-tools.h index 42f0339..3f5177f 100644 --- a/predict-tools.h +++ b/predict-tools.h @@ -11,17 +11,17 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ @@ -34,8 +34,6 @@ #include "sat-vis.h" - - /** \brief Brief satellite pass info. */ typedef struct { gchar *satname; /*!< satellite name */ diff --git a/qth-data.c b/qth-data.c index dbc1dc3..c21e998 100644 --- a/qth-data.c +++ b/qth-data.c @@ -11,23 +11,22 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ #include -#include #include "sgpsdp/sgp4sdp4.h" #include "qth-data.h" #include "orbit-tools.h" @@ -65,11 +64,6 @@ qth_data_free (qth_t *qth) qth->wx = NULL; } - if (qth->data) { - g_key_file_free (qth->data); - qth->data = NULL; - } - g_free (qth); } diff --git a/qth-data.h b/qth-data.h index a6445e4..3a248b7 100644 --- a/qth-data.h +++ b/qth-data.h @@ -11,17 +11,17 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ @@ -32,7 +32,6 @@ #include "sgpsdp/sgp4sdp4.h" - /** \brief QTH data structure in human readable form. */ typedef struct { gchar *name; /*!< Name, eg. callsign. */ @@ -43,8 +42,6 @@ typedef struct { gint alt; /*!< Altitude above sea level in meters. */ gchar *qra; /*!< QRA locator */ gchar *wx; /*!< Weather station code (4 chars). */ - - GKeyFile *data; /*!< Raw data from cfg file. */ } qth_t; diff --git a/sat-vis.c b/sat-vis.c index cc37e61..e55f04a 100644 --- a/sat-vis.c +++ b/sat-vis.c @@ -11,36 +11,33 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ /** \brief Satellite visibility calculations. */ -/* #include */ -#include #include "sgpsdp/sgp4sdp4.h" #include "gtk-sat-data.h" #include "sat-vis.h" -/* #include "sat-cfg.h" */ static gchar VIS2CHR[SAT_VIS_NUM] = { '-', 'V', 'D', 'E'}; static gchar *VIS2STR[SAT_VIS_NUM] = { - N_("Unknown"), - N_("Visible"), - N_("Daylight"), - N_("Eclipsed") + "Unknown", + "Visible", + "Daylight", + "Eclipsed" }; @@ -94,7 +91,7 @@ get_sat_vis (sat_t *sat, qth_t *qth, gdouble jul_utc) /* FIXME */ /* threshold = (gdouble) sat_cfg_get_int (SAT_CFG_INT_PRED_TWILIGHT_THLD); */ threshold = (gdouble) -6; - + if (sun_el <= threshold && sat->el >= 0.0) vis = SAT_VIS_VISIBLE; else @@ -125,6 +122,6 @@ vis_to_chr (sat_vis_t vis) gchar * vis_to_str (sat_vis_t vis) { - return g_strdup (_(VIS2STR[vis])); + return g_strdup (VIS2STR[vis]); } diff --git a/sat-vis.h b/sat-vis.h index 96cc591..de14f71 100644 --- a/sat-vis.h +++ b/sat-vis.h @@ -11,17 +11,17 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ @@ -30,12 +30,10 @@ #include -#include #include "sgpsdp/sgp4sdp4.h" #include "gtk-sat-data.h" - /** \brief Satellite visibility. */ typedef enum { SAT_VIS_NONE = 0, /*!< Unknown/undefined. */ diff --git a/sgpsdp/sgp4sdp4.h b/sgpsdp/sgp4sdp4.h index 555bd6b..8c05106 100644 --- a/sgpsdp/sgp4sdp4.h +++ b/sgpsdp/sgp4sdp4.h @@ -22,7 +22,7 @@ typedef enum { ORBIT_TYPE_UNKNOWN = 0, ORBIT_TYPE_LEO, /*!< Low Earth orbit, up to 1200 km. */ - ORBIT_TYPE_ICO, /*!< Intermediate Circular Orbit, up to 1400 km. */ + ORBIT_TYPE_ICO, /*!< Intermediate Circular Orbit, up to 1400 km. */ ORBIT_TYPE_GEO, /*!< Geostationary. */ ORBIT_TYPE_GSO, /*!< Geosynchronuous. */ ORBIT_TYPE_MOLNIYA, @@ -75,8 +75,8 @@ typedef struct { double xincl1; double xnodeo1; double omegao1; -} tle_t; - +} tle_t; + /** \brief Geodetic position data structure. * \ingroup sgpsdpif @@ -165,11 +165,6 @@ typedef struct { vector_t pos; /*!< Raw position and range */ vector_t vel; /*!< Raw velocity */ - /*** FIXME: REMOVE */ - obs_set_t bearing; /*!< Az, El, range and vel */ - obs_astro_t astro; /*!< Ra and Decl */ - /*** END */ - /* time keeping fields */ double jul_epoch; double jul_utc; @@ -209,7 +204,7 @@ typedef struct { #define e6a 1.0E-6 #define tothrd 6.6666667E-1 /* 2/3 */ #define xj2 1.0826158E-3 /* J2 Harmonic */ -#define xj3 -2.53881E-6 /* J3 Harmonic */ +#define xj3 -2.53881E-6 /* J3 Harmonic */ #define xj4 -1.65597E-6 /* J4 Harmonic */ #define xke 7.43669161E-2 #define xkmper 6.378135E3 /* Earth radius km */ @@ -218,7 +213,7 @@ typedef struct { #define ck2 5.413079E-4 #define ck4 6.209887E-7 #define __f 3.352779E-3 -#define ge 3.986008E5 +#define ge 3.986008E5 #define __s__ 1.012229 #define qoms2t 1.880279E-09 #define secday 8.6400E4 /* Seconds per day */ @@ -255,7 +250,7 @@ typedef struct { #define __sr__ 6.96000E5 /*Solar radius - kilometers (IAU 76)*/ #define AU 1.49597870E8 /*Astronomical unit - kilometers (IAU 76)*/ -/* Entry points of Deep() +/* Entry points of Deep() FIXME: Change to enu */ #define dpinit 1 /* Deep-space initialization code */ #define dpsec 2 /* Deep-space secular code */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..353bf06 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) + +project(iss-test) + +add_executable(iss-test + iss-test.c +) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake") + +# Glib +# cmake/FindGlib.cmake is taken from https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGLIB.cmake +find_package(Glib REQUIRED) +include_directories(${GLIB_INCLUDE_DIR}) +include_directories(${GLIBCONFIG_INCLUDE_DIR}) + +target_link_libraries(iss-test gpredict) + +# sys math lib +target_link_libraries(iss-test m) + +install(TARGETS iss-test DESTINATION bin) \ No newline at end of file diff --git a/iss-test.c b/test/iss-test.c similarity index 98% rename from iss-test.c rename to test/iss-test.c index b37113d..325d77e 100644 --- a/iss-test.c +++ b/test/iss-test.c @@ -1,6 +1,6 @@ #include #include -#include "libgpredict.h" +#include "../gpredict.h" char tle_str[3][80]; sat_t sat; diff --git a/time-tools.c b/time-tools.c index a48e5b3..2328d6f 100644 --- a/time-tools.c +++ b/time-tools.c @@ -11,34 +11,24 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ #include -#include -//#include -#ifdef HAVE_CONFIG_H -# include -#endif #include "sgpsdp/sgp4sdp4.h" #include "time-tools.h" -//#ifdef G_OS_WIN32 -//# include "libc_internal.h" -//# include "libc_interface.h" -//#endif - /** \brief Get the current time. @@ -49,43 +39,13 @@ gdouble get_current_daynum () { struct tm utc; - //struct timeval tmval; GTimeVal tmval; double daynum; UTC_Calendar_Now (&utc); - //gettimeofday (&tmval, NULL); g_get_current_time (&tmval); daynum = Julian_Date (&utc); daynum = daynum + (double)tmval.tv_usec/8.64e+10; - - return daynum; -} - -/* This function calculates the day number from m/d/y. */ -/* Legacy code no longer in use -long -get_daynum_from_dmy (int d, int m, int y) -{ - - long dn; - double mm, yy; - - if (m<3) - { - y--; - m+=12; - } - - if (y<57) - y+=100; - - yy=(double)y; - mm=(double)m; - dn=(long)(floor(365.25*(yy-80.0))-floor(19.0+yy/100.0)+floor(4.75+yy/400.0)-16.0); - dn+=d+30*m+(long)floor(0.6*mm-0.3); - - return dn; + return daynum; } -*/ diff --git a/time-tools.h b/time-tools.h index 7b59fbc..a0408f8 100644 --- a/time-tools.h +++ b/time-tools.h @@ -11,17 +11,17 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ @@ -29,7 +29,6 @@ #define TIME_TOOLS_H 1 gdouble get_current_daynum (void); -//long get_daynum_from_dmy (int d, int m, int y); #endif diff --git a/tle-tools.c b/tle-tools.c index 582dc90..c1e57b4 100644 --- a/tle-tools.c +++ b/tle-tools.c @@ -13,28 +13,24 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ #include -#include #include "sgpsdp/sgp4sdp4.h" #include "sat-log.h" -#ifdef HAVE_CONFIG_H -# include -#endif #include "tle-tools.h" @@ -47,7 +43,7 @@ * \param checksum Flag indicating whether to perform checksum check. * \param tle Pointer to a tle_t structure where the TLE data will be put. * \return TLE_CONV_SUCCESS if the conversion is successful or TLE_CONV_ERROR - * if an error has occurred during the conversion. + * if an error has occurred during the conversion. * * This function converts NASA 2-line orbital element data (as read from a tle * file) into a tle_t structure, which is used all over in gpredict. Note that diff --git a/tle-tools.h b/tle-tools.h index 8d676f3..fe05367 100644 --- a/tle-tools.h +++ b/tle-tools.h @@ -11,17 +11,17 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ @@ -30,7 +30,6 @@ #include #include "sgpsdp/sgp4sdp4.h" -//#include "gtk-sat-data.h" enum {