Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
libgpredict.a
sgpsdp/*.o
sgpsdp/test-001
sgpsdp/test-002
iss-test
*.o
build
60 changes: 60 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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"
)
40 changes: 0 additions & 40 deletions Makefile

This file was deleted.

49 changes: 42 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
```
120 changes: 120 additions & 0 deletions cmake/FindGlib.cmake
Original file line number Diff line number Diff line change
@@ -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 <rakuco@webkit.org>
#
# 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
)
File renamed without changes.
14 changes: 6 additions & 8 deletions gtk-sat-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <glib.h>
#include <glib/gi18n.h>
#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.
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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.
*/
Expand All @@ -202,7 +200,7 @@ void gtk_sat_data_free_sat(sat_t *sat)
g_free(sat->website);
sat->website=NULL;
}

g_free(sat);
}
}
16 changes: 7 additions & 9 deletions orbit-tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <glib.h>
#include <glib/gi18n.h>
#include "sgpsdp/sgp4sdp4.h"
#include "orbit-tools.h"



orbit_type_t
get_orbit_type (sat_t *sat)
{
Expand Down Expand Up @@ -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
Expand Down
Loading