├── src ├── .gitignore ├── plugingl │ ├── qtstylesheet.h │ ├── pi_shaders.h │ ├── TexFont.h │ ├── qtstylesheet.cpp │ └── pidc.h ├── celestial_navigation.png ├── transform_star.hpp ├── icons.h ├── geodesic.h ├── tinyxml │ └── tinyxmlerror.cpp ├── ClockCorrectionDialog.h ├── FindBodyDialog.h ├── FixDialog.h ├── ClockCorrectionDialog.cpp ├── zuFile.h ├── SightDialog.h ├── astrolabe │ ├── globals.cpp │ ├── sun.cpp │ ├── dicts.cpp │ ├── riseset.cpp │ └── equinox.cpp ├── celestial_navigation_pi.h ├── CelestialNavigationDialog.h ├── FindBodyDialog.cpp ├── bzip2 │ ├── randtable.c │ ├── crctable.c │ ├── huffman.c │ └── bzlib.h ├── Sight.h ├── transform_star.cpp ├── icons.cpp ├── zuFile.cpp ├── celestial_navigation_pi.cpp ├── zlib-1.2.3 │ └── zconf.h └── geodesic.c ├── .gitignore ├── VERSION.cmake ├── data ├── Celestial_Navigation_Information.html └── IGRF11.COF ├── cmake ├── version.h.in ├── PluginGL.cmake ├── PluginJSON.cmake ├── PluginXML.cmake ├── PluginNMEA.cmake ├── wxWTranslateCatalog.h.in ├── PluginLocalization.cmake ├── PluginInstall.cmake ├── PluginConfigure.cmake └── PluginPackage.cmake ├── po └── POTFILES.in ├── README ├── CMakeLists.txt └── appveyor.yml /src/.gitignore: -------------------------------------------------------------------------------- 1 | version.h 2 | wxWTranslateCatalog.h 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | buildwin 3 | data/ 4 | !data/*.svg 5 | -------------------------------------------------------------------------------- /src/plugingl/qtstylesheet.h: -------------------------------------------------------------------------------- 1 | #ifdef __OCPN__ANDROID__ 2 | extern QString qtStyleSheet; 3 | #endif 4 | -------------------------------------------------------------------------------- /src/celestial_navigation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seandepagnier/celestial_navigation_pi/HEAD/src/celestial_navigation.png -------------------------------------------------------------------------------- /VERSION.cmake: -------------------------------------------------------------------------------- 1 | SET(PLUGIN_VERSION_MAJOR "2") 2 | SET(PLUGIN_VERSION_MINOR "3") 3 | SET(PLUGIN_VERSION_PATCH "") 4 | SET(PLUGIN_VERSION_DATE "2018-3-29") 5 | -------------------------------------------------------------------------------- /data/Celestial_Navigation_Information.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seandepagnier/celestial_navigation_pi/HEAD/data/Celestial_Navigation_Information.html -------------------------------------------------------------------------------- /cmake/version.h.in: -------------------------------------------------------------------------------- 1 | #define PLUGIN_VERSION_MAJOR ${PLUGIN_VERSION_MAJOR} 2 | #define PLUGIN_VERSION_MINOR ${PLUGIN_VERSION_MINOR} 3 | #define PLUGIN_VERSION_DATE "${PLUGIN_VERSION_DATE}" 4 | -------------------------------------------------------------------------------- /src/transform_star.hpp: -------------------------------------------------------------------------------- 1 | void frame_bias ( double &ra, double &dec ); 2 | void precess ( double jdd, double &ra, double &dec ); 3 | void nutate ( double jdd, double &ra, double &dec ); 4 | void proper_motion_parallax (double jdd, double &ra, double &dec, double dra, double ddec, double radvel, double parallax); 5 | -------------------------------------------------------------------------------- /src/icons.h: -------------------------------------------------------------------------------- 1 | /* Autogenerated by png2wx.pl on Sat Feb 23 14:55:26 2013 */ 2 | #ifndef ICONS_H 3 | #define ICONS_H 1 4 | 5 | #include 6 | #ifndef WX_PRECOMP 7 | # include 8 | #endif 9 | 10 | extern void initialize_images(void); 11 | 12 | extern wxBitmap *_img_celestial_navigation; 13 | 14 | #endif /* ICONS_H */ 15 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | src/CelestialNavigationDialog.cpp 2 | src/CelestialNavigationDialog.h 3 | src/CelestialNavigationUI.cpp 4 | src/CelestialNavigationUI.h 5 | src/FindBodyDialog.cpp 6 | src/FindBodyDialog.h 7 | src/Sight.cpp 8 | src/Sight.h 9 | src/SightDialog.cpp 10 | src/SightDialog.h 11 | src/celestial_navigation_pi.cpp 12 | src/celestial_navigation_pi.h 13 | -------------------------------------------------------------------------------- /cmake/PluginGL.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Sean D'Epagnier 3 | ## Copyright: 4 | ## License: GPLv3 5 | ##--------------------------------------------------------------------------- 6 | 7 | SET(SRC_PLUGINGL 8 | src/plugingl/pidc.cpp 9 | src/plugingl/pi_shaders.cpp 10 | src/plugingl/TexFont.cpp 11 | src/plugingl/qtstylesheet.cpp 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/PluginJSON.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Sean D'Epagnier 3 | ## Copyright: 2015 4 | ## License: GPLv3+ 5 | ##--------------------------------------------------------------------------- 6 | 7 | IF(WIN32) 8 | SET(SRC_JSON 9 | src/wxJSON/jsonreader.cpp 10 | src/wxJSON/jsonval.cpp 11 | src/wxJSON/jsonwriter.cpp 12 | ) 13 | ENDIF(WIN32) 14 | INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/wxJSON) 15 | -------------------------------------------------------------------------------- /cmake/PluginXML.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Sean D'Epagnier 3 | ## Copyright: 4 | ## License: GPLv3 5 | ##--------------------------------------------------------------------------- 6 | 7 | 8 | IF(WIN32) 9 | SET(SRC_TINYXML 10 | src/tinyxml/tinyxml.cpp 11 | src/tinyxml/tinyxmlparser.cpp 12 | src/tinyxml/tinyxmlerror.cpp 13 | ) 14 | ENDIF(WIN32) 15 | 16 | ADD_DEFINITIONS(-DTIXML_USE_STL) 17 | 18 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Celestial Navigation Plugin for OpenCPN 2 | ======================================= 3 | 4 | automatically perform sight reductions, and plot position from celestial sights. 5 | 6 | Compiling 7 | ========= 8 | 9 | * git clone git://github.com/seandepagnier/celestial_navigation_pi.git 10 | 11 | Under windows, you must find the file "opencpn.lib" (Visual Studio) or "libopencpn.dll.a" (mingw) which is built in the build directory after compiling opencpn. This file must be copied to the plugin directory. 12 | 13 | Build as normally: 14 | 15 | * cd .. 16 | * cd build 17 | * cmake .. 18 | * make 19 | * make install 20 | 21 | License 22 | ======= 23 | The plugin code is licensed under the terms of the GPL v3 or, at your will, later. 24 | -------------------------------------------------------------------------------- /cmake/PluginNMEA.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Sean D'Epagnier 3 | ## Copyright: 2015 4 | ## License: GPLv3+ 5 | ##--------------------------------------------------------------------------- 6 | 7 | SET(SRC_NMEA0183 8 | src/nmea0183/latlong.cpp 9 | src/nmea0183/long.cpp 10 | src/nmea0183/nmea0183.cpp 11 | src/nmea0183/response.cpp 12 | src/nmea0183/rmb.cpp 13 | src/nmea0183/sentence.cpp 14 | src/nmea0183/talkerid.cpp 15 | src/nmea0183/rmc.cpp 16 | src/nmea0183/hexvalue.cpp 17 | src/nmea0183/lat.cpp 18 | src/nmea0183/expid.cpp 19 | src/nmea0183/wpl.cpp 20 | src/nmea0183/rte.cpp 21 | src/nmea0183/hdt.cpp 22 | src/nmea0183/hdg.cpp 23 | src/nmea0183/hdm.cpp 24 | src/nmea0183/gll.cpp 25 | src/nmea0183/vtg.cpp 26 | src/nmea0183/gga.cpp 27 | src/nmea0183/gsv.cpp 28 | src/nmea0183/dbt.cpp 29 | src/nmea0183/dpt.cpp 30 | src/nmea0183/mtw.cpp 31 | src/nmea0183/mwv.cpp 32 | src/nmea0183/vhw.cpp 33 | src/nmea0183/vwr.cpp 34 | src/nmea0183/zda.cpp 35 | src/nmea0183/rsa.cpp 36 | src/nmea0183/mwd.cpp 37 | src/nmea0183/vwt.cpp 38 | src/nmea0183/mta.cpp 39 | src/nmea0183/vlw.cpp 40 | src/nmea0183/mda.cpp 41 | ) 42 | 43 | INCLUDE_DIRECTORIES(src/nmea0183) 44 | 45 | ADD_LIBRARY(LIB_PLUGINNMEA0183 STATIC ${SRC_NMEA0183}) 46 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} LIB_PLUGINNMEA0183 ) 47 | -------------------------------------------------------------------------------- /src/geodesic.h: -------------------------------------------------------------------------------- 1 | /* 2 | Geodesic Forward and Reverse calculation functions 3 | Abstracted and adapted from PROJ-4.5.0 by David S.Register (bdbcat@yahoo.com) 4 | 5 | Original source code contains the following license: 6 | 7 | Copyright (c) 2000, Frank Warmerdam 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a 10 | copy of this software and associated documentation files (the "Software"), 11 | to deal in the Software without restriction, including without limitation 12 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | and/or sell copies of the Software, and to permit persons to whom the 14 | Software is furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included 17 | in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | extern "C" void ll_gc_ll(double lat, double lon, double crs, double dist, double *dlat, double *dlon); 29 | extern "C" void ll_gc_ll_reverse(double lat1, double lon1, double lat2, double lon2, 30 | double *bearing, double *dist); 31 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Sean D'Epagnier 3 | ## Copyright: 4 | ## License: GPLv3 5 | ##--------------------------------------------------------------------------- 6 | 7 | 8 | # define minimum cmake version 9 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6.2) 10 | 11 | PROJECT(celestial_navigation_pi) 12 | 13 | SET(PACKAGE_NAME celestial_navigation_pi) 14 | SET(VERBOSE_NAME CelestialNavigation) 15 | SET(TITLE_NAME CELESTIALNAVIGATION) 16 | SET(CPACK_PACKAGE_CONTACT "Sean D'Epagnier ") 17 | 18 | MESSAGE (STATUS "*** Building ${PACKAGE_NAME} ***") 19 | 20 | INCLUDE("cmake/PluginConfigure.cmake") 21 | 22 | SET(SRC_CELESTIAL_NAVIGATION 23 | src/astrolabe/calendar.cpp 24 | src/astrolabe/dicts.cpp 25 | src/astrolabe/dynamical.cpp 26 | src/astrolabe/elp2000.cpp 27 | src/astrolabe/equinox.cpp 28 | src/astrolabe/globals.cpp 29 | src/astrolabe/nutation.cpp 30 | src/astrolabe/riseset.cpp 31 | src/astrolabe/sun.cpp 32 | src/astrolabe/util.cpp 33 | src/astrolabe/vsop87d.cpp 34 | src/geomag/geomag.c 35 | src/CelestialNavigationDialog.cpp 36 | src/CelestialNavigationUI.cpp 37 | src/SightDialog.cpp 38 | src/Sight.cpp 39 | src/icons.cpp 40 | src/FindBodyDialog.cpp 41 | src/FixDialog.cpp 42 | src/ClockCorrectionDialog.cpp 43 | src/geodesic.c 44 | src/transform_star.cpp 45 | src/epv00.cpp 46 | src/celestial_navigation_pi.cpp 47 | src/zuFile.cpp 48 | ) 49 | 50 | INCLUDE("cmake/PluginXML.cmake") 51 | INCLUDE("cmake/PluginGL.cmake") 52 | 53 | ADD_LIBRARY(${PACKAGE_NAME} SHARED ${SRC_CELESTIAL_NAVIGATION} ${SRC_TINYXML} ${SRC_PLUGINGL}) 54 | 55 | INCLUDE("cmake/PluginInstall.cmake") 56 | INCLUDE("cmake/PluginLocalization.cmake") 57 | INCLUDE("cmake/PluginPackage.cmake") 58 | -------------------------------------------------------------------------------- /cmake/wxWTranslateCatalog.h.in: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * $Id: ocpn_draw_pi.h,v 1.0 2015/01/28 01:54:37 jongough Exp $ 3 | * 4 | * Project: OpenCPN 5 | * Purpose: Redefine _() macro to allow usage of catalog 6 | * Author: Jon Gough 7 | * 8 | *************************************************************************** 9 | * Copyright (C) 2010 by David S. Register * 10 | * $EMAIL$ * 11 | * * 12 | * This program is free software; you can redistribute it and/or modify * 13 | * it under the terms of the GNU General Public License as published by * 14 | * the Free Software Foundation; either version 2 of the License, or * 15 | * (at your option) any later version. * 16 | * * 17 | * This program is distributed in the hope that it will be useful, * 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 20 | * GNU General Public License for more details. * 21 | * * 22 | * You should have received a copy of the GNU General Public License * 23 | * along with this program; if not, write to the * 24 | * Free Software Foundation, Inc., * 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 26 | *************************************************************************** 27 | */ 28 | #ifndef _ODCATTRANS_H_ 29 | #define _ODCATTRANS_H_ 30 | 31 | #ifndef WXINTL_NO_GETTEXT_MACRO 32 | #ifdef _ 33 | #undef _ 34 | #endif // _ 35 | #define _(s) wxGetTranslation((s), wxS("opencpn-${PROJECT_NAME}")) 36 | #endif // WXINTL_NO_GETTEXT_MACRO 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/tinyxml/tinyxmlerror.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | www.sourceforge.net/projects/tinyxml 3 | Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any 7 | damages arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any 10 | purpose, including commercial applications, and to alter it and 11 | redistribute it freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must 14 | not claim that you wrote the original software. If you use this 15 | software in a product, an acknowledgment in the product documentation 16 | would be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and 19 | must not be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | */ 24 | 25 | #include "tinyxml.h" 26 | 27 | // The goal of the seperate error file is to make the first 28 | // step towards localization. tinyxml (currently) only supports 29 | // english error messages, but the could now be translated. 30 | // 31 | // It also cleans up the code a bit. 32 | // 33 | 34 | const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] = 35 | { 36 | "No error", 37 | "Error", 38 | "Failed to open file", 39 | "Error parsing Element.", 40 | "Failed to read Element name", 41 | "Error reading Element value.", 42 | "Error reading Attributes.", 43 | "Error: empty tag.", 44 | "Error reading end tag.", 45 | "Error parsing Unknown.", 46 | "Error parsing Comment.", 47 | "Error parsing Declaration.", 48 | "Error document empty.", 49 | "Error null (0) or unexpected EOF found in input stream.", 50 | "Error parsing CDATA.", 51 | "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", 52 | }; 53 | -------------------------------------------------------------------------------- /src/ClockCorrectionDialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2016 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | #ifndef _CLOCKCORRECTIONDIALOG_H_ 29 | #define _CLOCKCORRECTIONDIALOG_H_ 30 | 31 | #include "CelestialNavigationUI.h" 32 | 33 | #include 34 | 35 | class Sight; 36 | 37 | class ClockCorrectionDialog : public ClockCorrectionDialogBase 38 | { 39 | public: 40 | ClockCorrectionDialog(wxWindow *parent) : ClockCorrectionDialogBase(parent) {} 41 | private: 42 | void OnUpdate( wxSpinEvent& event ); 43 | }; 44 | 45 | #endif 46 | // _FIXDIALOG_H_ 47 | -------------------------------------------------------------------------------- /src/FindBodyDialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2013 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | #ifndef _FINDBODYDIALOG_H_ 29 | #define _FINDBODYDIALOG_H_ 30 | 31 | #include "CelestialNavigationUI.h" 32 | 33 | class Sight; 34 | 35 | class FindBodyDialog: public FindBodyDialogBase 36 | { 37 | public: 38 | 39 | FindBodyDialog(wxWindow* parent, Sight &sight); 40 | ~FindBodyDialog( ); 41 | 42 | void OnUpdate( wxCommandEvent& event ); 43 | void OnDone( wxCommandEvent& event ); 44 | void Update(); 45 | 46 | Sight& m_Sight; 47 | }; 48 | 49 | #endif 50 | // _FINDBODYDIALOG_H_ 51 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | clone_folder: c:\project\celestial_navigation_pi 2 | shallow_clone: true 3 | image: 4 | - Visual Studio 2015 5 | 6 | platform: 7 | # - x64 8 | - Win32 9 | 10 | configuration: Release 11 | test: OFF 12 | 13 | install: 14 | - '"C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x86' 15 | 16 | # sent environment variables for wxWidgets 17 | - set WXWIN=C:\wxWidgets-3.0.2 18 | - set wxWidgets_ROOT_DIR=%WXWIN% 19 | - set wxWidgets_LIB_DIR=%WXWIN%\lib\vc_dll 20 | - cmd: SET PATH=%PATH%;%WXWIN%;%wxWidgets_LIB_DIR%;C:\Program Files (x86)\Poedit\Gettexttools\bin; 21 | 22 | # install dependencies: 23 | - choco install poedit nsis -x86 24 | 25 | # Download and unzip wxwidgets 26 | - ps: Start-FileDownload http://downloads.sourceforge.net/project/wxwindows/3.0.2/wxWidgets-3.0.2.zip 27 | - cmd: 7z x wxwidgets-3.0.2.zip -o%WXWIN% > null 28 | 29 | # some debugging information 30 | - set 31 | # - cmake --help 32 | 33 | # build wxWidgets 34 | - cmd: cd %WXWIN%\build\msw\ 35 | - cmd: nmake -f makefile.vc BUILD=release SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_ 36 | - cmd: nmake -f makefile.vc BUILD=debug SHARED=1 CFLAGS=/D_USING_V120_SDK71_ CXXFLAGS=/D_USING_V120_SDK71_ 37 | 38 | before_build: 39 | - cd c:\project\celestial_navigation_pi 40 | - mkdir build 41 | - cd build 42 | - ps: Start-FileDownload https://downloads.sourceforge.net/project/opencpnplugins/opencpn_lib/4.8.2-vc120_xp/opencpn.lib 43 | - ps: Start-FileDownload https://downloads.sourceforge.net/project/opencpnplugins/opencpn_packaging_data/OpenCPN_buildwin.7z 44 | - cmd: 7z x -y OpenCPN_buildwin.7z -oc:\project\celestial_navigation_pi 45 | - cmake -T v120_xp .. 46 | 47 | build_script: 48 | # - cmake --build . --config debug 49 | - cmake --build . --target package --config release 50 | 51 | artifacts: 52 | - path: 'build\*.exe' 53 | name: installer 54 | 55 | deploy: 56 | description: 'release created by AppVeyor CI' 57 | provider: GitHub 58 | auth_token: '%GitHub_auth_token%' 59 | artifact: installer 60 | draft: true 61 | prerelease: true 62 | on: 63 | appveyor_repo_tag: true # deploy on tag push only 64 | configuration: Release # Debug contains non-redist MS DLLs -------------------------------------------------------------------------------- /src/plugingl/pi_shaders.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * 5 | *************************************************************************** 6 | * Copyright (C) 2017 by David S. Register * 7 | * * 8 | * This program is free software; you can redistribute it and/or modify * 9 | * it under the terms of the GNU General Public License as published by * 10 | * the Free Software Foundation; either version 2 of the License, or * 11 | * (at your option) any later version. * 12 | * * 13 | * This program is distributed in the hope that it will be useful, * 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 | * GNU General Public License for more details. * 17 | * * 18 | * You should have received a copy of the GNU General Public License * 19 | * along with this program; if not, write to the * 20 | * Free Software Foundation, Inc., * 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 22 | **************************************************************************/ 23 | 24 | #ifndef __PISHADERS_H__ 25 | #define __PISHADERS_H__ 26 | 27 | #include "wx/wxprec.h" 28 | #ifndef WX_PRECOMP 29 | #include "wx/wx.h" 30 | #endif //precompiled headers 31 | 32 | #ifdef ocpnUSE_GLES2 33 | #include "GLES2/gl2.h" 34 | #endif 35 | 36 | extern GLint pi_color_tri_shader_program; 37 | extern GLint pi_colorv_tri_shader_program; 38 | extern GLint pi_texture_2D_shader_program; 39 | extern GLint pi_texture_2DA_shader_program; 40 | extern GLint pi_texture_text_shader_program; 41 | extern GLint pi_circle_filled_shader_program; 42 | 43 | 44 | bool pi_loadShaders(); 45 | void configureShaders(float width, float height); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/FixDialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2016 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | #ifndef _FIXDIALOG_H_ 29 | #define _FIXDIALOG_H_ 30 | 31 | #include "CelestialNavigationUI.h" 32 | 33 | #include 34 | 35 | class Sight; 36 | 37 | class FixDialog : public FixDialogBase 38 | { 39 | public: 40 | FixDialog(wxWindow *parent); 41 | void Update(int clock_offset, bool warnings); 42 | 43 | int m_clock_offset; 44 | double m_fixlat, m_fixlon, m_fixerror; 45 | private: 46 | void OnGo( wxCommandEvent& event ); 47 | void OnUpdate( wxCommandEvent& event ) { Update(m_clock_offset, false); } 48 | void OnUpdateSpin( wxSpinEvent& event ) { Update(m_clock_offset, false); } 49 | }; 50 | 51 | #endif 52 | // _FIXDIALOG_H_ 53 | -------------------------------------------------------------------------------- /src/ClockCorrectionDialog.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2016 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | #include 29 | #include "CelestialNavigationDialog.h" 30 | #include "ClockCorrectionDialog.h" 31 | 32 | #include "ocpn_plugin.h" 33 | #include "Sight.h" 34 | 35 | void ClockCorrectionDialog::OnUpdate( wxSpinEvent& event ) 36 | { 37 | CelestialNavigationDialog *parent((CelestialNavigationDialog*)GetParent()); 38 | wxListCtrl *lSights = parent->m_lSights; 39 | for(int i = 0; iGetItemCount(); i++) { 40 | Sight *s = (Sight*)wxUIntToPtr(lSights->GetItemData(i)); 41 | s->Recompute(m_sClockCorrection->GetValue()); 42 | s->RebuildPolygons(); 43 | } 44 | 45 | parent->UpdateSights(); 46 | RequestRefresh( parent->GetParent() ); 47 | } 48 | -------------------------------------------------------------------------------- /src/zuFile.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | zyGrib: meteorological GRIB file viewer 3 | Copyright (C) 2008 - Jacques Zaninetti - http://www.zygrib.org 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***********************************************************************/ 18 | 19 | #ifndef ZU_FILE_H 20 | #define ZU_FILE_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | // zuFile : uniform interface for READING uncompressed, gziped and bziped files 27 | // (with fseek ftell not so bugged as in ... library) 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #ifdef __ANDROID__ 35 | #define BZ_OK 0 36 | #else 37 | #include 38 | #endif 39 | 40 | #define ZU_COMPRESS_AUTO -1 41 | #define ZU_COMPRESS_NONE 0 42 | #define ZU_COMPRESS_GZIP 1 43 | #define ZU_COMPRESS_BZIP 2 44 | 45 | #define ZU_BUFREADSIZE 256000 46 | 47 | 48 | typedef struct 49 | { 50 | int type; 51 | int ok; 52 | char *fname; 53 | long pos; 54 | 55 | void *zfile; // exact file type depends of compress type 56 | 57 | FILE *faux; // auxiliary file for bzip 58 | } ZUFILE; 59 | 60 | 61 | ZUFILE * zu_open(const char *fname, const char *mode, int type=ZU_COMPRESS_AUTO); 62 | int zu_close(ZUFILE *f); 63 | 64 | int zu_can_read_file(const char *fname); 65 | 66 | int zu_read(ZUFILE *f, void *buf, long len); 67 | 68 | long zu_tell(ZUFILE *f); 69 | 70 | int zu_seek(ZUFILE *f, long offset, int whence); // TODO: whence=SEEK_END 71 | 72 | void zu_rewind(ZUFILE *f); 73 | 74 | long zu_filesize(ZUFILE *f); 75 | 76 | // for internal use : 77 | int zu_bzSeekForward(ZUFILE *f, unsigned long nbytes); 78 | 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /src/SightDialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2014 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | #ifndef _SIGHTDIALOG_H_ 29 | #define _SIGHTDIALOG_H_ 30 | 31 | #include "wx/listctrl.h" 32 | #include "wx/calctrl.h" 33 | 34 | #include "CelestialNavigationUI.h" 35 | 36 | 37 | class Sight; 38 | 39 | class SightDialog: public SightDialogBase 40 | { 41 | 42 | public: 43 | enum {ALTITUDE, AZIMUTH, LUNAR}; 44 | 45 | SightDialog(wxWindow* parent, Sight &sight, int clock_offset); 46 | ~SightDialog( ); 47 | 48 | // void SetColorScheme(ColorScheme cs); 49 | 50 | void OnSetDefaults( wxCommandEvent& event ); 51 | void MeasurementEntered( wxCommandEvent& event ) { EndModal(wxID_OK); } 52 | void Recompute( wxCommandEvent& event ) { Recompute(); } 53 | void RecomputeCalendar( wxCalendarEvent& event ) { Recompute(); } 54 | void RecomputeSpin( wxSpinEvent& event ) { Recompute(); } 55 | // void RecomputeScroll( wxScrollEvent& event ) { Recompute(); } 56 | void RecomputeColor( wxColourPickerEvent& event ) { Recompute(); } 57 | void NewBody(); 58 | void NewBody( wxCommandEvent& event ) { NewBody(); Recompute(); } 59 | void OnFindBody( wxCommandEvent& event ); 60 | 61 | wxDateTime DateTime(); 62 | void Recompute(); 63 | 64 | private: 65 | double BodyAltitude(wxString body); 66 | 67 | Sight &m_Sight; 68 | int m_clock_offset; 69 | bool m_breadytorecompute; 70 | }; 71 | 72 | 73 | 74 | #endif 75 | // _SIGHTDIALOG_H_ 76 | -------------------------------------------------------------------------------- /src/plugingl/TexFont.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: OpenGL text rendering 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2014 Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 2 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 24 | **************************************************************************/ 25 | 26 | #ifndef __TEXFONT_H__ 27 | #define __TEXFONT_H__ 28 | 29 | /* support ascii plus degree symbol for now pack font in a single texture 16x8 */ 30 | #define DEGREE_GLYPH 127 31 | #define MIN_GLYPH 32 32 | #define MAX_GLYPH 128 33 | 34 | #define NUM_GLYPHS (MAX_GLYPH - MIN_GLYPH) 35 | 36 | #define COLS_GLYPHS 16 37 | #define ROWS_GLYPHS ((NUM_GLYPHS / COLS_GLYPHS)+1) 38 | 39 | struct TexGlyphInfo { 40 | int x, y, width, height; 41 | float advance; 42 | }; 43 | 44 | class TexFont { 45 | public: 46 | TexFont(); 47 | ~TexFont(); 48 | 49 | void Build( wxFont &font, bool blur = false ); 50 | void Delete(); 51 | 52 | void GetTextExtent( const wxString &string, int *width, int *height); 53 | void RenderString( const char *string, int x=0, int y=0 ); 54 | void RenderString( const wxString &string, int x=0, int y=0 ); 55 | bool IsBuilt(){ return m_built; } 56 | void SetColor(wxColor &color){ m_color = color;} 57 | 58 | private: 59 | void GetTextExtent( const char *string, int *width, int *height); 60 | void RenderGlyph( int c ); 61 | 62 | wxFont m_font; 63 | bool m_blur; 64 | 65 | TexGlyphInfo tgi[MAX_GLYPH]; 66 | 67 | unsigned int texobj; 68 | int tex_w, tex_h; 69 | int m_maxglyphw; 70 | int m_maxglyphh; 71 | bool m_built; 72 | 73 | float m_dx; 74 | float m_dy; 75 | wxColor m_color; 76 | }; 77 | #endif //guard 78 | -------------------------------------------------------------------------------- /src/astrolabe/globals.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2000, 2001 William McClain 2 | 3 | This file is part of Astrolabe. 4 | 5 | Astrolabe is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | Astrolabe is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with Astrolabe; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* Global values. 21 | 22 | These can be set directly, or there is a routine astrolabe.util.load_params() 23 | which will assign them based on values in a parameter text file. 24 | 25 | */ 26 | 27 | #include "astrolabe.hpp" 28 | 29 | using std::string; 30 | 31 | /* 32 | Abbreviation for standard timezone (e.g., "CST" for North American 33 | Central Standard Time) 34 | */ 35 | string astrolabe::globals::standard_timezone_name = "UT"; 36 | 37 | /* 38 | Time in fractional days to be subtracted from UT to calculate the standard 39 | time zone offset. Locations east of Greenwich should use negative values. 40 | */ 41 | double astrolabe::globals::standard_timezone_offset = 0.0; 42 | 43 | /* 44 | Abbreviation for daylight savings timezone (e.g., "CDT" for North American 45 | Central Daylight Time) 46 | 47 | This is optional. If set to None, no daylight savings conversions 48 | will be performed. 49 | */ 50 | string astrolabe::globals::daylight_timezone_name; 51 | 52 | /* 53 | Time in fractional days to be subtracted from UT to calculate the daylight savings 54 | time zone offset. Locations east of Greenwich should use negative values. 55 | 56 | This value is not used unless "daylight_timezone_name" has an value other 57 | than None. 58 | */ 59 | double astrolabe::globals::daylight_timezone_offset = 0.0; 60 | 61 | /* 62 | Observer's longitude in radians, measured positive west of Greenwich, 63 | negative to the east. Should be between -pi...pi. 64 | */ 65 | double astrolabe::globals::longitude = 0.0; 66 | 67 | /* 68 | Observer's latitude in radians, measured positive north of the equator, 69 | negative to the south. Should be between -pi/2...pi/2. 70 | */ 71 | double astrolabe::globals::latitude = 0.0; 72 | 73 | /* 74 | The full path name of the VSOP87D text data file, eg: 75 | 76 | /home/wmcclain/astrolabe/data/vsop87d.txt 77 | 78 | This value is not required unless the vsop87d module is used. 79 | */ 80 | string astrolabe::globals::vsop87d_text_path; 81 | 82 | /* 83 | The full path name of the VSOP87D binary data file, eg: 84 | 85 | /home/wmcclain/astrolabe/data/vsop87d.dat 86 | 87 | This value is not required unless the vsop87d module is used. If the value 88 | is not defined or the file is not readable, the VSOP87d() class init method 89 | will use vsop87d_text_path instead. 90 | */ 91 | string astrolabe::globals::vsop87d_binary_path; 92 | 93 | -------------------------------------------------------------------------------- /cmake/PluginLocalization.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Pavel Kalian / Sean D'Epagnier 3 | ## Copyright: 4 | ## License: GPLv3+ 5 | ##--------------------------------------------------------------------------- 6 | 7 | FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext) 8 | string(REPLACE "_pi" "" I18N_NAME ${PACKAGE_NAME}) 9 | IF (GETTEXT_XGETTEXT_EXECUTABLE) 10 | ADD_CUSTOM_COMMAND( 11 | OUTPUT po/${PACKAGE_NAME}.pot.dummy 12 | COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} --force-po --package-name=${PACKAGE_NAME} --package-version="${PACKAGE_VERSION}" --output=po/${PACKAGE_NAME}.pot --keyword=_ --width=80 --files-from=${CMAKE_CURRENT_SOURCE_DIR}/po/POTFILES.in 13 | DEPENDS po/POTFILES.in po/${PACKAGE_NAME}.pot 14 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 15 | COMMENT "${I18N_NAME}-pot-update [${PACKAGE_NAME}]: Generated pot file." 16 | ) 17 | ADD_CUSTOM_TARGET(${I18N_NAME}-pot-update COMMENT "[${PACKAGE_NAME}]-pot-update: Done." DEPENDS po/${PACKAGE_NAME}.pot.dummy) 18 | 19 | ENDIF(GETTEXT_XGETTEXT_EXECUTABLE ) 20 | 21 | MACRO(GETTEXT_UPDATE_PO _potFile) 22 | SET(_poFiles ${_potFile}) 23 | GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE) 24 | 25 | FOREACH (_currentPoFile ${ARGN}) 26 | GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE) 27 | GET_FILENAME_COMPONENT(_poBasename ${_absFile} NAME_WE) 28 | 29 | ADD_CUSTOM_COMMAND( 30 | OUTPUT ${_absFile}.dummy 31 | COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --width=80 --strict --quiet --update --backup=none --no-location -s ${_absFile} ${_absPotFile} 32 | DEPENDS ${_absPotFile} ${_absFile} 33 | COMMENT "${I18N_NAME}-po-update [${_poBasename}]: Updated po file." 34 | ) 35 | 36 | SET(_poFiles ${_poFiles} ${_absFile}.dummy) 37 | 38 | ENDFOREACH (_currentPoFile ) 39 | 40 | ADD_CUSTOM_TARGET(${I18N_NAME}-po-update COMMENT "[${PACKAGE_NAME}]-po-update: Done." DEPENDS ${_poFiles}) 41 | ENDMACRO(GETTEXT_UPDATE_PO) 42 | 43 | IF (GETTEXT_MSGMERGE_EXECUTABLE) 44 | FILE(GLOB PACKAGE_PO_FILES po/*.po) 45 | GETTEXT_UPDATE_PO(po/${PACKAGE_NAME}.pot ${PACKAGE_PO_FILES}) 46 | ENDIF(GETTEXT_MSGMERGE_EXECUTABLE) 47 | 48 | SET(_gmoFiles) 49 | MACRO(GETTEXT_BUILD_MO) 50 | FOREACH (_poFile ${ARGN}) 51 | GET_FILENAME_COMPONENT(_absFile ${_poFile} ABSOLUTE) 52 | GET_FILENAME_COMPONENT(_poBasename ${_absFile} NAME_WE) 53 | SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_poBasename}.mo) 54 | 55 | ADD_CUSTOM_COMMAND( 56 | OUTPUT ${_gmoFile} 57 | COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${_gmoFile} ${_absFile} 58 | COMMAND ${CMAKE_COMMAND} -E copy ${_gmoFile} "Resources/${_poBasename}.lproj/opencpn-${PACKAGE_NAME}.mo" 59 | DEPENDS ${_absFile} 60 | COMMENT "${I18N_NAME}-i18n [${_poBasename}]: Created mo file." 61 | ) 62 | 63 | IF(APPLE) 64 | INSTALL(FILES ${_gmoFile} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/OpenCPN.app/Contents/Resources/${_poBasename}.lproj RENAME opencpn-${PACKAGE_NAME}.mo ) 65 | ELSE(APPLE) 66 | INSTALL(FILES ${_gmoFile} DESTINATION ${PREFIX_DATA}/locale/${_poBasename}/LC_MESSAGES RENAME opencpn-${PACKAGE_NAME}.mo ) 67 | ENDIF(APPLE) 68 | 69 | SET(_gmoFiles ${_gmoFiles} ${_gmoFile}) 70 | ENDFOREACH (_poFile ) 71 | ENDMACRO(GETTEXT_BUILD_MO) 72 | 73 | if(GETTEXT_MSGFMT_EXECUTABLE) 74 | FILE(GLOB PACKAGE_PO_FILES po/*.po) 75 | GETTEXT_BUILD_MO(${PACKAGE_PO_FILES}) 76 | ADD_CUSTOM_TARGET(${I18N_NAME}-i18n COMMENT "${PACKAGE_NAME}-i18n: Done." DEPENDS ${_gmoFiles}) 77 | ADD_DEPENDENCIES(${PACKAGE_NAME} ${I18N_NAME}-i18n) 78 | ENDIF(GETTEXT_MSGFMT_EXECUTABLE) 79 | -------------------------------------------------------------------------------- /src/celestial_navigation_pi.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Plugin 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2010, 2014 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | */ 26 | 27 | #ifndef _CELESTIAL_NAVIGATIONPI_H_ 28 | #define _CELESTIAL_NAVIGATIONPI_H_ 29 | 30 | #include 31 | 32 | #include "version.h" 33 | 34 | #define MY_API_VERSION_MAJOR 1 35 | #define MY_API_VERSION_MINOR 11 36 | 37 | #define ABOUT_AUTHOR_URL "http://seandepagnier.users.sourceforge.net" 38 | 39 | #include "ocpn_plugin.h" 40 | #include "plugingl/qtstylesheet.h" 41 | #include "CelestialNavigationDialog.h" 42 | 43 | class piDC; 44 | 45 | //---------------------------------------------------------------------------------------------------------- 46 | // The PlugIn Class Definition 47 | //---------------------------------------------------------------------------------------------------------- 48 | 49 | #define CELESTIAL_NAVIGATION_TOOL_POSITION -1 // Request default positioning of toolbar tool 50 | 51 | class celestial_navigation_pi : public wxEvtHandler, opencpn_plugin_111 52 | { 53 | public: 54 | celestial_navigation_pi(void *ppimgr); 55 | ~celestial_navigation_pi(void); 56 | 57 | // The required PlugIn Methods 58 | int Init(void); 59 | bool DeInit(void); 60 | 61 | int GetAPIVersionMajor(); 62 | int GetAPIVersionMinor(); 63 | int GetPlugInVersionMajor(); 64 | int GetPlugInVersionMinor(); 65 | wxBitmap *GetPlugInBitmap(); 66 | wxString GetCommonName(); 67 | wxString GetShortDescription(); 68 | wxString GetLongDescription(); 69 | 70 | void OnToolbarToolCallback(int id); 71 | 72 | int GetToolbarToolCount(void); 73 | void SetColorScheme(PI_ColorScheme cs); 74 | 75 | bool RenderOverlay( wxDC &dc, PlugIn_ViewPort *vp ); 76 | bool RenderGLOverlay( wxGLContext *pcontext, PlugIn_ViewPort *vp ); 77 | void Render(piDC &dc, PlugIn_ViewPort *vp); 78 | 79 | static wxString StandardPath(); 80 | void SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix); 81 | void SetCursorLatLon(double lat, double lon); 82 | 83 | private: 84 | wxWindow *m_parent_window; 85 | int m_leftclick_tool_id; 86 | 87 | CelestialNavigationDialog *m_pCelestialNavigationDialog; 88 | }; 89 | 90 | extern void celestial_navigation_pi_BoatPos(double &lat, double &lon); 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/CelestialNavigationDialog.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2016 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | #ifndef _CelestialNavigationDialog_h_ 29 | #define _CelestialNavigationDialog_h_ 30 | 31 | #include 32 | #ifdef __OCPN__ANDROID__ 33 | #include 34 | #endif 35 | 36 | #include "geodesic.h" 37 | #include "CelestialNavigationUI.h" 38 | #include "FixDialog.h" 39 | #include "ClockCorrectionDialog.h" 40 | 41 | class CelestialNavigationDialog : public CelestialNavigationDialogBase 42 | { 43 | public: 44 | CelestialNavigationDialog(wxWindow *parent); 45 | ~CelestialNavigationDialog(); 46 | #ifdef __OCPN__ANDROID__ 47 | void OnEvtPanGesture( wxQT_PanGestureEvent &event); 48 | #endif 49 | void UpdateSights(); 50 | 51 | FixDialog m_FixDialog; 52 | 53 | private: 54 | 55 | bool OpenXML(wxString filename, bool reportfailure); 56 | void SaveXML(wxString filename); 57 | 58 | void UpdateButtons(); // Correct button state 59 | void UpdateFix(bool warnings=true); 60 | 61 | // event handlers 62 | void OnNew(wxCommandEvent &event); 63 | void OnDuplicate(wxCommandEvent &event); 64 | void OnEdit( ); 65 | void OnEditMouse( wxMouseEvent& event ) { OnEdit(); } 66 | void OnEdit(wxCommandEvent &event) { OnEdit(); } 67 | void OnDelete(wxCommandEvent &event); 68 | void OnDeleteAll(wxCommandEvent &event); 69 | void OnFix( wxCommandEvent& event ); 70 | void OnDRShift( wxCommandEvent& event ); 71 | void OnClockOffset( wxCommandEvent& event ); 72 | void OnInformation( wxCommandEvent& event ); 73 | void OnHide( wxCommandEvent& event ); 74 | void OnClose( wxCommandEvent& event ) { Hide(); } 75 | 76 | void OnClockCorrection( wxSpinEvent& event ); 77 | void OnSightListLeftDown(wxMouseEvent &event); 78 | void OnBtnLeftDown(wxMouseEvent &event); // record control key state for some action buttons 79 | void OnSightSelected(wxListEvent &event); 80 | 81 | void InsertSight(Sight *s, bool warnings=true); 82 | void UpdateSight(int idx, bool warnings=true); 83 | 84 | wxString m_sights_path; 85 | int clock_correction; 86 | 87 | ClockCorrectionDialog m_ClockCorrectionDialog; 88 | #ifdef __OCPN__ANDROID__ 89 | wxPoint m_downPos, m_startPos, m_startMouse; 90 | #endif 91 | }; 92 | 93 | #endif // _CelestialNavigationDialog_h_ 94 | -------------------------------------------------------------------------------- /cmake/PluginInstall.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Pavel Kalian (Based on the work of Sean D'Epagnier) 3 | ## Copyright: 2014 4 | ## License: GPLv3+ 5 | ##--------------------------------------------------------------------------- 6 | 7 | IF (QT_ANDROID ) 8 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${OCPN_Core_LIBRARIES} ) 9 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} "-lgnustl_shared") 10 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} "-lz" ) 11 | ENDIF(QT_ANDROID) 12 | 13 | IF(NOT APPLE) 14 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${wxWidgets_LIBRARIES} ${EXTRA_LIBS} ) 15 | ENDIF(NOT APPLE) 16 | 17 | IF(NOT QT_ANDROID) 18 | IF(WIN32) 19 | SET(PARENT "opencpn") 20 | 21 | IF(MSVC) 22 | # TARGET_LINK_LIBRARIES(${PACKAGE_NAME} 23 | # gdiplus.lib 24 | # glu32.lib) 25 | TARGET_LINK_LIBRARIES(${PACKAGE_NAME} ${OPENGL_LIBRARIES}) 26 | 27 | SET(OPENCPN_IMPORT_LIB "${PARENT}.lib") 28 | ENDIF(MSVC) 29 | 30 | IF(MINGW) 31 | # assuming wxwidgets is compiled with unicode, this is needed for mingw headers 32 | ADD_DEFINITIONS( " -DUNICODE" ) 33 | TARGET_LINK_LIBRARIES(${PACKAGE_NAME} ${OPENGL_LIBRARIES}) 34 | SET(OPENCPN_IMPORT_LIB "${PARENT}.dll") 35 | SET( CMAKE_SHARED_LINKER_FLAGS "-L../buildwin" ) 36 | ENDIF(MINGW) 37 | 38 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${OPENCPN_IMPORT_LIB} ) 39 | ENDIF(WIN32) 40 | 41 | IF(UNIX) 42 | IF(PROFILING) 43 | find_library(GCOV_LIBRARY 44 | NAMES 45 | gcov 46 | PATHS 47 | /usr/lib/gcc/i686-pc-linux-gnu/4.7 48 | ) 49 | 50 | SET(EXTRA_LIBS ${EXTRA_LIBS} ${GCOV_LIBRARY}) 51 | ENDIF(PROFILING) 52 | ENDIF(UNIX) 53 | 54 | IF(APPLE) 55 | INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/OpenCPN.app/Contents/SharedSupport/plugins) 56 | FIND_PACKAGE(ZLIB REQUIRED) 57 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${ZLIB_LIBRARIES} ) 58 | INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/OpenCPN.app/Contents/PlugIns) 59 | 60 | IF(EXISTS ${PROJECT_SOURCE_DIR}/data) 61 | INSTALL(DIRECTORY data DESTINATION ${CMAKE_BINARY_DIR}/OpenCPN.app/Contents/SharedSupport/plugins/${PACKAGE_NAME}) 62 | ENDIF() 63 | 64 | ENDIF(APPLE) 65 | 66 | IF(UNIX AND NOT APPLE) 67 | FIND_PACKAGE(BZip2 REQUIRED) 68 | INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR}) 69 | FIND_PACKAGE(ZLIB REQUIRED) 70 | INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) 71 | TARGET_LINK_LIBRARIES( ${PACKAGE_NAME} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARY} ) 72 | ENDIF(UNIX AND NOT APPLE) 73 | 74 | SET(PARENT opencpn) 75 | 76 | SET(PREFIX_DATA share) 77 | SET(PREFIX_LIB lib) 78 | 79 | IF(WIN32) 80 | MESSAGE (STATUS "Install Prefix: ${CMAKE_INSTALL_PREFIX}") 81 | SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/../OpenCPN) 82 | IF(CMAKE_CROSSCOMPILING) 83 | INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins") 84 | SET(INSTALL_DIRECTORY "plugins/${PACKAGE_NAME}") 85 | ELSE(CMAKE_CROSSCOMPILING) 86 | INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME DESTINATION "plugins") 87 | SET(INSTALL_DIRECTORY "plugins\\\\${PACKAGE_NAME}") 88 | ENDIF(CMAKE_CROSSCOMPILING) 89 | 90 | IF(EXISTS ${PROJECT_SOURCE_DIR}/data) 91 | INSTALL(DIRECTORY data DESTINATION "${INSTALL_DIRECTORY}") 92 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/data) 93 | ENDIF(WIN32) 94 | 95 | IF(UNIX AND NOT APPLE) 96 | SET(PREFIX_PARENTDATA ${PREFIX_DATA}/${PARENT}) 97 | IF(NOT DEFINED PREFIX_PLUGINS) 98 | SET(PREFIX_PLUGINS ${PREFIX_LIB}/${PARENT}) 99 | ENDIF(NOT DEFINED PREFIX_PLUGINS) 100 | INSTALL(TARGETS ${PACKAGE_NAME} RUNTIME LIBRARY DESTINATION ${PREFIX_PLUGINS}) 101 | 102 | IF(EXISTS ${PROJECT_SOURCE_DIR}/data) 103 | INSTALL(DIRECTORY data DESTINATION ${PREFIX_PARENTDATA}/plugins/${PACKAGE_NAME}) 104 | ENDIF() 105 | ENDIF(UNIX AND NOT APPLE) 106 | 107 | ENDIF(NOT QT_ANDROID) 108 | -------------------------------------------------------------------------------- /src/plugingl/qtstylesheet.cpp: -------------------------------------------------------------------------------- 1 | #ifdef __OCPN__ANDROID__ 2 | #include 3 | 4 | QString qtStyleSheet = "\ 5 | QScrollBar:horizontal {\ 6 | border: 0px solid grey;\ 7 | background-color: rgb(240, 240, 240);\ 8 | height: 25px;\ 9 | margin: 0px 1px 0 1px;\ 10 | }\ 11 | QScrollBar::handle:horizontal {\ 12 | background-color: rgb(200, 200, 200);\ 13 | min-width: 20px;\ 14 | border-radius: 10px;\ 15 | }\ 16 | QScrollBar::add-line:horizontal {\ 17 | border: 0px solid grey;\ 18 | background: #32CC99;\ 19 | width: 0px;\ 20 | subcontrol-position: right;\ 21 | subcontrol-origin: margin;\ 22 | }\ 23 | QScrollBar::sub-line:horizontal {\ 24 | border: 0px solid grey;\ 25 | background: #32CC99;\ 26 | width: 0px;\ 27 | subcontrol-position: left;\ 28 | subcontrol-origin: margin;\ 29 | }\ 30 | QScrollBar:vertical {\ 31 | border: 0px solid grey;\ 32 | background-color: rgb(240, 240, 240);\ 33 | width: 35px;\ 34 | margin: 1px 0px 1px 0px;\ 35 | }\ 36 | QScrollBar::handle:vertical {\ 37 | background-color: rgb(200, 200, 200);\ 38 | min-height: 20px;\ 39 | border-radius: 10px;\ 40 | }\ 41 | QScrollBar::add-line:vertical {\ 42 | border: 0px solid grey;\ 43 | background: #32CC99;\ 44 | height: 0px;\ 45 | subcontrol-position: top;\ 46 | subcontrol-origin: margin;\ 47 | }\ 48 | QScrollBar::sub-line:vertical {\ 49 | border: 0px solid grey;\ 50 | background: #32CC99;\ 51 | height: 0px;\ 52 | subcontrol-position: bottom;\ 53 | subcontrol-origin: margin;\ 54 | }\ 55 | QCheckBox {\ 56 | spacing: 25px;\ 57 | }\ 58 | QCheckBox::indicator {\ 59 | width: 30px;\ 60 | height: 30px;\ 61 | }\ 62 | QTreeWidget QScrollBar:vertical {\ 63 | border: 0px solid grey;\ 64 | background-color: rgb(240, 240, 240);\ 65 | width: 35px;\ 66 | margin: 1px 0px 1px 0px;\ 67 | }\ 68 | QTreeWidget QScrollBar::handle:vertical {\ 69 | background-color: rgb(200, 200, 200);\ 70 | min-height: 20px;\ 71 | border-radius: 10px;\ 72 | }\ 73 | QTreeWidget QScrollBar::add-line:vertical {\ 74 | border: 0px solid grey;\ 75 | background: #32CC99;\ 76 | height: 0px;\ 77 | subcontrol-position: top;\ 78 | subcontrol-origin: margin;\ 79 | }\ 80 | \ 81 | QTreeWidget QScrollBar::sub-line:vertical {\ 82 | border: 0px solid grey;\ 83 | background: #32CC99;\ 84 | height: 0px;\ 85 | subcontrol-position: bottom;\ 86 | subcontrol-origin: margin;\ 87 | }\ 88 | \ 89 | QTreeWidget QScrollBar:horizontal {\ 90 | border: 0px solid grey;\ 91 | background-color: rgb(240, 240, 240);\ 92 | height: 35px;\ 93 | margin: 0px 1px 0 1px;\ 94 | }\ 95 | QTreeWidget QScrollBar::handle:horizontal {\ 96 | background-color: rgb(200, 200, 200);\ 97 | min-width: 20px;\ 98 | border-radius: 10px;\ 99 | }\ 100 | QTreeWidget QScrollBar::add-line:horizontal {\ 101 | border: 0px solid grey;\ 102 | background: #32CC99;\ 103 | width: 0px;\ 104 | subcontrol-position: right;\ 105 | subcontrol-origin: margin;\ 106 | }\ 107 | QTreeWidget QScrollBar::sub-line:horizontal {\ 108 | border: 0px solid grey;\ 109 | background: #32CC99;\ 110 | width: 0px;\ 111 | subcontrol-position: left;\ 112 | subcontrol-origin: margin;\ 113 | }\ 114 | QScrollBar::handle:horizontal {\ 115 | background-color: rgb(200, 200, 200);\ 116 | min-width: 20px;\ 117 | border-radius: 10px;\ 118 | }\ 119 | QScrollBar::add-line:horizontal {\ 120 | border: 0px solid grey;\ 121 | background: #32CC99;\ 122 | width: 0px;\ 123 | subcontrol-position: right;\ 124 | subcontrol-origin: margin;\ 125 | }\ 126 | QScrollBar::sub-line:horizontal {\ 127 | border: 0px solid grey;\ 128 | background: #32CC99;\ 129 | width: 0px;\ 130 | subcontrol-position: left;\ 131 | subcontrol-origin: margin;\ 132 | }\ 133 | QScrollBar:vertical {\ 134 | border: 0px solid grey;\ 135 | background-color: rgb(240, 240, 240);\ 136 | width: 35px;\ 137 | margin: 1px 0px 1px 0px;\ 138 | }\ 139 | QScrollBar::handle:vertical {\ 140 | background-color: rgb(200, 200, 200);\ 141 | min-height: 20px;\ 142 | border-radius: 10px;\ 143 | }\ 144 | QScrollBar::add-line:vertical {\ 145 | border: 0px solid grey;\ 146 | background: #32CC99;\ 147 | height: 0px;\ 148 | subcontrol-position: top;\ 149 | subcontrol-origin: margin;\ 150 | }\ 151 | QScrollBar::sub-line:vertical {\ 152 | border: 0px solid grey;\ 153 | background: #32CC99;\ 154 | height: 0px;\ 155 | subcontrol-position: bottom;\ 156 | subcontrol-origin: margin;\ 157 | }\ 158 | QCheckBox {\ 159 | spacing: 25px;\ 160 | }\ 161 | QCheckBox::indicator {\ 162 | width: 30px;\ 163 | height: 30px;\ 164 | }\ 165 | QRadioButton {\ 166 | font-size: 16px;\ 167 | } \ 168 | QPushButton {\ 169 | font-size: 16px;\ 170 | } \ 171 | QTreeWidget::item {\ 172 | border: 0px solid grey;\ 173 | height: 25px;\ 174 | font-size: 25px;\ 175 | }\ 176 | "; 177 | #endif 178 | -------------------------------------------------------------------------------- /src/FindBodyDialog.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2013 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | #include 29 | #include // toh, 2009.02.22 30 | #include 31 | 32 | #include "FindBodyDialog.h" 33 | 34 | #include "ocpn_plugin.h" 35 | 36 | #include "Sight.h" 37 | #include "celestial_navigation_pi.h" 38 | #include "geodesic.h" 39 | 40 | FindBodyDialog::FindBodyDialog( wxWindow* parent, Sight &sight ) 41 | : FindBodyDialogBase(parent), m_Sight(sight) 42 | { 43 | double lat, lon; 44 | celestial_navigation_pi_BoatPos(lat, lon); 45 | wxFileConfig *pConf = GetOCPNConfigObject(); 46 | pConf->SetPath( _T("/PlugIns/CelestialNavigation/FindBody") ); 47 | 48 | bool boat_position; 49 | pConf->Read( _T("BoatPosition"), &boat_position, true ); 50 | m_cbBoatPosition->SetValue(boat_position); 51 | 52 | bool magnetic_azimuth; 53 | pConf->Read( _T("MagneticAzimuth"), &magnetic_azimuth, false); 54 | m_cbMagneticAzimuth->SetValue(magnetic_azimuth); 55 | 56 | if(!m_cbBoatPosition->GetValue()) { 57 | pConf->Read( _T("Lat"), &lat, lat ); 58 | pConf->Read( _T("Lon"), &lon, lon ); 59 | } 60 | 61 | m_tLatitude->SetValue(wxString::Format(_T("%.4f"), lat)); 62 | m_tLongitude->SetValue(wxString::Format(_T("%.4f"), lon)); 63 | 64 | Centre(); 65 | Update(); 66 | } 67 | 68 | FindBodyDialog::~FindBodyDialog( ) 69 | { 70 | wxFileConfig *pConf = GetOCPNConfigObject(); 71 | pConf->SetPath( _T("/PlugIns/CelestialNavigation/FindBody") ); 72 | pConf->Write( _T("BoatPosition"), m_cbBoatPosition->GetValue()); 73 | pConf->Write( _T("MagneticAzimuth"), m_cbMagneticAzimuth->GetValue()); 74 | double lat, lon; 75 | if(m_tLatitude->GetValue().ToDouble(&lat)) 76 | pConf->Write( _T("Lat"), lat ); 77 | if(m_tLatitude->GetValue().ToDouble(&lon)) 78 | pConf->Write( _T("Lon"), lon ); 79 | } 80 | 81 | extern "C" int geomag_calc(double latitude, double longitude, double alt, 82 | int day, int month, double year, double results[14]); 83 | 84 | void FindBodyDialog::OnUpdate( wxCommandEvent& event ) 85 | { 86 | Update(); 87 | } 88 | 89 | void FindBodyDialog::OnDone( wxCommandEvent& event ) 90 | { 91 | EndModal(wxID_OK); 92 | } 93 | 94 | void FindBodyDialog::Update() 95 | { 96 | /* NOTE: we do not peform any altitude corrections here */ 97 | double lat1, lon1, lat2, lon2, bearing, dist; 98 | m_tLatitude->GetValue().ToDouble(&lat1); 99 | m_tLongitude->GetValue().ToDouble(&lon1); 100 | 101 | m_Sight.BodyLocation(m_Sight.m_DateTime, &lat2, &lon2, 0, 0); 102 | 103 | ll_gc_ll_reverse(lat1, lon1, lat2, lon2, &bearing, &dist); 104 | 105 | dist = 90 - dist/60; 106 | 107 | if(m_cbMagneticAzimuth->GetValue()) { 108 | double results[14]; 109 | 110 | geomag_calc(lat1, lon1, m_Sight.m_EyeHeight, 111 | m_Sight.m_DateTime.GetDay(), m_Sight.m_DateTime.GetMonth(), 112 | m_Sight.m_DateTime.GetYear(), results); 113 | bearing -= results[0]; 114 | } 115 | 116 | m_tAltitude->SetValue(wxString::Format(_T("%f"), dist)); 117 | m_tAzimuth->SetValue(wxString::Format(_T("%f"), bearing)); 118 | } 119 | -------------------------------------------------------------------------------- /src/bzip2/randtable.c: -------------------------------------------------------------------------------- 1 | 2 | /*-------------------------------------------------------------*/ 3 | /*--- Table for randomising repetitive blocks ---*/ 4 | /*--- randtable.c ---*/ 5 | /*-------------------------------------------------------------*/ 6 | 7 | /*-- 8 | This file is a part of bzip2 and/or libbzip2, a program and 9 | library for lossless, block-sorting data compression. 10 | 11 | Copyright (C) 1996-2002 Julian R Seward. All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions 15 | are met: 16 | 17 | 1. Redistributions of source code must retain the above copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 20 | 2. The origin of this software must not be misrepresented; you must 21 | not claim that you wrote the original software. If you use this 22 | software in a product, an acknowledgment in the product 23 | documentation would be appreciated but is not required. 24 | 25 | 3. Altered source versions must be plainly marked as such, and must 26 | not be misrepresented as being the original software. 27 | 28 | 4. The name of the author may not be used to endorse or promote 29 | products derived from this software without specific prior written 30 | permission. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 33 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 38 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Julian Seward, Cambridge, UK. 45 | jseward@acm.org 46 | bzip2/libbzip2 version 1.0 of 21 March 2000 47 | 48 | This program is based on (at least) the work of: 49 | Mike Burrows 50 | David Wheeler 51 | Peter Fenwick 52 | Alistair Moffat 53 | Radford Neal 54 | Ian H. Witten 55 | Robert Sedgewick 56 | Jon L. Bentley 57 | 58 | For more information on these sources, see the manual. 59 | --*/ 60 | 61 | 62 | #include "bzlib_private.h" 63 | 64 | 65 | /*---------------------------------------------*/ 66 | Int32 BZ2_rNums[512] = { 67 | 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, 68 | 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, 69 | 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, 70 | 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, 71 | 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, 72 | 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, 73 | 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, 74 | 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, 75 | 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, 76 | 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, 77 | 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, 78 | 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, 79 | 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, 80 | 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, 81 | 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, 82 | 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, 83 | 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, 84 | 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, 85 | 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, 86 | 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, 87 | 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, 88 | 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, 89 | 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, 90 | 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, 91 | 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, 92 | 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, 93 | 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, 94 | 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, 95 | 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, 96 | 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, 97 | 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, 98 | 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, 99 | 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, 100 | 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, 101 | 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, 102 | 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, 103 | 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, 104 | 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, 105 | 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, 106 | 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, 107 | 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, 108 | 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, 109 | 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, 110 | 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, 111 | 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, 112 | 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, 113 | 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, 114 | 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, 115 | 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, 116 | 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 117 | 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 118 | 936, 638 119 | }; 120 | 121 | 122 | /*-------------------------------------------------------------*/ 123 | /*--- end randtable.c ---*/ 124 | /*-------------------------------------------------------------*/ 125 | -------------------------------------------------------------------------------- /src/astrolabe/sun.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2000, 2001 William McClain 2 | 3 | This file is part of Astrolabe. 4 | 5 | Astrolabe is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | Astrolabe is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with Astrolabe; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* Geocentric solar position and radius, both low and high precision. */ 21 | 22 | /* 23 | High precision position calculations. 24 | 25 | This is a very light wrapper around the VSOP87d class. The geocentric longitude of 26 | the Sun is simply the heliocentric longitude of the Earth + 180 degrees. The 27 | geocentric latitude of the Sun is the negative of the heliocentric latitude of the 28 | Earth. The radius is of course the same in both coordinate systems. 29 | 30 | */ 31 | 32 | #include 33 | #include "astrolabe.hpp" 34 | 35 | using std::vector; 36 | 37 | using astrolabe::Coords; 38 | using astrolabe::util::d_to_r; 39 | using astrolabe::util::dms_to_d; 40 | using astrolabe::util::modpi2; 41 | using astrolabe::util::polynomial; 42 | using astrolabe::calendar::jd_to_jcent; 43 | using astrolabe::constants::pi; 44 | 45 | double astrolabe::sun::Sun::dimension(double jd, Coords dim) const { 46 | /* Return one of geocentric ecliptic longitude, latitude and radius. 47 | 48 | Parameters: 49 | jd : Julian Day in dynamical time 50 | dim : one of "L" (longitude) or "B" (latitude) or "R" (radius). 51 | 52 | Returns: 53 | Either longitude in radians, or 54 | latitude in radians, or 55 | radius in au. 56 | 57 | */ 58 | double X = vsop.dimension(jd, vEarth, dim); 59 | if (dim == vL) 60 | X = modpi2(X + pi); 61 | else if (dim == vB) 62 | X = -X; 63 | return X; 64 | } 65 | 66 | void astrolabe::sun::Sun::dimension3(double jd, double &L, double &B, double &R) const { 67 | /* Return geocentric ecliptic longitude, latitude and radius. 68 | 69 | Parameters: 70 | jd : Julian Day in dynamical time 71 | 72 | Returns: 73 | longitude in radians 74 | latitude in radians 75 | radius in au 76 | 77 | */ 78 | L = dimension(jd, vL); 79 | B = dimension(jd, vB); 80 | R = dimension(jd, vR); 81 | } 82 | 83 | void astrolabe::sun::longitude_radius_low(double jd, double &L, double &R) { 84 | /* Return geometric longitude and radius vector. 85 | 86 | Low precision. The longitude is accurate to 0.01 degree. 87 | The latitude should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5 88 | 89 | Parameters: 90 | jd : Julian Day in dynamical time 91 | 92 | Returns: 93 | longitude in radians 94 | radius in au 95 | 96 | */ 97 | // 98 | // Constant terms 99 | // 100 | static const double _kL0[] = {d_to_r(280.46646), d_to_r(36000.76983), d_to_r( 0.0003032)}; 101 | static const VECTOR(kL0, double); 102 | 103 | static const double _kM[] = {d_to_r(357.52911), d_to_r(35999.05029), d_to_r(-0.0001537)}; 104 | static const VECTOR(kM, double); 105 | 106 | static const double _kC[] = {d_to_r( 1.914602), d_to_r( -0.004817), d_to_r(-0.000014)}; 107 | static const VECTOR(kC, double); 108 | 109 | static const double _ke[] = {0.016708634, -0.000042037, -0.0000001267}; 110 | static const VECTOR(ke, double); 111 | 112 | static const double _ck3 = d_to_r( 0.019993); 113 | static const double _ck4 = d_to_r(-0.000101); 114 | static const double _ck5 = d_to_r( 0.000289); 115 | 116 | const double T = jd_to_jcent(jd); 117 | const double L0 = polynomial(kL0, T); 118 | const double M = polynomial(kM, T); 119 | const double e = polynomial(ke, T); 120 | const double C = polynomial(kC, T) * sin(M) 121 | + (_ck3 - _ck4 * T) * sin(2 * M) 122 | + _ck5 * sin(3 * M); 123 | L = modpi2(L0 + C); 124 | const double v = M + C; 125 | R = 1.000001018 * (1 - e * e) / (1 + e * cos(v)); 126 | } 127 | 128 | double astrolabe::sun::apparent_longitude_low(double jd, double L) { 129 | /* Correct the geometric longitude for nutation and aberration. 130 | 131 | Low precision. [Meeus-1998: pg 164] 132 | 133 | Parameters: 134 | jd : Julian Day in dynamical time 135 | L : longitude in radians 136 | 137 | Returns: 138 | corrected longitude in radians 139 | 140 | */ 141 | // 142 | // Constant terms 143 | // 144 | static const double _lk0 = d_to_r(125.04); 145 | static const double _lk1 = d_to_r(1934.136); 146 | static const double _lk2 = d_to_r(0.00569); 147 | static const double _lk3 = d_to_r(0.00478); 148 | 149 | const double T = jd_to_jcent(jd); 150 | const double omega = _lk0 - _lk1 * T; 151 | return modpi2(L - _lk2 - _lk3 * sin(omega)); 152 | } 153 | 154 | double astrolabe::sun::aberration_low(double R) { 155 | /* Correct for aberration; low precision, but good enough for most uses. 156 | 157 | [Meeus-1998: pg 164] 158 | 159 | Parameters: 160 | R : radius in au 161 | 162 | Returns: 163 | correction in radians 164 | 165 | */ 166 | // 167 | // Constant terms 168 | // 169 | static const double _lk4 = d_to_r(dms_to_d(0, 0, 20.4898)); 170 | //static const double _lk4 = d_to_r(dms_to_d(0, 0, 6.5)); 171 | 172 | return -_lk4 / R; 173 | } 174 | 175 | -------------------------------------------------------------------------------- /src/Sight.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Support 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2013 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | * 26 | */ 27 | 28 | 29 | #include 30 | 31 | #ifdef __MSVC__ 32 | #include 33 | #include 34 | #include 35 | #define NAN std::numeric_limits::quiet_NaN () 36 | #define INFINITY std::numeric_limits::infinity () 37 | 38 | #define isnan _isnan 39 | #define isinf(x) (!_finite(x) && !_isnan(x)) 40 | 41 | #define trunc(d) ( ((d)>0) ? floor(d) : ceil(d) ) 42 | #endif 43 | 44 | WX_DECLARE_LIST(wxRealPoint, wxRealPointList); 45 | 46 | class piDC; 47 | 48 | // Sight 49 | //---------------------------------------------------------------------------- 50 | 51 | const wxString SightType[] = {_("Altitude"), _("Azimuth"), _("Lunar")}; 52 | 53 | class Sight : public wxObject 54 | { 55 | public: 56 | enum Type {ALTITUDE, AZIMUTH, LUNAR}; 57 | enum BodyLimb {LOWER, CENTER, UPPER}; 58 | 59 | Sight() { s_lastsightcolor++; } 60 | Sight(Type type, wxString body, BodyLimb bodylimb, wxDateTime datetime, 61 | double timecertainty, double measurement, double measurementcertainty); 62 | 63 | ~Sight(); 64 | 65 | void SetVisible(bool visible = true); ///< set visibility and make points selectable accordingly 66 | bool IsVisible() { return m_bVisible; } 67 | 68 | void Recompute(int clock_offset); 69 | void RebuildPolygons(); 70 | 71 | wxString Alminac(double lat, double lon, double ghaast, double rad, double SD, double HP); 72 | void RecomputeAltitude(); 73 | void RecomputeAzimuth(); 74 | void RecomputeLunar(); 75 | 76 | void RebuildPolygonsAltitude(); 77 | void RebuildPolygonsAzimuth(); 78 | 79 | bool m_bVisible; // should this sight be drawn? 80 | 81 | Type m_Type; 82 | wxString m_Body; 83 | BodyLimb m_BodyLimb; 84 | 85 | wxDateTime m_DateTime; // Time for the sight 86 | double m_TimeCertainty; 87 | 88 | double m_Measurement; // Measurement angle in degrees (NaN is valid for all) 89 | double m_MeasurementCertainty; 90 | double m_LunarMoonAltitude, m_LunarBodyAltitude; 91 | 92 | double m_EyeHeight; // Height above sea in meters 93 | double m_Temperature; // Temperature in degrees celcius 94 | double m_Pressure; // Pressure in millibars 95 | double m_IndexError; // Error of measurement in degrees 96 | 97 | double m_ShiftNm; // direction to move points 98 | double m_ShiftBearing; // direction to move points 99 | bool m_bMagneticShiftBearing; // use magnetic or true for shift 100 | 101 | wxString m_ColourName; 102 | wxColour m_Colour; // Color of the sight 103 | 104 | virtual void Render(piDC &dc, PlugIn_ViewPort &pVP); 105 | 106 | void BodyLocation(wxDateTime time, double *lat, double *lon, double *ghaash, double *rad); 107 | std::list GetPoints(); 108 | 109 | wxString m_CalcStr; 110 | 111 | /* for altitude */ 112 | double m_ObservedAltitude; /* after all corrections are applied */ 113 | 114 | /* for azimuth */ 115 | bool m_bMagneticNorth; // if azimuth angle is in magnetic coordinates 116 | 117 | /* for lunar */ 118 | double m_TimeCorrection; 119 | 120 | protected: 121 | double CalcAngle(wxRealPoint p1, wxRealPoint p2); 122 | double ComputeStepSize(double certainty, double stepsize, double min, double max); 123 | 124 | wxRealPointList *MergePoints(wxRealPointList *p1, wxRealPointList *p2); 125 | wxRealPointList *ReduceToConvexPolygon(wxRealPointList *points); 126 | 127 | std::list polygons; 128 | 129 | private: 130 | wxRealPoint DistancePoint( double altitude, double trace, double lat, double lon); 131 | void BuildAltitudeLineOfPosition(double altitudemin, double altitudemax, double altitudestep, 132 | double tracestep, double timemin, double timemax, double timestep); 133 | bool BearingPoint(double altitude, double trace, 134 | double &rlat, double &rlon, double &lasttrace, double &llat, double &llon, 135 | double lat, double lon); 136 | void BuildBearingLineOfPosition(double altitudestep, 137 | double azimuthmin, double azimuthmax, double azimuthstep, 138 | double timemin, double timemax, double timestep); 139 | 140 | void DrawPolygon(piDC &dc, PlugIn_ViewPort &vp, wxRealPointList &area); 141 | 142 | wxDateTime m_CorrectedDateTime; 143 | 144 | static int s_lastsightcolor; 145 | }; 146 | 147 | double resolve_heading(double heading); 148 | double resolve_heading_positive(double heading); 149 | 150 | -------------------------------------------------------------------------------- /src/transform_star.cpp: -------------------------------------------------------------------------------- 1 | #include "cmath" 2 | #include "astrolabe/astrolabe.hpp" 3 | 4 | using namespace astrolabe; 5 | using namespace astrolabe::calendar; 6 | using namespace astrolabe::nutation; 7 | 8 | /* Equations come from 9 | United States Naval Observatory Circular No. 179: 10 | The IAU Resolutions on Astronomical Reference Systems, Time Scales, and Earth Rotation Models: 11 | Explanation and Implementation 12 | by 13 | George H. Kaplan 14 | 15 | Downloaded from http://aa.usno.navy.mil/publications/docs/Circular_179.pdf */ 16 | 17 | 18 | const double mas_to_rad = 4.8481368110953599359e-9; // radians per milli-arc-second */ 19 | const double as_to_rad = 4.8481368110953599359e-6; // radians per arc second */ 20 | const double J2000 = cal_to_jd(2000,1,1.5,true); // 2000 January 1.5 21 | 22 | 23 | void frame_bias (double &ra, double &dec) { 24 | 25 | double r[3], x[3], B[3][3]; 26 | int i,j; 27 | 28 | // eq. 5.1 or 3.2 from Circular 179: 29 | 30 | r[0] = cos(ra) * cos(dec); 31 | r[1] = sin(ra) * cos(dec); 32 | r[2] = sin(dec); 33 | 34 | const double deltaAlpha_0 = -14.6 * mas_to_rad; 35 | const double xi_0 = -16.6170 * mas_to_rad; 36 | const double eta_0 = -6.8192 * mas_to_rad; 37 | 38 | // eq. 3.3 from Circular 179: 39 | 40 | B[0][0] = 1.; 41 | B[0][1] = deltaAlpha_0; 42 | B[0][2] = -xi_0; 43 | B[1][0] = -deltaAlpha_0; 44 | B[1][1] = 1.; 45 | B[1][2] = -eta_0; 46 | B[2][0] = xi_0; 47 | B[2][1] = eta_0; 48 | B[2][2] = 1.; 49 | 50 | for(i=0;i<3;++i) { 51 | x[i] = 0.; 52 | for (j=0;j<3;++j) 53 | x[i] += B[i][j] * r[j]; 54 | } 55 | 56 | // eq. 5.2 from Circular 179: 57 | 58 | ra = atan2(x[1], x[0]); 59 | dec = atan2(x[2],sqrt(x[0]*x[0] + x[1]*x[1])); 60 | 61 | } 62 | 63 | void nutate (double jdd, double &ra, double &dec) { 64 | 65 | double r[3], x[3], N[3][3]; 66 | int i,j; 67 | 68 | // eq. 5.1 from Circular 179: 69 | 70 | r[0] = cos(ra) * cos(dec); 71 | r[1] = sin(ra) * cos(dec); 72 | r[2] = sin(dec); 73 | 74 | // nutation in longitude 75 | const double deltaPsi = nut_in_lon(jdd); 76 | 77 | // nutation in obliquity 78 | const double deltaEps = nut_in_obl(jdd); 79 | 80 | // mean obliquity 81 | const double eps = obliquity(jdd); 82 | 83 | // true obliquity 84 | const double epsPrime = eps + deltaEps; 85 | 86 | // eq. 5.20 from Circular 179: 87 | 88 | double S1 = sin(eps), S2 = sin(-deltaPsi), S3 = sin(-epsPrime); 89 | double C1 = cos(eps), C2 = cos(-deltaPsi), C3 = cos(-epsPrime); 90 | 91 | // eq. 5.21 from Circular 179: 92 | 93 | N[0][0] = C2; 94 | N[0][1] = S2*C1; 95 | N[0][2] = S2*S1; 96 | N[1][0] = -S2*C3; 97 | N[1][1] = C3*C2*C1 - S1*S3; 98 | N[1][2] = C3*C2*S1 + C1*S3; 99 | N[2][0] = S2*S3; 100 | N[2][1] = -S3*C2*C1 - S1*C3; 101 | N[2][2] = -S3*C2*S1 + C3*C1; 102 | 103 | for(i=0;i<3;++i) { 104 | x[i] = 0.; 105 | for (j=0;j<3;++j) 106 | x[i] += N[i][j] * r[j]; 107 | } 108 | 109 | // eq. 5.2 from Circular 179: 110 | 111 | ra = atan2(x[1], x[0]); 112 | dec = atan2(x[2],sqrt(x[0]*x[0] + x[1]*x[1])); 113 | 114 | } 115 | 116 | void precess (double jdd, double &ra, double &dec) { 117 | 118 | const double eps_0 = obliquity(J2000)/as_to_rad; //obliquity of the ecliptic at J2000.0 119 | 120 | double psi_a, om_a, chi_a; 121 | double r[3], x[3], P[3][3]; 122 | int i,j; 123 | 124 | #define sinas(x) sin(as_to_rad * x) 125 | #define cosas(x) cos(as_to_rad * x) 126 | 127 | if( jdd == J2000 ) 128 | return; 129 | 130 | // eq. 5.1 from Circular 179: 131 | 132 | r[0] = cos(ra) * cos(dec); 133 | r[1] = sin(ra) * cos(dec); 134 | r[2] = sin(dec); 135 | 136 | double T = (jdd - J2000)/36525.0; 137 | 138 | // eq. 5.8 from Circular 179: 139 | 140 | psi_a = (((( - 0.0000000951 * T 141 | + 0.000132851 ) * T 142 | - 0.00114045 ) * T 143 | - 1.0790069 ) * T 144 | + 5038.481507 ) * T; 145 | 146 | om_a = (((( + 0.0000003337 * T 147 | - 0.000000467 ) * T 148 | - 0.00772503 ) * T 149 | + 0.0512623 ) * T 150 | - 0.025754 ) * T + eps_0; 151 | 152 | chi_a = (((( - 0.0000000560 * T 153 | + 0.000170663 ) * T 154 | - 0.00121197 ) * T 155 | - 2.3814292 ) * T 156 | + 10.556403 ) * T; 157 | 158 | // eq. 5.9 from Circular 179: 159 | 160 | double S1 = sinas(eps_0), S2 = sinas(-psi_a), S3 = sinas(-om_a), S4 = sinas(chi_a); 161 | double C1 = cosas(eps_0), C2 = cosas(-psi_a), C3 = cosas(-om_a), C4 = cosas(chi_a); 162 | 163 | // eq. 5.10 from Circular 179: 164 | 165 | P[0][0] = C4*C2 - S2*S4*C3; 166 | P[0][1] = C4*S2*C1 + S4*C3*C2*C1 - S1*S4*S3; 167 | P[0][2] = C4*S2*S1 + S4*C3*C2*S1 + C1*S4*S3; 168 | P[1][0] = -S4*C2 - S2*C4*C3; 169 | P[1][1] = -S4*S2*C1 + C4*C3*C2*C1 - S1*C4*S3; 170 | P[1][2] = -S4*S2*S1 + C4*C3*C2*S1 + C1*C4*S3; 171 | P[2][0] = S2*S3; 172 | P[2][1] = -S3*C2*C1 - S1*C3; 173 | P[2][2] = -S3*C2*S1 + C3*C1; 174 | 175 | for(i=0;i<3;++i) { 176 | x[i] = 0.; 177 | for (j=0;j<3;++j) 178 | x[i] += P[i][j] * r[j]; 179 | } 180 | 181 | // eq. 5.2 from Circular 179: 182 | 183 | ra = atan2(x[1], x[0]); 184 | dec = atan2(x[2],sqrt(x[0]*x[0] + x[1]*x[1])); 185 | 186 | } 187 | 188 | int iauEpv00_wrapper(double date, double* pob); 189 | 190 | void proper_motion_parallax (double jdd, double &ra, double &dec, double dra, double ddec, double radvel, double parallax) { 191 | 192 | /* based on function pmpx from the sofa library - http://www.iausofa.org */ 193 | 194 | double pob[3]; 195 | 196 | double r[3], pm[3]; 197 | int i; 198 | 199 | // eq. 5.1 from Circular 179: 200 | 201 | r[0] = cos(ra) * cos(dec); 202 | r[1] = sin(ra) * cos(dec); 203 | r[2] = sin(dec); 204 | 205 | dra = atan2 ( dra * mas_to_rad , cos(dec) ); // convert from milli-arcsec * cos(doc) to radians per year 206 | ddec = ddec * mas_to_rad; // convert from milli-arcsec to radians per year 207 | parallax = parallax * mas_to_rad; // convert from milli-arcsec to radians 208 | 209 | iauEpv00_wrapper(jdd, &pob[0]); //get barycentric Earth position 210 | 211 | //std::cout << "POB vector: " << pob[0] << ", " << pob[1] << ", " << pob[2] << endl; 212 | 213 | double T = (jdd - J2000)/365.25; /* in Julian years - not centuries! */ 214 | 215 | double w = parallax * radvel * 86400.0 * 365250.0 / 1.49597870e11; // parallax in radians * radvel in AU/year 216 | double pdz = ddec * r[2]; 217 | 218 | pm[0] = -dra * r[1] - pdz * cos(ra) + w * r[0]; 219 | pm[1] = dra * r[0] - pdz * sin(ra) + w * r[1]; 220 | pm[2] = ddec * cos(dec) + w * r[2]; 221 | 222 | for(i=0;i<3;++i) { 223 | r[i] += T * pm[i] - parallax * pob[i]; 224 | } 225 | // note: at this stage r is no longer a unit vector - but this doesn't matter 226 | 227 | // eq. 5.2 from Circular 179: 228 | 229 | ra = atan2(r[1], r[0]); 230 | dec = atan2(r[2],sqrt(r[0]*r[0] + r[1]*r[1])); 231 | 232 | } 233 | 234 | 235 | -------------------------------------------------------------------------------- /src/plugingl/pidc.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Layer to use wxDC or opengl 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2011 by Sean D'Epagnier * 9 | * sean at depagnier dot com * 10 | * * 11 | * This program is free software; you can redistribute it and/or modify * 12 | * it under the terms of the GNU General Public License as published by * 13 | * the Free Software Foundation; either version 2 of the License, or * 14 | * (at your option) any later version. * 15 | * * 16 | * This program is distributed in the hope that it will be useful, * 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 19 | * GNU General Public License for more details. * 20 | * * 21 | * You should have received a copy of the GNU General Public License * 22 | * along with this program; if not, write to the * 23 | * Free Software Foundation, Inc., * 24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 25 | *************************************************************************** 26 | * 27 | *f 28 | */ 29 | 30 | 31 | #ifndef __PIDC_H__ 32 | #define __PIDC_H__ 33 | 34 | #include 35 | #include "linmath.h" 36 | 37 | #include "TexFont.h" 38 | #include "ocpn_plugin.h" 39 | 40 | 41 | #ifdef ocpnUSE_GL 42 | #include 43 | #endif 44 | 45 | //class ViewPort; 46 | class GLUtesselator; 47 | 48 | void DrawGLThickLine( float x1, float y1, float x2, float y2, wxPen pen, bool b_hiqual ); 49 | 50 | //---------------------------------------------------------------------------- 51 | // piDC 52 | //---------------------------------------------------------------------------- 53 | 54 | class wxGLCanvas; 55 | 56 | class piDC 57 | { 58 | public: 59 | piDC(wxGLCanvas &canvas); 60 | piDC(wxDC &pdc); 61 | piDC(); 62 | 63 | ~piDC(); 64 | 65 | void SetBackground( const wxBrush &brush ); 66 | void SetPen( const wxPen &pen); 67 | void SetBrush( const wxBrush &brush); 68 | void SetTextForeground(const wxColour &colour); 69 | void SetTextBackground(const wxColour &colour); 70 | void SetFont(const wxFont& font); 71 | static void SetGLAttrs( bool highQuality ); 72 | void SetGLStipple() const; 73 | void SetVP(PlugIn_ViewPort *vp); 74 | void SetDC(wxDC *dc_in){dc = dc_in;} 75 | 76 | const wxPen& GetPen() const; 77 | const wxBrush& GetBrush() const; 78 | const wxFont& GetFont() const; 79 | 80 | void GetSize(wxCoord *width, wxCoord *height) const; 81 | 82 | void DrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, bool b_hiqual = true); 83 | void DrawLines( int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, bool b_hiqual = true); 84 | 85 | void StrokeLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); 86 | void StrokeLine( wxPoint a, wxPoint b) { StrokeLine(a.x, a.y, b.x, b.y); } 87 | void StrokeLines( int n, wxPoint *points); 88 | 89 | void Clear(); 90 | void DrawRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h ); 91 | void DrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord w, wxCoord h, wxCoord rr ); 92 | void DrawCircle(wxCoord x, wxCoord y, wxCoord radius); 93 | void DrawCircle(const wxPoint &pt, wxCoord radius) { DrawCircle(pt.x, pt.y, radius); } 94 | void StrokeCircle(wxCoord x, wxCoord y, wxCoord radius); 95 | 96 | void DrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); 97 | void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, float scale =1.0, float angle = 0.0); 98 | void DrawPolygonTessellated(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); 99 | void StrokePolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, float scale = 1.0); 100 | 101 | void DrawBitmap(const wxBitmap &bitmap, wxCoord x, wxCoord y, bool usemask); 102 | 103 | void DrawText(const wxString &text, wxCoord x, wxCoord y); 104 | void GetTextExtent(const wxString &string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, 105 | wxCoord *externalLeading = NULL, wxFont *font = NULL); 106 | 107 | void ResetBoundingBox(); 108 | void CalcBoundingBox(wxCoord x, wxCoord y); 109 | 110 | void DestroyClippingRegion() {} 111 | 112 | wxDC *GetDC() const { return dc; } 113 | 114 | void DrawGLLineArray( int n, float *vertex_array, unsigned char *color_array, bool b_hiqual ); 115 | void DrawGLLineArray( int n, float *vertex_array, float *color_array, bool b_hiqual ); 116 | 117 | #ifdef ocpnUSE_GL 118 | GLfloat *s_odc_tess_work_buf; 119 | #endif 120 | 121 | #ifdef USE_ANDROID_GLES2 122 | int s_odc_tess_vertex_idx; 123 | int s_odc_tess_vertex_idx_this; 124 | int s_odc_tess_buf_len; 125 | GLenum s_odc_tess_mode; 126 | int s_odc_nvertex; 127 | vec4 s_odc_tess_color; 128 | //ViewPort *s_odc_tessVP; 129 | GLUtesselator *m_tobj; 130 | 131 | #endif 132 | 133 | protected: 134 | bool ConfigurePen(); 135 | bool ConfigureBrush(); 136 | 137 | void GLDrawBlendData(wxCoord x, wxCoord y, wxCoord w, wxCoord h, 138 | int format, const unsigned char *data); 139 | 140 | void drawrrhelperGLES2( wxCoord x0, wxCoord y0, wxCoord r, int quadrant, int steps ); 141 | 142 | wxGLCanvas *glcanvas; 143 | wxDC *dc; 144 | wxPen m_pen; 145 | wxBrush m_brush; 146 | wxColour m_textforegroundcolour; 147 | wxColour m_textbackgroundcolour; 148 | wxFont m_font; 149 | 150 | #ifdef ocpnUSE_GL 151 | TexFont m_texfont; 152 | #endif 153 | bool m_buseTex; 154 | 155 | #if wxUSE_GRAPHICS_CONTEXT 156 | wxGraphicsContext *pgc; 157 | #endif 158 | 159 | float *workBuf; 160 | size_t workBufSize; 161 | unsigned int workBufIndex; 162 | 163 | wxSize m_vpSize; 164 | 165 | }; 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /src/bzip2/crctable.c: -------------------------------------------------------------------------------- 1 | 2 | /*-------------------------------------------------------------*/ 3 | /*--- Table for doing CRCs ---*/ 4 | /*--- crctable.c ---*/ 5 | /*-------------------------------------------------------------*/ 6 | 7 | /*-- 8 | This file is a part of bzip2 and/or libbzip2, a program and 9 | library for lossless, block-sorting data compression. 10 | 11 | Copyright (C) 1996-2002 Julian R Seward. All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions 15 | are met: 16 | 17 | 1. Redistributions of source code must retain the above copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 20 | 2. The origin of this software must not be misrepresented; you must 21 | not claim that you wrote the original software. If you use this 22 | software in a product, an acknowledgment in the product 23 | documentation would be appreciated but is not required. 24 | 25 | 3. Altered source versions must be plainly marked as such, and must 26 | not be misrepresented as being the original software. 27 | 28 | 4. The name of the author may not be used to endorse or promote 29 | products derived from this software without specific prior written 30 | permission. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 33 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 38 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Julian Seward, Cambridge, UK. 45 | jseward@acm.org 46 | bzip2/libbzip2 version 1.0 of 21 March 2000 47 | 48 | This program is based on (at least) the work of: 49 | Mike Burrows 50 | David Wheeler 51 | Peter Fenwick 52 | Alistair Moffat 53 | Radford Neal 54 | Ian H. Witten 55 | Robert Sedgewick 56 | Jon L. Bentley 57 | 58 | For more information on these sources, see the manual. 59 | --*/ 60 | 61 | 62 | #include "bzlib_private.h" 63 | 64 | /*-- 65 | I think this is an implementation of the AUTODIN-II, 66 | Ethernet & FDDI 32-bit CRC standard. Vaguely derived 67 | from code by Rob Warnock, in Section 51 of the 68 | comp.compression FAQ. 69 | --*/ 70 | 71 | UInt32 BZ2_crc32Table[256] = { 72 | 73 | /*-- Ugly, innit? --*/ 74 | 75 | 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L, 76 | 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L, 77 | 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L, 78 | 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL, 79 | 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L, 80 | 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L, 81 | 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L, 82 | 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL, 83 | 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L, 84 | 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L, 85 | 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L, 86 | 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL, 87 | 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L, 88 | 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L, 89 | 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L, 90 | 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL, 91 | 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL, 92 | 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L, 93 | 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L, 94 | 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL, 95 | 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL, 96 | 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L, 97 | 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L, 98 | 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL, 99 | 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL, 100 | 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L, 101 | 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L, 102 | 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL, 103 | 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL, 104 | 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L, 105 | 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L, 106 | 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL, 107 | 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L, 108 | 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL, 109 | 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL, 110 | 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L, 111 | 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L, 112 | 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL, 113 | 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL, 114 | 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L, 115 | 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L, 116 | 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL, 117 | 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL, 118 | 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L, 119 | 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L, 120 | 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL, 121 | 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL, 122 | 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L, 123 | 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L, 124 | 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL, 125 | 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L, 126 | 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L, 127 | 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L, 128 | 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL, 129 | 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L, 130 | 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L, 131 | 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L, 132 | 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, 133 | 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, 134 | 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, 135 | 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, 136 | 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, 137 | 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, 138 | 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L 139 | }; 140 | 141 | 142 | /*-------------------------------------------------------------*/ 143 | /*--- end crctable.c ---*/ 144 | /*-------------------------------------------------------------*/ 145 | -------------------------------------------------------------------------------- /src/icons.cpp: -------------------------------------------------------------------------------- 1 | /* Autogenerated by png2wx.pl on Sat Feb 23 14:55:26 2013 */ 2 | #include 3 | #ifndef WX_PRECOMP 4 | # include 5 | #endif 6 | #include 7 | #include "icons.h" 8 | 9 | wxBitmap *_img_celestial_navigation; 10 | 11 | void initialize_images(void) 12 | { 13 | { 14 | wxMemoryInputStream sm("\211PNG\r\n\032\n\000\000\000\rIHDR\000\000\000 \000\000\000 \b\006\000\000\000szz\364\000\000\000\001sRGB\000\256\316\034\351\000\000\000\006bKGD\000\377\000\377\000\377\240\275\247\223\000\000\000\011pHYs\000\000\r\327\000\000\r\327\001B(\233x\000\000\000\atIME\a\335\002\027\0017\025)b\267\377\000\000\0118IDATX\303M\227K\257e\327Q\307\177Uk\355\307y\334\333\367\341\333n\273\273m\267\301\261\215-\313\201\310\246A \024)\022\231\300\b\301\000\011\361\001\020\023\306(\237\000\0111\313\b\220\230@\200\001\003@\002\011\241\3044\235\304\030\223\304\217@\234\216\333m\273\351n\367\275\367<\366\336k\255*\006\353\270\205\3169\332Z\247\326^U\265\352\377\257\207,g\207.\200\213 \016\"\002\310\356+\000\210\200\0038\210\203\0138\276\223\033x]?\372\370\377\373\341\365Ew\314\0350\334\252\014\021b=D\020\001\021\335iP\202\200\001*\202\003Q\024s\303\001qA\304\301\034' b\270\201\002&\002b\b\202\211#V\3371\021\324\rGA\rL\000'\212*\237\373*\"\210\b\305\340\344\342\001\327_{\236O>}\310\215\233\357C\024B\210\2309\b\340\216\253\243\200\273\020\3241\034\261z\216\213U\231*\270\2438\246\202\270\324uT,g\242\240\210P\215P\001\027\256^9\342\017~\377\327\271\366\314e\026}\341\327~\363\217H)\243\252\b\006V\017S\247*\025p7\324\301\203\343\006\342\212IA0L\005\314Q\252aBD\334v!\250wO`\027h\021\256\277\366\"W\256\\a6\357\330;<\"h K\001s\232\330\222KB|\a\025\001\254\202\303\021\304\n\004\301]\320\342\230\b\342\206\310\347\267\256\250\n9\033\202\242*J\020\005\011H\210\250F>\372\350!\267><\243\233\035\363\215o\374+\233\355\210j@U1sbhQQT\204\340BP!\212\022\020T\265\312\024$hU\202\"\"(BPE\244\256\021A.\036^u\321\272\351s\364\273\303\245\213\207\000\334\271s\237\320\004\304\035w\000h\273\216i\032*\016\250\377k\014\224\234v\3107\314v\0140\307\314p7\034\247i\032\2064\324}f\310\223'\317\272\242\250\352\356J\005A1\367G\324C\034/\206;\270T\014t}\3070L;\243\254\032n\206\213\343\305q\251J\253r`g\200(L9\327\265;\261m[B\210\b\202j\000\367\212b\352\201\346N.\016bUAe)n\320\267\035c\232p\257HG\252@\002\230i%K\000J\025/\026=\353\325\232\200b\n\230\021\347\363%!\204\312w\253\312\315\035\014\212;X!\250Qr\241\310\316\200\0029\033\363\371\214\224s\365\332\034q\307\024\334\035\325\032\232hB\016F\333\366\214\343\204(\210\011\352\212\341\304\345bA\014\221\020\002\356`f\0243\274\030\305\n\245\030\301\2144N\250\031\245H\245^)\214\303\300|>g\263^\343\272KPVs\211\273\001\212\211\241(}\327q>\215\b\212\250\343V\020\224\270\\.\231\317\347;\257\035\333\201\246\230c93\214c\315\001(\271$\254\004\212\331nO!hd>_\260\035\006\034#\004\301\314j8\304Qw\372~NJ\011a\20737Djl\342r\261\244\237\367\270Q)\026\003m\3232\216\003\333a$\254#\323\224(mf;NXNL\323DA\021\204\2243{{K\034\310y\2527\026\002NuF%2\353gl\266\033$\204\212W\a\325*\217\375\254\247k\273\232\214\005\372\256\247\355[\206MG\333\r4\261au\276fJ\023\356NVA5b^HS\002\034+\306\245K\227\270\177\377>\245\024rN\024+\2108\207\207\a\234\235\237\0224`\305\260]\306u\253\005 \252\352\016\204J\214\221\030\003%\227\232\271\212\021TY,\346\364\271ch[\306\355\200\2313\245D\014\021\257Grrr\002\002\347\247\347\244\034I9\263\230\317\370\302\013?\315\277\337\270\211\206\260+\212\206\272\342j\210)\321v\374\326\240\204&`\005\246q\244\230\241\032\210\021\212\031\242\302\254\237qp\341\002\253U\275\221<%Dk\254c\014\274\366\372\317\361\326\233o\263ZoP\205\227_~\221;w>&\304H4\243\204\232\345\212\027\"\221L\"\202\020c\244i[r\312X1R1\260\352}\354C\345u\251\025PTx\354\370\230~\326\222rf\263\331\022\203\262wa\237+W.srr\314\355\333\037\263\267\267\344\350\370\200[\267>\244iZ\304\225\0222I\200,\024\257\305-\212\b^\274f<\027r.5\341XU\3265\rGG\207<\377\322s\\}\352\n\313\013\3734\363\031M\333\320\205@\323\004\246\315\300g\017\036\360\3643W9\271\370\030\242\302g\017\036r\363\215\357\360\355\033\a\334\275\373\277L\016);\356\r\bXr\324!\206\030(\2450\215S\245W\251y<\210\362\370\245\213|\351\365/\362\354\027\256\361\375\037\336\342?~r\217\321>e\023\032\346\363\226\313\217\355s\351\342\021\317>~\314KO_\246\321JA/\316r\271\340+_\3752w\356|BJ\211\207g\247l6k\326\353\r\233\365\026\001R\202\360\263\257\274\376\265\020\343#\000\252\006\272\266\343\227\276\362\313\034^~\202\357|\367M\376\371\237\376\205\037\374\340=N\317\a\326\331\011m\303`\316\303\002?>\037\370\321\371\212\017\316\267\374\360l$\026\347p\326\242*\270;\317=\377S\334\375\344\036}\327\3214\r!(M\333\320w=\261i\2101F\232\330\320v-A\225n\326\363\334\253/\363\346;\357\361\356\273\377C\030V,\273@h:tZ\261\264}\232\365@\311\202x\246\210\361\311\375\211\367Ys\266\236x\203\302o_\177\212\213\307{\\\271\374\004}\337QJ\341\354\354\234\365j\303\260\031\030\306\211a\263a\034Gb\2322}\337\023b\303\376\205=\236y\345%\376\354\317\377\202i\230\350TP\022aq\310b\377\2008\233\323FE\363\300\242k\350d\242\r\001\361\302\220\241\364\201`#\177\365\327\177\217\347\r\277\373;\277\305\323O=\301\227^{\225[\037|H\014\221\246\357\230\231\341\245Pr!\375\370.%gp\310\245`\030q\273\035(\305HGG\374\345\237\3741\245d\016\366\017h\202\023\003\304\0201w\306)1\235\rM\333\022=s6\024\376\366\037o\360\207\277\367\033\374\327\333\337\343\374\374\234\371r\306|1C^\371\342W\375\277\277\377-4DT\003M\337\323\267=M\323\022\2739q\266\317\362\370\210\343\223#\226\373K\242\266t@\257 b(\016\032q\011L\006\333\311X\r\211\363\011F\0037'Y&m\266\374\352\365\027\220\325\003\276{\363-\232Fq\034}\370\331\003\\\245\226\317\222\261\234)id\230\022S\3124\301\330o\nK\3330K+\304GRILV\030\2633\025a5\032\347\023l-PBC\333\367\354-Zf\255beb\332n\231\2065\337\274\3716O^y\022\304\231Rf\234&\342f\273F\375QC\214\245\211\011!2a)0l\326\234\236GD\214\261\024b\233\030\263\320\212\322w\r\247\233\011\327\206\020\033\306\"$s\314\nf`\226\260d\204iC\332\236s\357t\213\264\277@\210\201a\330bV\210\343\264\255\335\257\025\\\025\003(\011U\241$e\334\300\251\033\3238\321\315\006\346mKJ\205\256i8\025!\031\024\027V\233\221\355d\230\324y2\250\022\325\261\224(%\341yb\0326\334\276}\233\371\274c\273]c\356D\233\316\000\307\245N\257\352\245v\302\222v\263\"\270\025\362\270!\367=S\214\0243\332\256%g#\245\302\331fKNy\327\030\013\032\024\274>\333\250\214\343\000n\224\222x\357\235w\271pa\311\351\351)\030D/c-\204\273\376\336%\324~>Mu\230\360B\343-xf\353\231\355nr\031\307H\316\231\365zK)\231b\005\367\335\310.\273\026_\204\034\003\271\244G-\375\307w>bq\355\032\354\006\333\377\003\362y\254$M\364[\032\000\000\000\000IEND\256B`\202", 2488); 15 | _img_celestial_navigation = new wxBitmap(wxImage(sm)); 16 | } 17 | return; 18 | } 19 | -------------------------------------------------------------------------------- /src/astrolabe/dicts.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2000, 2001 William McClain 2 | 3 | This file is part of Astrolabe. 4 | 5 | Astrolabe is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | Astrolabe is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with Astrolabe; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* Some classes to provide string->enum and other mappings. */ 21 | 22 | #include "astrolabe.hpp" 23 | 24 | using std::string; 25 | using std::map; 26 | 27 | using astrolabe::vPlanets; 28 | using astrolabe::Coords; 29 | using astrolabe::util::int_to_string; 30 | 31 | // externally visible objects 32 | const astrolabe::dicts::StringToPlanet astrolabe::dicts::stringToPlanet; 33 | const astrolabe::dicts::StringToCoord astrolabe::dicts::stringToCoord; 34 | const astrolabe::dicts::MonthToString astrolabe::dicts::monthToString; 35 | const astrolabe::dicts::SeasonToString astrolabe::dicts::seasonToString; 36 | const astrolabe::dicts::PlanetToString astrolabe::dicts::planetToString; 37 | 38 | // 39 | // planet name -> vPlanets 40 | // 41 | astrolabe::dicts::StringToPlanet::StringToPlanet() { 42 | class Data { 43 | public: 44 | Data(const string &name, vPlanets planet) : name(name), planet(planet) {}; 45 | 46 | string name; 47 | vPlanets planet; 48 | }; 49 | /* 50 | const Data tbl[] = { 51 | {Data("Mercury", vMercury)}, 52 | {Data("Venus", vVenus)}, 53 | {Data("Earth", vEarth)}, 54 | {Data("Mars", vMars)}, 55 | {Data("Jupiter", vJupiter)}, 56 | {Data("Saturn", vSaturn)}, 57 | {Data("Uranus", vUranus)}, 58 | {Data("Neptune", vNeptune)} 59 | }; 60 | */ 61 | const Data tbl[] = { 62 | Data("Mercury", vMercury), 63 | Data("Venus", vVenus), 64 | Data("Earth", vEarth), 65 | Data("Mars", vMars), 66 | Data("Jupiter", vJupiter), 67 | Data("Saturn", vSaturn), 68 | Data("Uranus", vUranus), 69 | Data("Neptune", vNeptune) 70 | }; 71 | for (const Data *p = tbl; p != tbl + ARRAY_SIZE(tbl); p++) 72 | pmap[p->name] = p->planet; 73 | } 74 | 75 | const vPlanets &astrolabe::dicts::StringToPlanet::operator[](const string &name) const { 76 | std::map::const_iterator p = pmap.find(name); 77 | if (p == pmap.end()) 78 | throw Error("astrolabe::dicts::StringToPlanet::operator[]: unknown planet name = " + name); 79 | return p->second; 80 | } 81 | 82 | // 83 | // coordinate name -> Coords 84 | // 85 | astrolabe::dicts::StringToCoord::StringToCoord() { 86 | class Data { 87 | public: 88 | Data(const string &name, Coords coord) : name(name), coord(coord) {}; 89 | 90 | string name; 91 | Coords coord; 92 | }; 93 | 94 | const Data tbl[] = { 95 | Data("L", vL), 96 | Data("B", vB), 97 | Data("R", vR) 98 | }; 99 | for (const Data *p = tbl; p != tbl + ARRAY_SIZE(tbl); p++) 100 | pmap[p->name] = p->coord; 101 | } 102 | 103 | const Coords &astrolabe::dicts::StringToCoord::operator[](const string &name) const { 104 | std::map::const_iterator p = pmap.find(name); 105 | if (p == pmap.end()) 106 | throw Error("astrolabe::dicts::StringToCoord::operator[]: unknown coord name = " + name); 107 | return p->second; 108 | } 109 | 110 | // 111 | // integer -> month name string 112 | // 113 | // Month names. There must be twelve. The default is three-character 114 | // abbreviations so that listings line up. 115 | // 116 | astrolabe::dicts::MonthToString::MonthToString() { 117 | class Data { 118 | public: 119 | Data(int month, const string &name) : month(month), name(name) {}; 120 | 121 | int month; 122 | string name; 123 | }; 124 | 125 | const Data tbl[] = { 126 | Data(1, "jan"), 127 | Data(2, "feb"), 128 | Data(3, "mar"), 129 | Data(4, "apr"), 130 | Data(5, "may"), 131 | Data(6, "jun"), 132 | Data(7, "jul"), 133 | Data(8, "aug"), 134 | Data(9, "sep"), 135 | Data(10, "oct"), 136 | Data(11, "nov"), 137 | Data(12, "dec"), 138 | }; 139 | for (const Data *p = tbl; p != tbl + ARRAY_SIZE(tbl); p++) 140 | pmap[p->month] = p->name; 141 | } 142 | 143 | const string &astrolabe::dicts::MonthToString::operator[](int month) const { 144 | std::map::const_iterator p = pmap.find(month); 145 | if (p == pmap.end()) 146 | throw Error("astrolabe::dicts::MonthToString::operator[]: month number out of range = " + int_to_string(month)); 147 | return p->second; 148 | } 149 | 150 | // 151 | // Season -> season name string 152 | // 153 | // Month names. There must be twelve. The default is three-character 154 | // abbreviations so that listings line up. 155 | // 156 | astrolabe::dicts::SeasonToString::SeasonToString() { 157 | class Data { 158 | public: 159 | Data(Season season, const string &name) : season(season), name(name) {}; 160 | 161 | Season season; 162 | string name; 163 | }; 164 | 165 | const Data tbl[] = { 166 | Data(kSpring, "spring"), 167 | Data(kSummer, "summer"), 168 | Data(kAutumn, "autumn"), 169 | Data(kWinter, "winter") 170 | }; 171 | for (const Data *p = tbl; p != tbl + ARRAY_SIZE(tbl); p++) 172 | pmap[p->season] = p->name; 173 | } 174 | 175 | const string &astrolabe::dicts::SeasonToString::operator[](Season season) const { 176 | std::map::const_iterator p = pmap.find(season); 177 | if (p == pmap.end()) 178 | throw Error("astrolabe::dicts::SeasonToString::operator[]: season out of range = " + int_to_string(season)); 179 | return p->second; 180 | } 181 | 182 | // 183 | // vPlanets -> planet name string 184 | // 185 | astrolabe::dicts::PlanetToString::PlanetToString() { 186 | class Data { 187 | public: 188 | Data(vPlanets planet, const string &name) : planet(planet), name(name) {}; 189 | 190 | vPlanets planet; 191 | string name; 192 | }; 193 | 194 | const Data tbl[] = { 195 | Data(vMercury, "Mercury"), 196 | Data(vVenus, "Venus"), 197 | Data(vEarth, "Earth"), 198 | Data(vMars, "Mars"), 199 | Data(vJupiter, "Jupiter"), 200 | Data(vSaturn, "Saturn"), 201 | Data(vUranus, "Uranus"), 202 | Data(vNeptune, "Neptune") 203 | }; 204 | for (const Data *p = tbl; p != tbl + ARRAY_SIZE(tbl); p++) 205 | pmap[p->planet] = p->name; 206 | } 207 | 208 | const string &astrolabe::dicts::PlanetToString::operator[](vPlanets planet) const { 209 | std::map::const_iterator p = pmap.find(planet); 210 | if (p == pmap.end()) 211 | throw Error("astrolabe::dicts::PlanetToString::operator[]: planet out of range = " + int_to_string(planet)); 212 | return p->second; 213 | } 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /src/bzip2/huffman.c: -------------------------------------------------------------------------------- 1 | 2 | /*-------------------------------------------------------------*/ 3 | /*--- Huffman coding low-level stuff ---*/ 4 | /*--- huffman.c ---*/ 5 | /*-------------------------------------------------------------*/ 6 | 7 | /*-- 8 | This file is a part of bzip2 and/or libbzip2, a program and 9 | library for lossless, block-sorting data compression. 10 | 11 | Copyright (C) 1996-2002 Julian R Seward. All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions 15 | are met: 16 | 17 | 1. Redistributions of source code must retain the above copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 20 | 2. The origin of this software must not be misrepresented; you must 21 | not claim that you wrote the original software. If you use this 22 | software in a product, an acknowledgment in the product 23 | documentation would be appreciated but is not required. 24 | 25 | 3. Altered source versions must be plainly marked as such, and must 26 | not be misrepresented as being the original software. 27 | 28 | 4. The name of the author may not be used to endorse or promote 29 | products derived from this software without specific prior written 30 | permission. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 33 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 38 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Julian Seward, Cambridge, UK. 45 | jseward@acm.org 46 | bzip2/libbzip2 version 1.0 of 21 March 2000 47 | 48 | This program is based on (at least) the work of: 49 | Mike Burrows 50 | David Wheeler 51 | Peter Fenwick 52 | Alistair Moffat 53 | Radford Neal 54 | Ian H. Witten 55 | Robert Sedgewick 56 | Jon L. Bentley 57 | 58 | For more information on these sources, see the manual. 59 | --*/ 60 | 61 | 62 | #include "bzlib_private.h" 63 | 64 | /*---------------------------------------------------*/ 65 | #define WEIGHTOF(zz0) ((zz0) & 0xffffff00) 66 | #define DEPTHOF(zz1) ((zz1) & 0x000000ff) 67 | #define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3)) 68 | 69 | #define ADDWEIGHTS(zw1,zw2) \ 70 | (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \ 71 | (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2))) 72 | 73 | #define UPHEAP(z) \ 74 | { \ 75 | Int32 zz, tmp; \ 76 | zz = z; tmp = heap[zz]; \ 77 | while (weight[tmp] < weight[heap[zz >> 1]]) { \ 78 | heap[zz] = heap[zz >> 1]; \ 79 | zz >>= 1; \ 80 | } \ 81 | heap[zz] = tmp; \ 82 | } 83 | 84 | #define DOWNHEAP(z) \ 85 | { \ 86 | Int32 zz, yy, tmp; \ 87 | zz = z; tmp = heap[zz]; \ 88 | while (True) { \ 89 | yy = zz << 1; \ 90 | if (yy > nHeap) break; \ 91 | if (yy < nHeap && \ 92 | weight[heap[yy+1]] < weight[heap[yy]]) \ 93 | yy++; \ 94 | if (weight[tmp] < weight[heap[yy]]) break; \ 95 | heap[zz] = heap[yy]; \ 96 | zz = yy; \ 97 | } \ 98 | heap[zz] = tmp; \ 99 | } 100 | 101 | 102 | /*---------------------------------------------------*/ 103 | void BZ2_hbMakeCodeLengths ( UChar *len, 104 | Int32 *freq, 105 | Int32 alphaSize, 106 | Int32 maxLen ) 107 | { 108 | /*-- 109 | Nodes and heap entries run from 1. Entry 0 110 | for both the heap and nodes is a sentinel. 111 | --*/ 112 | Int32 nNodes, nHeap, n1, n2, i, j, k; 113 | Bool tooLong; 114 | 115 | Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; 116 | Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; 117 | Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; 118 | 119 | for (i = 0; i < alphaSize; i++) 120 | weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; 121 | 122 | while (True) { 123 | 124 | nNodes = alphaSize; 125 | nHeap = 0; 126 | 127 | heap[0] = 0; 128 | weight[0] = 0; 129 | parent[0] = -2; 130 | 131 | for (i = 1; i <= alphaSize; i++) { 132 | parent[i] = -1; 133 | nHeap++; 134 | heap[nHeap] = i; 135 | UPHEAP(nHeap); 136 | } 137 | 138 | AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); 139 | 140 | while (nHeap > 1) { 141 | n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); 142 | n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); 143 | nNodes++; 144 | parent[n1] = parent[n2] = nNodes; 145 | weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]); 146 | parent[nNodes] = -1; 147 | nHeap++; 148 | heap[nHeap] = nNodes; 149 | UPHEAP(nHeap); 150 | } 151 | 152 | AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 ); 153 | 154 | tooLong = False; 155 | for (i = 1; i <= alphaSize; i++) { 156 | j = 0; 157 | k = i; 158 | while (parent[k] >= 0) { k = parent[k]; j++; } 159 | len[i-1] = j; 160 | if (j > maxLen) tooLong = True; 161 | } 162 | 163 | if (! tooLong) break; 164 | 165 | for (i = 1; i < alphaSize; i++) { 166 | j = weight[i] >> 8; 167 | j = 1 + (j / 2); 168 | weight[i] = j << 8; 169 | } 170 | } 171 | } 172 | 173 | 174 | /*---------------------------------------------------*/ 175 | void BZ2_hbAssignCodes ( Int32 *code, 176 | UChar *length, 177 | Int32 minLen, 178 | Int32 maxLen, 179 | Int32 alphaSize ) 180 | { 181 | Int32 n, vec, i; 182 | 183 | vec = 0; 184 | for (n = minLen; n <= maxLen; n++) { 185 | for (i = 0; i < alphaSize; i++) 186 | if (length[i] == n) { code[i] = vec; vec++; }; 187 | vec <<= 1; 188 | } 189 | } 190 | 191 | 192 | /*---------------------------------------------------*/ 193 | void BZ2_hbCreateDecodeTables ( Int32 *limit, 194 | Int32 *base, 195 | Int32 *perm, 196 | UChar *length, 197 | Int32 minLen, 198 | Int32 maxLen, 199 | Int32 alphaSize ) 200 | { 201 | Int32 pp, i, j, vec; 202 | 203 | pp = 0; 204 | for (i = minLen; i <= maxLen; i++) 205 | for (j = 0; j < alphaSize; j++) 206 | if (length[j] == i) { perm[pp] = j; pp++; }; 207 | 208 | for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0; 209 | for (i = 0; i < alphaSize; i++) base[length[i]+1]++; 210 | 211 | for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1]; 212 | 213 | for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0; 214 | vec = 0; 215 | 216 | for (i = minLen; i <= maxLen; i++) { 217 | vec += (base[i+1] - base[i]); 218 | limit[i] = vec-1; 219 | vec <<= 1; 220 | } 221 | for (i = minLen + 1; i <= maxLen; i++) 222 | base[i] = ((limit[i-1] + 1) << 1) - base[i]; 223 | } 224 | 225 | 226 | /*-------------------------------------------------------------*/ 227 | /*--- end huffman.c ---*/ 228 | /*-------------------------------------------------------------*/ 229 | -------------------------------------------------------------------------------- /src/zuFile.cpp: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | zyGrib: meteorological GRIB file viewer 3 | Copyright (C) 2008 - Jacques Zaninetti - http://www.zygrib.org 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***********************************************************************/ 18 | 19 | #include "zuFile.h" 20 | 21 | //---------------------------------------------------- 22 | int zu_can_read_file(const char *fname) 23 | { 24 | ZUFILE *f; 25 | f = zu_open(fname, "rb"); 26 | if (f == NULL) { 27 | return 0; 28 | } 29 | else { 30 | zu_close(f); 31 | return 1; 32 | } 33 | } 34 | 35 | //---------------------------------------------------- 36 | ZUFILE * zu_open(const char *fname, const char *mode, int type) 37 | { 38 | ZUFILE *f; 39 | char buf[16]; 40 | if (!fname || strlen(fname)==0) { 41 | return NULL; 42 | } 43 | f = (ZUFILE *) malloc(sizeof(ZUFILE)); 44 | if (!f) { 45 | return NULL; 46 | } 47 | 48 | f->ok = 1; 49 | f->pos = 0; 50 | f->fname = strdup(fname); 51 | 52 | if (type == ZU_COMPRESS_AUTO) 53 | { 54 | char *p = strrchr(f->fname, '.'); 55 | int i=0; 56 | while (p!=NULL && *p !='\0' && i<4) { 57 | buf[i] = tolower(*p); 58 | i++; 59 | p++; 60 | } 61 | buf[i] = '\0'; 62 | if (!strcmp(buf, ".gz")) { 63 | f->type = ZU_COMPRESS_GZIP; 64 | //fprintf(stderr,"ZU_COMPRESS_GZIP\n"); 65 | } 66 | #ifndef __ANDROID__ 67 | else if (!strcmp(buf, ".bz2") || !strcmp(buf, ".bz")) { 68 | f->type = ZU_COMPRESS_BZIP; 69 | //fprintf(stderr,"ZU_COMPRESS_BZIP\n"); 70 | } 71 | #endif 72 | else { 73 | f->type = ZU_COMPRESS_NONE; 74 | //fprintf(stderr,"ZU_COMPRESS_NONE\n"); 75 | } 76 | } 77 | else 78 | { 79 | f->type = type; 80 | } 81 | 82 | switch(f->type) { 83 | case ZU_COMPRESS_NONE : 84 | f->zfile = (void *) fopen(f->fname, mode); 85 | break; 86 | case ZU_COMPRESS_GZIP : 87 | f->zfile = (void *) gzopen(f->fname, mode); 88 | break; 89 | #ifndef __ANDROID__ 90 | case ZU_COMPRESS_BZIP : 91 | f->faux = fopen(f->fname, mode); 92 | if (f->faux) { 93 | int bzerror=BZ_OK; 94 | f->zfile = (void *) BZ2_bzReadOpen(&bzerror,f->faux,0,0,NULL,0); 95 | if (bzerror != BZ_OK) { 96 | BZ2_bzReadClose (&bzerror,(BZFILE*)(f->zfile)); 97 | fclose(f->faux); 98 | f->zfile = NULL; 99 | } 100 | } else { 101 | f->zfile = NULL; 102 | } 103 | break; 104 | #endif 105 | default : 106 | f->zfile = NULL; 107 | } 108 | 109 | if (f->zfile == NULL) { 110 | free(f); 111 | f = NULL; 112 | } 113 | 114 | return f; 115 | } 116 | //---------------------------------------------------- 117 | int zu_read(ZUFILE *f, void *buf, long len) 118 | { 119 | int nb = 0; 120 | int bzerror=BZ_OK; 121 | switch(f->type) { 122 | case ZU_COMPRESS_NONE : 123 | nb = fread(buf, 1, len, (FILE*)(f->zfile)); 124 | break; 125 | case ZU_COMPRESS_GZIP : 126 | nb = gzread((gzFile)(f->zfile), buf, len); 127 | break; 128 | #ifndef __ANDROID__ 129 | case ZU_COMPRESS_BZIP : 130 | nb = BZ2_bzRead(&bzerror,(BZFILE*)(f->zfile), buf, len); 131 | break; 132 | #endif 133 | } 134 | f->pos += nb; 135 | return nb; 136 | } 137 | 138 | //---------------------------------------------------- 139 | int zu_close(ZUFILE *f) 140 | { 141 | int bzerror=BZ_OK; 142 | if (f) { 143 | f->ok = 0; 144 | f->pos = 0; 145 | free(f->fname); 146 | if (f->zfile) { 147 | switch(f->type) { 148 | case ZU_COMPRESS_NONE : 149 | fclose((FILE*)(f->zfile)); 150 | break; 151 | case ZU_COMPRESS_GZIP : 152 | gzclose((gzFile)(f->zfile)); 153 | break; 154 | #ifndef __ANDROID__ 155 | case ZU_COMPRESS_BZIP : 156 | BZ2_bzReadClose (&bzerror,(BZFILE*)(f->zfile)); 157 | if (f->faux) { 158 | fclose(f->faux); 159 | } 160 | break; 161 | #endif 162 | } 163 | } 164 | free(f); 165 | } 166 | return 0; 167 | } 168 | 169 | 170 | 171 | //---------------------------------------------------- 172 | long zu_tell(ZUFILE *f) 173 | { 174 | return f->pos; 175 | } 176 | 177 | //---------------------------------------------------- 178 | long zu_filesize(ZUFILE *f) 179 | { 180 | long res = 0; 181 | FILE *ftmp = fopen(f->fname, "rb"); 182 | if (ftmp) 183 | { 184 | fseek(ftmp, 0, SEEK_END); 185 | res = ftell(ftmp); 186 | fclose(ftmp); 187 | } 188 | return res; 189 | } 190 | 191 | //---------------------------------------------------- 192 | int zu_seek(ZUFILE *f, long offset, int whence) 193 | { 194 | int res = 0; 195 | int bzerror=BZ_OK; 196 | if (whence == SEEK_END) { 197 | return -1; // TODO 198 | } 199 | 200 | switch(f->type) { //SEEK_SET, SEEK_CUR 201 | case ZU_COMPRESS_NONE : 202 | res = fseek((FILE*)(f->zfile), offset, whence); 203 | f->pos = ftell((FILE*)(f->zfile)); 204 | break; 205 | case ZU_COMPRESS_GZIP : 206 | if (whence == SEEK_SET) { 207 | res = gzseek((gzFile)(f->zfile), offset, whence); 208 | } 209 | else { // !!! BUG with SEEK_CUR in ZLIB !!! 210 | int p1 = gztell((gzFile)(f->zfile)); 211 | res = gzseek((gzFile)(f->zfile), p1+offset, SEEK_SET); 212 | } 213 | f->pos = gztell((gzFile)(f->zfile)); 214 | if (res >= 0) 215 | res = 0; 216 | break; 217 | #ifndef __ANDROID__ 218 | case ZU_COMPRESS_BZIP : 219 | if (whence==SEEK_SET && offset >= f->pos) { 220 | res = zu_bzSeekForward(f, offset-f->pos); 221 | } 222 | else if (whence==SEEK_CUR) { 223 | res = zu_bzSeekForward(f, offset); 224 | } 225 | else { // BAD : reopen file 226 | BZ2_bzReadClose (&bzerror,(BZFILE*)(f->zfile)); 227 | bzerror=BZ_OK; 228 | rewind(f->faux); 229 | f->pos = 0; 230 | f->zfile = (void *) BZ2_bzReadOpen(&bzerror,f->faux,0,0,NULL,0); 231 | if (bzerror != BZ_OK) { 232 | BZ2_bzReadClose (&bzerror,(BZFILE*)(f->zfile)); 233 | fclose(f->faux); 234 | f->zfile = NULL; 235 | f->ok = 0; 236 | } 237 | res = zu_bzSeekForward(f, offset); 238 | } 239 | break; 240 | #endif 241 | } 242 | return res; 243 | } 244 | 245 | #ifndef __ANDROID__ 246 | //----------------------------------------------------------------- 247 | int zu_bzSeekForward(ZUFILE *f, unsigned long nbytes_) 248 | // for internal use 249 | { 250 | unsigned long nbytes = nbytes_; 251 | char buf[ZU_BUFREADSIZE]; 252 | unsigned long nbread = 0; 253 | int nb; 254 | int bzerror=BZ_OK; 255 | while (bzerror==BZ_OK && nbytes>=ZU_BUFREADSIZE) { 256 | nb = BZ2_bzRead(&bzerror,(BZFILE*)(f->zfile), buf, ZU_BUFREADSIZE); 257 | nbytes -= nb; 258 | nbread += nb; 259 | } 260 | if (bzerror==BZ_OK && nbytes>0) { 261 | nb = BZ2_bzRead(&bzerror,(BZFILE*)(f->zfile), buf, nbytes); 262 | nbread += nb; 263 | } 264 | f->pos += nbread; 265 | 266 | return nbread==nbytes_ ? 0 : -1; 267 | } 268 | #endif 269 | //----------------------------------------------------------------- 270 | void zu_rewind(ZUFILE *f) 271 | { 272 | zu_seek(f, 0, SEEK_SET); 273 | } 274 | 275 | 276 | -------------------------------------------------------------------------------- /data/IGRF11.COF: -------------------------------------------------------------------------------- 1 | IGRF2010 2010.00 13 8 0 2010.00 2015.00 -1.0 600.0 IGRF2010 0 2 | 1 0 -29496.50 0.00 11.40 0.00 IGRF2010 1 3 | 1 1 -1585.90 4945.10 16.70 -28.80 IGRF2010 2 4 | 2 0 -2396.60 0.00 -11.30 0.00 IGRF2010 3 5 | 2 1 3026.00 -2707.70 -3.90 -23.00 IGRF2010 4 6 | 2 2 1668.60 -575.40 2.70 -12.90 IGRF2010 5 7 | 3 0 1339.70 0.00 1.30 0.00 IGRF2010 6 8 | 3 1 -2326.30 -160.50 -3.90 8.60 IGRF2010 7 9 | 3 2 1231.70 251.70 -2.90 -2.90 IGRF2010 8 10 | 3 3 634.20 -536.80 -8.10 -2.10 IGRF2010 9 11 | 4 0 912.60 0.00 -1.40 0.00 IGRF2010 10 12 | 4 1 809.00 286.40 2.00 0.40 IGRF2010 11 13 | 4 2 166.60 -211.20 -8.90 3.20 IGRF2010 12 14 | 4 3 -357.10 164.40 4.40 3.60 IGRF2010 13 15 | 4 4 89.70 -309.20 -2.30 -0.80 IGRF2010 14 16 | 5 0 -231.10 0.00 -0.50 0.00 IGRF2010 15 17 | 5 1 357.20 44.70 0.50 0.50 IGRF2010 16 18 | 5 2 200.30 188.90 -1.50 1.50 IGRF2010 17 19 | 5 3 -141.20 -118.10 -0.70 0.90 IGRF2010 18 20 | 5 4 -163.10 0.10 1.30 3.70 IGRF2010 19 21 | 5 5 -7.70 100.90 1.40 -0.60 IGRF2010 20 22 | 6 0 72.80 0.00 -0.30 0.00 IGRF2010 21 23 | 6 1 68.60 -20.80 -0.30 -0.10 IGRF2010 22 24 | 6 2 76.00 44.20 -0.30 -2.10 IGRF2010 23 25 | 6 3 -141.40 61.50 1.90 -0.40 IGRF2010 24 26 | 6 4 -22.90 -66.30 -1.60 -0.50 IGRF2010 25 27 | 6 5 13.10 3.10 -0.20 0.80 IGRF2010 26 28 | 6 6 -77.90 54.90 1.80 0.50 IGRF2010 27 29 | 7 0 80.40 0.00 0.20 0.00 IGRF2010 28 30 | 7 1 -75.00 -57.80 -0.10 0.60 IGRF2010 29 31 | 7 2 -4.70 -21.20 -0.60 0.30 IGRF2010 30 32 | 7 3 45.30 6.60 1.40 -0.20 IGRF2010 31 33 | 7 4 14.00 24.90 0.30 -0.10 IGRF2010 32 34 | 7 5 10.40 7.00 0.10 -0.80 IGRF2010 33 35 | 7 6 1.60 -27.70 -0.80 -0.30 IGRF2010 34 36 | 7 7 4.90 -3.40 0.40 0.20 IGRF2010 35 37 | 8 0 24.30 0.00 -0.10 0.00 IGRF2010 36 38 | 8 1 8.20 10.90 0.10 0.00 IGRF2010 37 39 | 8 2 -14.50 -20.00 -0.50 0.20 IGRF2010 38 40 | 8 3 -5.70 11.90 0.30 0.50 IGRF2010 39 41 | 8 4 -19.30 -17.40 -0.30 0.40 IGRF2010 40 42 | 8 5 11.60 16.70 0.30 0.10 IGRF2010 41 43 | 8 6 10.90 7.10 0.20 -0.10 IGRF2010 42 44 | 8 7 -14.10 -10.80 -0.50 0.40 IGRF2010 43 45 | 8 8 -3.70 1.70 0.20 0.40 IGRF2010 44 46 | 9 0 5.40 0.00 0.00 0.00 IGRF2010 45 47 | 9 1 9.40 -20.50 0.00 0.00 IGRF2010 46 48 | 9 2 3.40 11.60 0.00 0.00 IGRF2010 47 49 | 9 3 -5.30 12.80 0.00 0.00 IGRF2010 48 50 | 9 4 3.10 -7.20 0.00 0.00 IGRF2010 49 51 | 9 5 -12.40 -7.40 0.00 0.00 IGRF2010 50 52 | 9 6 -0.80 8.00 0.00 0.00 IGRF2010 51 53 | 9 7 8.40 2.20 0.00 0.00 IGRF2010 52 54 | 9 8 -8.40 -6.10 0.00 0.00 IGRF2010 53 55 | 9 9 -10.10 7.00 0.00 0.00 IGRF2010 54 56 | 10 0 -2.00 0.00 0.00 0.00 IGRF2010 55 57 | 10 1 -6.30 2.80 0.00 0.00 IGRF2010 56 58 | 10 2 0.90 -0.10 0.00 0.00 IGRF2010 57 59 | 10 3 -1.10 4.70 0.00 0.00 IGRF2010 58 60 | 10 4 -0.20 4.40 0.00 0.00 IGRF2010 59 61 | 10 5 2.50 -7.20 0.00 0.00 IGRF2010 60 62 | 10 6 -0.30 -1.00 0.00 0.00 IGRF2010 61 63 | 10 7 2.20 -4.00 0.00 0.00 IGRF2010 62 64 | 10 8 3.10 -2.00 0.00 0.00 IGRF2010 63 65 | 10 9 -1.00 -2.00 0.00 0.00 IGRF2010 64 66 | 10 10 -2.80 -8.30 0.00 0.00 IGRF2010 65 67 | 11 0 3.00 0.00 0.00 0.00 IGRF2010 66 68 | 11 1 -1.50 0.10 0.00 0.00 IGRF2010 67 69 | 11 2 -2.10 1.70 0.00 0.00 IGRF2010 68 70 | 11 3 1.60 -0.60 0.00 0.00 IGRF2010 69 71 | 11 4 -0.50 -1.80 0.00 0.00 IGRF2010 70 72 | 11 5 0.50 0.90 0.00 0.00 IGRF2010 71 73 | 11 6 -0.80 -0.40 0.00 0.00 IGRF2010 72 74 | 11 7 0.40 -2.50 0.00 0.00 IGRF2010 73 75 | 11 8 1.80 -1.30 0.00 0.00 IGRF2010 74 76 | 11 9 0.20 -2.10 0.00 0.00 IGRF2010 75 77 | 11 10 0.80 -1.90 0.00 0.00 IGRF2010 76 78 | 11 11 3.80 -1.80 0.00 0.00 IGRF2010 77 79 | 12 0 -2.10 0.00 0.00 0.00 IGRF2010 78 80 | 12 1 -0.20 -0.80 0.00 0.00 IGRF2010 79 81 | 12 2 0.30 0.30 0.00 0.00 IGRF2010 80 82 | 12 3 1.00 2.20 0.00 0.00 IGRF2010 81 83 | 12 4 -0.70 -2.50 0.00 0.00 IGRF2010 82 84 | 12 5 0.90 0.50 0.00 0.00 IGRF2010 83 85 | 12 6 -0.10 0.60 0.00 0.00 IGRF2010 84 86 | 12 7 0.50 0.00 0.00 0.00 IGRF2010 85 87 | 12 8 -0.40 0.10 0.00 0.00 IGRF2010 86 88 | 12 9 -0.40 0.30 0.00 0.00 IGRF2010 87 89 | 12 10 0.20 -0.90 0.00 0.00 IGRF2010 88 90 | 12 11 -0.80 -0.20 0.00 0.00 IGRF2010 89 91 | 12 12 0.00 0.80 0.00 0.00 IGRF2010 90 92 | 13 0 -0.20 0.00 0.00 0.00 IGRF2010 91 93 | 13 1 -0.90 -0.80 0.00 0.00 IGRF2010 92 94 | 13 2 0.30 0.30 0.00 0.00 IGRF2010 93 95 | 13 3 0.40 1.70 0.00 0.00 IGRF2010 94 96 | 13 4 -0.40 -0.60 0.00 0.00 IGRF2010 95 97 | 13 5 1.10 -1.20 0.00 0.00 IGRF2010 96 98 | 13 6 -0.30 -0.10 0.00 0.00 IGRF2010 97 99 | 13 7 0.80 0.50 0.00 0.00 IGRF2010 98 100 | 13 8 -0.20 0.10 0.00 0.00 IGRF2010 99 101 | 13 9 0.40 0.50 0.00 0.00 IGRF2010 100 102 | 13 10 0.00 0.40 0.00 0.00 IGRF2010 101 103 | 13 11 0.40 -0.20 0.00 0.00 IGRF2010 102 104 | 13 12 -0.30 -0.50 0.00 0.00 IGRF2010 103 105 | 13 13 -0.30 -0.80 0.00 0.00 IGRF2010 104 106 | -------------------------------------------------------------------------------- /src/bzip2/bzlib.h: -------------------------------------------------------------------------------- 1 | 2 | /*-------------------------------------------------------------*/ 3 | /*--- Public header file for the library. ---*/ 4 | /*--- bzlib.h ---*/ 5 | /*-------------------------------------------------------------*/ 6 | 7 | /*-- 8 | This file is a part of bzip2 and/or libbzip2, a program and 9 | library for lossless, block-sorting data compression. 10 | 11 | Copyright (C) 1996-2002 Julian R Seward. All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions 15 | are met: 16 | 17 | 1. Redistributions of source code must retain the above copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 20 | 2. The origin of this software must not be misrepresented; you must 21 | not claim that you wrote the original software. If you use this 22 | software in a product, an acknowledgment in the product 23 | documentation would be appreciated but is not required. 24 | 25 | 3. Altered source versions must be plainly marked as such, and must 26 | not be misrepresented as being the original software. 27 | 28 | 4. The name of the author may not be used to endorse or promote 29 | products derived from this software without specific prior written 30 | permission. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 33 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 36 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 38 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 40 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Julian Seward, Cambridge, UK. 45 | jseward@acm.org 46 | bzip2/libbzip2 version 1.0 of 21 March 2000 47 | 48 | This program is based on (at least) the work of: 49 | Mike Burrows 50 | David Wheeler 51 | Peter Fenwick 52 | Alistair Moffat 53 | Radford Neal 54 | Ian H. Witten 55 | Robert Sedgewick 56 | Jon L. Bentley 57 | 58 | For more information on these sources, see the manual. 59 | --*/ 60 | 61 | 62 | #ifndef _BZLIB_H 63 | #define _BZLIB_H 64 | 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | #define BZ_RUN 0 70 | #define BZ_FLUSH 1 71 | #define BZ_FINISH 2 72 | 73 | #define BZ_OK 0 74 | #define BZ_RUN_OK 1 75 | #define BZ_FLUSH_OK 2 76 | #define BZ_FINISH_OK 3 77 | #define BZ_STREAM_END 4 78 | #define BZ_SEQUENCE_ERROR (-1) 79 | #define BZ_PARAM_ERROR (-2) 80 | #define BZ_MEM_ERROR (-3) 81 | #define BZ_DATA_ERROR (-4) 82 | #define BZ_DATA_ERROR_MAGIC (-5) 83 | #define BZ_IO_ERROR (-6) 84 | #define BZ_UNEXPECTED_EOF (-7) 85 | #define BZ_OUTBUFF_FULL (-8) 86 | #define BZ_CONFIG_ERROR (-9) 87 | 88 | typedef 89 | struct { 90 | char *next_in; 91 | unsigned int avail_in; 92 | unsigned int total_in_lo32; 93 | unsigned int total_in_hi32; 94 | 95 | char *next_out; 96 | unsigned int avail_out; 97 | unsigned int total_out_lo32; 98 | unsigned int total_out_hi32; 99 | 100 | void *state; 101 | 102 | void *(*bzalloc)(void *,int,int); 103 | void (*bzfree)(void *,void *); 104 | void *opaque; 105 | } 106 | bz_stream; 107 | 108 | 109 | #ifndef BZ_IMPORT 110 | #define BZ_EXPORT 111 | #endif 112 | 113 | /* Need a definitition for FILE */ 114 | #include 115 | 116 | #ifdef _WIN32 117 | # include 118 | # ifdef small 119 | /* windows.h define small to char */ 120 | # undef small 121 | # endif 122 | # ifdef BZ_EXPORT 123 | # define BZ_API(func) WINAPI func 124 | # define BZ_EXTERN extern 125 | # else 126 | /* import windows dll dynamically */ 127 | # define BZ_API(func) (WINAPI * func) 128 | # define BZ_EXTERN 129 | # endif 130 | #else 131 | # define BZ_API(func) func 132 | # define BZ_EXTERN extern 133 | #endif 134 | 135 | 136 | /*-- Core (low-level) library functions --*/ 137 | 138 | BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( 139 | bz_stream* strm, 140 | int blockSize100k, 141 | int verbosity, 142 | int workFactor 143 | ); 144 | 145 | BZ_EXTERN int BZ_API(BZ2_bzCompress) ( 146 | bz_stream* strm, 147 | int action 148 | ); 149 | 150 | BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( 151 | bz_stream* strm 152 | ); 153 | 154 | BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( 155 | bz_stream *strm, 156 | int verbosity, 157 | int small 158 | ); 159 | 160 | BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( 161 | bz_stream* strm 162 | ); 163 | 164 | BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( 165 | bz_stream *strm 166 | ); 167 | 168 | 169 | 170 | /*-- High(er) level library functions --*/ 171 | 172 | #ifndef BZ_NO_STDIO 173 | #define BZ_MAX_UNUSED 5000 174 | 175 | typedef void BZFILE; 176 | 177 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( 178 | int* bzerror, 179 | FILE* f, 180 | int verbosity, 181 | int small, 182 | void* unused, 183 | int nUnused 184 | ); 185 | 186 | BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( 187 | int* bzerror, 188 | BZFILE* b 189 | ); 190 | 191 | BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( 192 | int* bzerror, 193 | BZFILE* b, 194 | void** unused, 195 | int* nUnused 196 | ); 197 | 198 | BZ_EXTERN int BZ_API(BZ2_bzRead) ( 199 | int* bzerror, 200 | BZFILE* b, 201 | void* buf, 202 | int len 203 | ); 204 | 205 | BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( 206 | int* bzerror, 207 | FILE* f, 208 | int blockSize100k, 209 | int verbosity, 210 | int workFactor 211 | ); 212 | 213 | BZ_EXTERN void BZ_API(BZ2_bzWrite) ( 214 | int* bzerror, 215 | BZFILE* b, 216 | void* buf, 217 | int len 218 | ); 219 | 220 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( 221 | int* bzerror, 222 | BZFILE* b, 223 | int abandon, 224 | unsigned int* nbytes_in, 225 | unsigned int* nbytes_out 226 | ); 227 | 228 | BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( 229 | int* bzerror, 230 | BZFILE* b, 231 | int abandon, 232 | unsigned int* nbytes_in_lo32, 233 | unsigned int* nbytes_in_hi32, 234 | unsigned int* nbytes_out_lo32, 235 | unsigned int* nbytes_out_hi32 236 | ); 237 | #endif 238 | 239 | 240 | /*-- Utility functions --*/ 241 | 242 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( 243 | char* dest, 244 | unsigned int* destLen, 245 | char* source, 246 | unsigned int sourceLen, 247 | int blockSize100k, 248 | int verbosity, 249 | int workFactor 250 | ); 251 | 252 | BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( 253 | char* dest, 254 | unsigned int* destLen, 255 | char* source, 256 | unsigned int sourceLen, 257 | int small, 258 | int verbosity 259 | ); 260 | 261 | 262 | /*-- 263 | Code contributed by Yoshioka Tsuneo 264 | (QWF00133@niftyserve.or.jp/tsuneo-y@is.aist-nara.ac.jp), 265 | to support better zlib compatibility. 266 | This code is not _officially_ part of libbzip2 (yet); 267 | I haven't tested it, documented it, or considered the 268 | threading-safeness of it. 269 | If this code breaks, please contact both Yoshioka and me. 270 | --*/ 271 | 272 | BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( 273 | void 274 | ); 275 | 276 | #ifndef BZ_NO_STDIO 277 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( 278 | const char *path, 279 | const char *mode 280 | ); 281 | 282 | BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( 283 | int fd, 284 | const char *mode 285 | ); 286 | 287 | BZ_EXTERN int BZ_API(BZ2_bzread) ( 288 | BZFILE* b, 289 | void* buf, 290 | int len 291 | ); 292 | 293 | BZ_EXTERN int BZ_API(BZ2_bzwrite) ( 294 | BZFILE* b, 295 | void* buf, 296 | int len 297 | ); 298 | 299 | BZ_EXTERN int BZ_API(BZ2_bzflush) ( 300 | BZFILE* b 301 | ); 302 | 303 | BZ_EXTERN void BZ_API(BZ2_bzclose) ( 304 | BZFILE* b 305 | ); 306 | 307 | BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( 308 | BZFILE *b, 309 | int *errnum 310 | ); 311 | #endif 312 | 313 | #ifdef __cplusplus 314 | } 315 | #endif 316 | 317 | #endif 318 | 319 | /*-------------------------------------------------------------*/ 320 | /*--- end bzlib.h ---*/ 321 | /*-------------------------------------------------------------*/ 322 | -------------------------------------------------------------------------------- /src/astrolabe/riseset.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2000, 2001 William McClain 2 | 3 | This file is part of Astrolabe. 4 | 5 | Astrolabe is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | Astrolabe is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with Astrolabe; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | /* Compute Rise, Set, and Transit times. 21 | 22 | Each of the routines requires three equatorial coordinates for the 23 | object: yesterday, today and tomorrow, all at 0hr UT. 24 | 25 | This approach is inadequate for the Moon, which moves too fast to 26 | be accurately interpolated from three daily positions. 27 | 28 | Bug: each of the routines drops some events which occur near 0hr UT. 29 | 30 | */ 31 | 32 | #include 33 | #include "astrolabe.hpp" 34 | 35 | using std::vector; 36 | 37 | using astrolabe::Error; 38 | using astrolabe::calendar::sidereal_time_greenwich; 39 | using astrolabe::constants::earth_equ_radius; 40 | using astrolabe::constants::standard_rst_altitude; 41 | using astrolabe::constants::pi2; 42 | using astrolabe::constants::seconds_per_day; 43 | using astrolabe::dynamical::deltaT_seconds; 44 | using astrolabe::util::d_to_r; 45 | using astrolabe::util::diff_angle; 46 | using astrolabe::util::equ_to_horiz; 47 | using astrolabe::util::interpolate3; 48 | using astrolabe::util::interpolate_angle3; 49 | using astrolabe::util::modpi2; 50 | 51 | namespace { 52 | const double _k1 = d_to_r(360.985647); 53 | }; 54 | 55 | double astrolabe::riseset::rise(double jd, const vector &raList, const vector &decList, double h0, double delta) { 56 | /* Return the Julian Day of the rise time of an object. 57 | 58 | Parameters: 59 | jd : Julian Day number of the day in question, at 0 hr UT 60 | raList : a sequence of three right accension values, in radians, 61 | for (jd-1, jd, jd+1) 62 | decList : a sequence of three right declination values, in radians, 63 | for (jd-1, jd, jd+1) 64 | h0 : the standard altitude in radians 65 | delta : desired accuracy in days. Times less than one minute are 66 | infeasible for rise times because of atmospheric refraction. 67 | 68 | Returns: 69 | Julian Day of the rise time 70 | 71 | */ 72 | const double THETA0 = sidereal_time_greenwich(jd); 73 | const double deltaT_days = deltaT_seconds(jd) / seconds_per_day; 74 | 75 | const double cosH0 = (sin(h0) - sin(astrolabe::globals::latitude) * sin(decList[1])) / (cos(astrolabe::globals::latitude) * cos(decList[1])); 76 | // 77 | // future: return some indicator when the object is circumpolar or always 78 | // below the horizon. 79 | // 80 | if (cosH0 < -1.0) // circumpolar 81 | return -1.0; 82 | if (cosH0 > 1.0) // never rises 83 | return -1.0; 84 | 85 | const double H0 = acos(cosH0); 86 | double m0 = (raList[1] + astrolabe::globals::longitude - THETA0) / pi2; 87 | double m = m0 - H0 / pi2; // this is the only difference between rise() and set() 88 | if (m < 0) 89 | m += 1; 90 | else if (m > 1) 91 | m -= 1; 92 | if (m < 0 || m > 1) 93 | throw Error("astrolabe::riseset::rise: m is out of range"); 94 | for (int i = 0; i < 20; i++) { 95 | m0 = m; 96 | const double theta0 = modpi2(THETA0 + _k1 * m); 97 | const double n = m + deltaT_days; 98 | if (n < -1 || n > 1) 99 | return -1.0; // Bug: this is where we drop some events 100 | const double ra = interpolate_angle3(n, raList); 101 | const double dec = interpolate3(n, decList); 102 | double H = theta0 - astrolabe::globals::longitude - ra; 103 | H = diff_angle(0.0, H); 104 | double A, h; 105 | equ_to_horiz(H, dec, A, h); 106 | const double dm = (h - h0) / (pi2 * cos(dec) * cos(astrolabe::globals::latitude) * sin(H)); 107 | m += dm; 108 | if (fabs(m - m0) < delta) 109 | return jd + m; 110 | } 111 | 112 | throw Error("astrolabe::riseset::rise: bailout"); 113 | } 114 | 115 | double astrolabe::riseset::set(double jd, const vector &raList, const vector &decList, double h0, double delta) { 116 | /* Return the Julian Day of the set time of an object. 117 | 118 | Parameters: 119 | jd : Julian Day number of the day in question, at 0 hr UT 120 | raList : a sequence of three right accension values, in radians, 121 | for (jd-1, jd, jd+1) 122 | decList : a sequence of three right declination values, in radians, 123 | for (jd-1, jd, jd+1) 124 | h0 : the standard altitude in radians 125 | delta : desired accuracy in days. Times less than one minute are 126 | infeasible for set times because of atmospheric refraction. 127 | 128 | Returns: 129 | Julian Day of the set time 130 | 131 | */ 132 | const double THETA0 = sidereal_time_greenwich(jd); 133 | const double deltaT_days = deltaT_seconds(jd) / seconds_per_day; 134 | 135 | const double cosH0 = (sin(h0) - sin(astrolabe::globals::latitude) * sin(decList[1])) / (cos(astrolabe::globals::latitude) * cos(decList[1])); 136 | // 137 | // future: return some indicator when the object is circumpolar or always 138 | // below the horizon. 139 | // 140 | if (cosH0 < -1.0) // circumpolar 141 | return -1.0; 142 | if (cosH0 > 1.0) // never rises 143 | return -1.0; 144 | 145 | const double H0 = acos(cosH0); 146 | double m0 = (raList[1] + astrolabe::globals::longitude - THETA0) / pi2; 147 | double m = m0 + H0 / pi2; // this is the only difference between rise() and set() 148 | if (m < 0) 149 | m += 1; 150 | else if (m > 1) 151 | m -= 1; 152 | if (m < 0 || m > 1) 153 | throw Error("astrolabe::riseset::set: m is out of range"); 154 | for (int i = 0; i < 20; i++) { 155 | m0 = m; 156 | const double theta0 = modpi2(THETA0 + _k1 * m); 157 | const double n = m + deltaT_days; 158 | if (n < -1 || n > 1) 159 | return -1.0; // Bug: this is where we drop some events 160 | const double ra = interpolate_angle3(n, raList); 161 | const double dec = interpolate3(n, decList); 162 | double H = theta0 - astrolabe::globals::longitude - ra; 163 | H = diff_angle(0.0, H); 164 | double A, h; 165 | equ_to_horiz(H, dec, A, h); 166 | const double dm = (h - h0) / (pi2 * cos(dec) * cos(astrolabe::globals::latitude) * sin(H)); 167 | m += dm; 168 | if (fabs(m - m0) < delta) 169 | return jd + m; 170 | } 171 | 172 | throw Error("astrolabe::riseset::set: bailout"); 173 | } 174 | 175 | double astrolabe::riseset::transit(double jd, const vector &raList, double delta) { 176 | /* Return the Julian Day of the transit time of an object. 177 | 178 | Parameters: 179 | jd : Julian Day number of the day in question, at 0 hr UT 180 | raList : a sequence of three right accension values, in radians, 181 | for (jd-1, jd, jd+1) 182 | delta : desired accuracy in days. 183 | 184 | Returns: 185 | Julian Day of the transit time 186 | 187 | */ 188 | // 189 | // future: report both upper and lower culmination, and transits of objects below 190 | // the horizon 191 | // 192 | const double THETA0 = sidereal_time_greenwich(jd); 193 | const double deltaT_days = deltaT_seconds(jd) / seconds_per_day; 194 | 195 | double m = (raList[1] + astrolabe::globals::longitude - THETA0) / pi2; 196 | if (m < 0) 197 | m += 1; 198 | else if (m > 1) 199 | m -= 1; 200 | if (m < 0 || m > 1) 201 | throw Error("astrolabe::riseset::transit: m is out of range"); 202 | for (int i = 0; i < 20; i++) { 203 | const double m0 = m; 204 | const double theta0 = modpi2(THETA0 + _k1 * m); 205 | const double n = m + deltaT_days; 206 | if (n < -1 || n > 1) 207 | return -1.0; // Bug: this is where we drop some events 208 | const double ra = interpolate_angle3(n, raList); 209 | double H = theta0 - astrolabe::globals::longitude - ra; 210 | H = diff_angle(0.0, H); 211 | const double dm = -H/pi2; 212 | m += dm; 213 | if (fabs(m - m0) < delta) 214 | return jd + m; 215 | } 216 | 217 | throw Error("astrolabe::riseset::transit: bailout"); 218 | } 219 | 220 | double astrolabe::riseset::moon_rst_altitude(double r) { 221 | /* Returnn the standard altitude of the Moon. 222 | 223 | Parameters: 224 | r : Distance between the centers of the Earth and Moon, in km. 225 | 226 | Returns: 227 | Standard altitude in radians. 228 | 229 | */ 230 | // horizontal parallax 231 | const double parallax = asin(earth_equ_radius / r); 232 | 233 | return 0.7275 * parallax + standard_rst_altitude; 234 | } 235 | 236 | -------------------------------------------------------------------------------- /src/celestial_navigation_pi.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * 3 | * Project: OpenCPN 4 | * Purpose: Celestial Navigation Plugin 5 | * Author: Sean D'Epagnier 6 | * 7 | *************************************************************************** 8 | * Copyright (C) 2015 by Sean D'Epagnier * 9 | * * 10 | * This program is free software; you can redistribute it and/or modify * 11 | * it under the terms of the GNU General Public License as published by * 12 | * the Free Software Foundation; either version 3 of the License, or * 13 | * (at your option) any later version. * 14 | * * 15 | * This program is distributed in the hope that it will be useful, * 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 | * GNU General Public License for more details. * 19 | * * 20 | * You should have received a copy of the GNU General Public License * 21 | * along with this program; if not, write to the * 22 | * Free Software Foundation, Inc., * 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 | *************************************************************************** 25 | */ 26 | 27 | #include 28 | #include 29 | 30 | #include "ocpn_plugin.h" 31 | 32 | #include "Sight.h" 33 | #include "celestial_navigation_pi.h" 34 | #include "icons.h" 35 | 36 | #include "plugingl/pidc.h" 37 | 38 | using namespace std; 39 | 40 | // the class factories, used to create and destroy instances of the PlugIn 41 | 42 | extern "C" DECL_EXP opencpn_plugin* create_pi(void *ppimgr) 43 | { 44 | return (opencpn_plugin *)new celestial_navigation_pi(ppimgr); 45 | } 46 | 47 | extern "C" DECL_EXP void destroy_pi(opencpn_plugin* p) 48 | { 49 | delete p; 50 | } 51 | 52 | //--------------------------------------------------------------------------------------------------------- 53 | // 54 | // Celestial_Navigation PlugIn Implementation 55 | // 56 | //--------------------------------------------------------------------------------------------------------- 57 | 58 | celestial_navigation_pi::celestial_navigation_pi(void *ppimgr) 59 | :opencpn_plugin_111 (ppimgr) 60 | { 61 | // Create the PlugIn icons 62 | initialize_images(); 63 | } 64 | 65 | celestial_navigation_pi::~celestial_navigation_pi(void){} 66 | 67 | 68 | //--------------------------------------------------------------------------------------------------------- 69 | // 70 | // PlugIn initialization and de-init 71 | // 72 | //--------------------------------------------------------------------------------------------------------- 73 | 74 | extern "C" int geomag_load(const char *mdfile); 75 | 76 | int celestial_navigation_pi::Init(void) 77 | { 78 | AddLocaleCatalog( _T("opencpn-celestial_navigation_pi") ); 79 | 80 | // Get a pointer to the opencpn display canvas, to use as a parent for windows created 81 | m_parent_window = GetOCPNCanvasWindow(); 82 | 83 | // This PlugIn needs a toolbar icon, so request its insertion 84 | m_leftclick_tool_id = InsertPlugInTool(_T(""), _img_celestial_navigation, 85 | _img_celestial_navigation, wxITEM_NORMAL, 86 | _("Celestial Navigation"), _T(""), NULL, 87 | CELESTIAL_NAVIGATION_TOOL_POSITION, 0, this); 88 | 89 | m_pCelestialNavigationDialog = NULL; 90 | 91 | return (WANTS_OVERLAY_CALLBACK | 92 | WANTS_OPENGL_OVERLAY_CALLBACK | 93 | WANTS_NMEA_EVENTS | 94 | // WANTS_CURSOR_LATLON | 95 | WANTS_TOOLBAR_CALLBACK | 96 | INSTALLS_TOOLBAR_TOOL 97 | ); 98 | } 99 | 100 | bool celestial_navigation_pi::DeInit(void) 101 | { 102 | RemovePlugInTool(m_leftclick_tool_id); 103 | 104 | if(m_pCelestialNavigationDialog) 105 | { 106 | m_pCelestialNavigationDialog->Close(); 107 | delete m_pCelestialNavigationDialog; 108 | m_pCelestialNavigationDialog = NULL; 109 | } 110 | return true; 111 | } 112 | 113 | int celestial_navigation_pi::GetAPIVersionMajor() 114 | { 115 | return MY_API_VERSION_MAJOR; 116 | } 117 | 118 | int celestial_navigation_pi::GetAPIVersionMinor() 119 | { 120 | return MY_API_VERSION_MINOR; 121 | } 122 | 123 | int celestial_navigation_pi::GetPlugInVersionMajor() 124 | { 125 | return PLUGIN_VERSION_MAJOR; 126 | } 127 | 128 | int celestial_navigation_pi::GetPlugInVersionMinor() 129 | { 130 | return PLUGIN_VERSION_MINOR; 131 | } 132 | 133 | wxBitmap *celestial_navigation_pi::GetPlugInBitmap() 134 | { 135 | return new wxBitmap(_img_celestial_navigation->ConvertToImage().Copy()); 136 | } 137 | 138 | wxString celestial_navigation_pi::GetCommonName() 139 | { 140 | return _("Celestial Navigation"); 141 | } 142 | 143 | wxString celestial_navigation_pi::GetShortDescription() 144 | { 145 | return _("Celestial Navigation PlugIn for OpenCPN"); 146 | } 147 | 148 | wxString celestial_navigation_pi::GetLongDescription() 149 | { 150 | return _("Celestial Navigation PlugIn for OpenCPN.\n\ 151 | Implements nautical almanac for sun, moon, planets,\n\ 152 | and various navigational stars.\n\ 153 | Compute position fix from celestial measurements."); 154 | } 155 | 156 | void celestial_navigation_pi::OnToolbarToolCallback(int id) 157 | { 158 | int ret; 159 | if(!m_pCelestialNavigationDialog) { 160 | /* load the geographical magnetic table */ 161 | wxString geomag_text_path = *GetpSharedDataLocation(); 162 | geomag_text_path.Append(_T("plugins/celestial_navigation_pi/data/IGRF11.COF")); 163 | if((ret = geomag_load(geomag_text_path.mb_str())) < 0) { 164 | wxString message = _("Failed to load file: ") + geomag_text_path + "\n"; 165 | switch (ret) { 166 | case -1: message += "(" + _("open error") + ")\n"; break; 167 | case -5: message += "(" + _("corrupt record") + ")\n"; break; 168 | case -6: message += "(" + _("too many models") + ")\n"; break; 169 | } 170 | wxMessageDialog mdlg(m_parent_window, message 171 | + _("Magnetic data will not be available for the celestial navigation plugin."), 172 | wxString(_("OpenCPN Alert"), wxOK | wxICON_ERROR)); 173 | mdlg.ShowModal(); 174 | } 175 | 176 | m_pCelestialNavigationDialog = new CelestialNavigationDialog(m_parent_window); 177 | } 178 | 179 | m_pCelestialNavigationDialog->Show(!m_pCelestialNavigationDialog->IsShown()); 180 | } 181 | 182 | int celestial_navigation_pi::GetToolbarToolCount(void) 183 | { 184 | return 1; 185 | } 186 | 187 | void celestial_navigation_pi::SetColorScheme(PI_ColorScheme cs) 188 | { 189 | if (NULL == m_pCelestialNavigationDialog) 190 | return; 191 | 192 | DimeWindow(m_pCelestialNavigationDialog); 193 | } 194 | 195 | bool celestial_navigation_pi::RenderOverlay(wxDC &dc, PlugIn_ViewPort *vp) 196 | { 197 | piDC pidc(dc); 198 | Render(pidc, vp); 199 | return true; 200 | } 201 | 202 | bool celestial_navigation_pi::RenderGLOverlay(wxGLContext *pcontext, PlugIn_ViewPort *vp) 203 | { 204 | piDC pidc; 205 | glEnable( GL_BLEND ); 206 | pidc.SetVP(vp); 207 | Render(pidc, vp); 208 | glDisable( GL_BLEND ); 209 | return true; 210 | } 211 | 212 | void celestial_navigation_pi::Render(piDC &dc, PlugIn_ViewPort *vp) 213 | { 214 | if(!m_pCelestialNavigationDialog || !m_pCelestialNavigationDialog->IsShown()) 215 | return; 216 | 217 | /* draw sights */ 218 | wxListCtrl *lSights = m_pCelestialNavigationDialog->m_lSights; 219 | for(int i = 0; iGetItemCount(); i++) { 220 | Sight *s = (Sight*)wxUIntToPtr(lSights->GetItemData(i)); 221 | s->Render ( dc, *vp ); 222 | } 223 | 224 | /* now render fix */ 225 | double lat = m_pCelestialNavigationDialog->m_FixDialog.m_fixlat; 226 | double lon = m_pCelestialNavigationDialog->m_FixDialog.m_fixlon; 227 | double err = m_pCelestialNavigationDialog->m_FixDialog.m_fixerror; 228 | wxPoint r1, r2; 229 | GetCanvasPixLL(vp, &r1, lat-1, lon-1); 230 | GetCanvasPixLL(vp, &r2, lat+1, lon+1); 231 | 232 | if(!isnan(err)) { 233 | dc.SetPen ( wxPen(wxColor(255, 0, 0), 1) ); 234 | dc.SetBrush( *wxTRANSPARENT_BRUSH); 235 | dc.DrawLine( r1.x, r1.y, r2.x, r2.y ); 236 | dc.DrawLine( r1.x, r2.y, r2.x, r1.y ); 237 | } 238 | } 239 | wxString celestial_navigation_pi::StandardPath() 240 | { 241 | wxStandardPathsBase& std_path = wxStandardPathsBase::Get(); 242 | wxString s = wxFileName::GetPathSeparator(); 243 | #if defined(__WXMSW__) 244 | wxString stdPath = std_path.GetConfigDir(); 245 | #elif defined(__WXGTK__) || defined(__WXQT__) 246 | wxString stdPath = std_path.GetUserDataDir(); 247 | #elif defined(__WXOSX__) 248 | wxString stdPath = (std_path.GetUserConfigDir() + s + _T("opencpn")); // should be ~/Library/Preferences/opencpn 249 | #endif 250 | 251 | return stdPath + wxFileName::GetPathSeparator() + 252 | _T("plugins") + wxFileName::GetPathSeparator() + 253 | _T("celestial_navigation") + wxFileName::GetPathSeparator(); 254 | } 255 | 256 | static double s_boat_lat, s_boat_lon; 257 | void celestial_navigation_pi::SetPositionFixEx(PlugIn_Position_Fix_Ex &pfix) 258 | { 259 | s_boat_lat = pfix.Lat; 260 | s_boat_lon = pfix.Lon; 261 | } 262 | 263 | void celestial_navigation_pi::SetCursorLatLon(double lat, double lon) 264 | { 265 | } 266 | 267 | void celestial_navigation_pi_BoatPos(double &lat, double &lon) 268 | { 269 | lat = s_boat_lat; 270 | lon = s_boat_lon; 271 | } 272 | -------------------------------------------------------------------------------- /src/astrolabe/equinox.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2000, 2001 William McClain 2 | 3 | This file is part of Astrolabe. 4 | 5 | Astrolabe is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | Astrolabe is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with Astrolabe; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | // Calculate the times of solstice and equinox events for Earth 21 | 22 | #include 23 | #include "astrolabe.hpp" 24 | 25 | using std::vector; 26 | using std::map; 27 | 28 | using astrolabe::calendar::jd_to_jcent; 29 | using astrolabe::constants::pi; 30 | using astrolabe::constants::pi2; 31 | using astrolabe::Error; 32 | using astrolabe::kAutumn; 33 | using astrolabe::kSpring; 34 | using astrolabe::kSummer; 35 | using astrolabe::kWinter; 36 | using astrolabe::nutation::nut_in_lon; 37 | using astrolabe::Season; 38 | using astrolabe::sun::aberration_low; 39 | using astrolabe::sun::Sun; 40 | using astrolabe::util::diff_angle; 41 | using astrolabe::util::d_to_r; 42 | using astrolabe::util::int_to_string; 43 | using astrolabe::util::polynomial; 44 | using astrolabe::vsop87d::vsop_to_fk5; 45 | 46 | enum Epoch {pre1000, post1000}; 47 | 48 | class Key { 49 | public: 50 | Key(Epoch epoch, Season season) : 51 | epoch(epoch), 52 | season(season) {}; 53 | bool operator<(const Key &rhs) const { 54 | if (epoch < rhs.epoch) 55 | return true; 56 | if (epoch > rhs.epoch) 57 | return false; 58 | return (season < rhs.season); 59 | }; 60 | 61 | const Epoch epoch; 62 | const Season season; 63 | }; 64 | 65 | class Value { 66 | public: 67 | Value() {}; 68 | Value(double d0, double d1, double d2, double d3, double d4) { 69 | series.push_back(d0); 70 | series.push_back(d1); 71 | series.push_back(d2); 72 | series.push_back(d3); 73 | series.push_back(d4); 74 | }; 75 | 76 | vector series; // should be const 77 | }; 78 | 79 | struct Data { 80 | Epoch epoch; 81 | Season season; 82 | double d0, d1, d2, d3, d4; 83 | }; 84 | 85 | namespace { 86 | const Data _tbl[] = { 87 | // 88 | // Meeus-1998 Table 27.A 89 | // 90 | {pre1000, kSpring, 1721139.29189, 365242.13740, 0.06134, 0.00111, -0.00071}, 91 | {pre1000, kSummer, 1721233.25401, 365241.72562, -0.05323, 0.00907, -0.00025}, 92 | {pre1000, kAutumn, 1721325.70455, 365242.49558, -0.11677, -0.00297, 0.00074}, 93 | {pre1000, kWinter, 1721414.39987, 365242.88257, -0.00769, -0.00933, -0.00006}, 94 | // 95 | // Meeus-1998 Table 27.B 96 | // 97 | {post1000, kSpring, 2451623.80984, 365242.37404, 0.05169, -0.00411, -0.00057}, 98 | {post1000, kSummer, 2451716.56767, 365241.62603, 0.00325, 0.00888, -0.00030}, 99 | {post1000, kAutumn, 2451810.21715, 365242.01767, -0.11575, 0.00337, 0.00078}, 100 | {post1000, kWinter, 2451900.05952, 365242.74049, -0.06223, -0.00823, 0.00032} 101 | }; 102 | }; 103 | 104 | class Table { 105 | public: 106 | Table(const Data *begin, const Data *end) { 107 | for (const Data *p = begin; p != end; p++) 108 | table[Key(p->epoch, p->season)] = Value(p->d0, p->d1, p->d2, p->d3, p->d4); 109 | }; 110 | map table; // should be const 111 | }; 112 | 113 | namespace { 114 | Table table(_tbl, _tbl + ARRAY_SIZE(_tbl)); 115 | }; 116 | 117 | // 118 | // Meeus-1998 Table 27.C 119 | // 120 | struct Term { 121 | int A; 122 | double B, C; 123 | }; 124 | 125 | namespace { 126 | const Term _terms[] = { 127 | {485, d_to_r(324.96), d_to_r( 1934.136)}, 128 | {203, d_to_r(337.23), d_to_r( 32964.467)}, 129 | {199, d_to_r(342.08), d_to_r( 20.186)}, 130 | {182, d_to_r( 27.85), d_to_r(445267.112)}, 131 | {156, d_to_r( 73.14), d_to_r( 45036.886)}, 132 | {136, d_to_r(171.52), d_to_r( 22518.443)}, 133 | { 77, d_to_r(222.54), d_to_r( 65928.934)}, 134 | { 74, d_to_r(296.72), d_to_r( 3034.906)}, 135 | { 70, d_to_r(243.58), d_to_r( 9037.513)}, 136 | { 58, d_to_r(119.81), d_to_r( 33718.147)}, 137 | { 52, d_to_r(297.17), d_to_r( 150.678)}, 138 | { 50, d_to_r( 21.02), d_to_r( 2281.226)}, 139 | { 45, d_to_r(247.54), d_to_r( 29929.562)}, 140 | { 44, d_to_r(325.15), d_to_r( 31555.956)}, 141 | { 29, d_to_r( 60.93), d_to_r( 4443.417)}, 142 | { 18, d_to_r(155.12), d_to_r( 67555.328)}, 143 | { 17, d_to_r(288.79), d_to_r( 4562.452)}, 144 | { 16, d_to_r(198.04), d_to_r( 62894.029)}, 145 | { 14, d_to_r(199.76), d_to_r( 31436.921)}, 146 | { 12, d_to_r( 95.39), d_to_r( 14577.848)}, 147 | { 12, d_to_r(287.11), d_to_r( 31931.756)}, 148 | { 12, d_to_r(320.81), d_to_r( 34777.259)}, 149 | { 9, d_to_r(227.73), d_to_r( 1222.114)}, 150 | { 8, d_to_r( 15.45), d_to_r( 16859.074)} 151 | }; 152 | 153 | const VECTOR(terms, Term); 154 | }; 155 | 156 | 157 | double astrolabe::equinox::equinox_approx(int yr, Season season) { 158 | /* Returns the approximate time of a solstice or equinox event. 159 | 160 | The year must be in the range -1000...3000. Within that range the 161 | the error from the precise instant is at most 2.16 minutes. 162 | 163 | Parameters: 164 | yr : year 165 | season : one of ("spring", "summer", "autumn", "winter") 166 | 167 | Returns: 168 | Julian Day of the event in dynamical time 169 | 170 | */ 171 | if (yr < -1000 || yr > 3000) 172 | throw Error("astrolabe::equinox::equinox_approx: year is out of range = " + int_to_string(yr)); 173 | if (season < kSpring || season > kWinter) 174 | throw Error("astrolabe::equinox::equinox_approx: unknown season = " + int_to_string(season)); 175 | 176 | double Y; 177 | Epoch epoch; 178 | if (-1000 <= yr && yr <= 1000) { 179 | Y = yr / 1000.0; 180 | epoch = pre1000; 181 | } 182 | else { 183 | Y = (yr - 2000) / 1000.0; 184 | epoch = post1000; 185 | } 186 | 187 | const Key key(epoch, season); 188 | const vector &poly = table.table[key].series; 189 | double jd = polynomial(poly, Y); 190 | 191 | const double T = jd_to_jcent(jd); 192 | const double W = d_to_r(35999.373 * T - 2.47); 193 | const double delta_lambda = 1 + 0.0334 * cos(W) + 0.0007 * cos(2 * W); 194 | double S = 0.0; 195 | for (std::vector::const_iterator p = terms.begin(); p != terms.end(); ++p) 196 | S += p->A * cos(p->B + p->C * T); 197 | jd += 0.00001 * S / delta_lambda; 198 | return jd; 199 | } 200 | 201 | namespace { 202 | class SeasonToCircle { 203 | public: 204 | SeasonToCircle() { 205 | class Data { 206 | public: 207 | Data(Season season, double circle) : season(season), circle(circle) {}; 208 | 209 | Season season; 210 | double circle; 211 | }; 212 | 213 | const Data tbl[] = { 214 | Data(kSpring, 0), 215 | Data(kSummer, pi * 0.5), 216 | Data(kAutumn, pi), 217 | Data(kWinter, pi * 1.5) 218 | }; 219 | for (const Data *p = tbl; p != tbl + ARRAY_SIZE(tbl); p++) 220 | pmap[p->season] = p->circle; 221 | }; 222 | 223 | const double &operator[](Season season) const { 224 | std::map::const_iterator p = pmap.find(season); 225 | if (p == pmap.end()) 226 | throw Error("astrolabe::equinox::SeasonToCircle::const double &operator[]: season out of range = " + int_to_string(season)); 227 | return p->second; 228 | }; 229 | 230 | private: 231 | map pmap; 232 | }; 233 | 234 | const SeasonToCircle seasonToCircle; 235 | }; 236 | 237 | double astrolabe::equinox::equinox_exact(double jd, Season season, double delta) { 238 | /* Return the precise moment of an equinox or solstice event on Earth. 239 | 240 | Parameters: 241 | jd : Julian Day of an approximate time of the event in dynamical time 242 | season : one of ("spring", "summer", "autumn", "winter") 243 | model : the solar position model, which must be an object that responds that 244 | to the dimension3() method. Actually, we presume this is an 245 | instance of astrolabe.sun.Sun() because we use the VSOP coordinate 246 | correction function. 247 | delta : the required precision in days. Times accurate to a second are 248 | reasonable when using the VSOP model. 249 | 250 | Returns: 251 | Julian Day of the event in dynamical time 252 | 253 | */ 254 | // 255 | // If we knew that the starting approximate time was close enough 256 | // to the actual time, we could pull nut_in_lon() and the aberration 257 | // out of the loop and save some calculating. 258 | // 259 | static const double _k_sun_motion = 365.25 / pi2; 260 | const double circ = seasonToCircle[season]; 261 | Sun sun; 262 | for (int i = 0; i < 20; i++) { 263 | const double jd0 = jd; 264 | double L, B, R; 265 | sun.dimension3(jd, L, B, R); 266 | L += nut_in_lon(jd) + aberration_low(R); 267 | vsop_to_fk5(jd, L, B); 268 | // Meeus uses jd + 58 * sin(diff(...)) 269 | jd += diff_angle(L, circ) * _k_sun_motion; 270 | if (fabs(jd - jd0) < delta) 271 | return jd; 272 | } 273 | throw Error("astrolabe::equinox::equinox_exact: bailout"); 274 | } 275 | -------------------------------------------------------------------------------- /cmake/PluginConfigure.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Sean D'Epagnier 3 | ## Copyright: 4 | ## License: GPLv3+ 5 | ##--------------------------------------------------------------------------- 6 | 7 | # To build for android, use this cmake invocation.. 8 | #$cmake -DCMAKE_TOOLCHAIN_FILE=../buildandroid/build_android.cmake 9 | 10 | 11 | SET(PLUGIN_SOURCE_DIR .) 12 | 13 | 14 | MESSAGE (STATUS "*** Building ${PACKAGE_NAME} ***") 15 | 16 | MESSAGE (STATUS "Build type: ${CMAKE_BUILD_TYPE}") 17 | IF (PREFIX) 18 | SET(CMAKE_INSTALL_PREFIX ${PREFIX}) 19 | ENDIF (PREFIX) 20 | 21 | SET(PREFIX_BIN bin) 22 | SET(PREFIX_INCLUDE include) 23 | SET(PREFIX_DATA share) 24 | SET(PREFIX_PKGDATA ${PREFIX_DATA}/${PACKAGE_NAME}) 25 | 26 | IF (NOT WIN32) 27 | # default 28 | SET (ARCH "i386") 29 | IF (UNIX AND NOT APPLE) 30 | MESSAGE (STATUS "*** Will install to ${CMAKE_INSTALL_PREFIX} ***") 31 | 32 | IF (EXISTS /etc/debian_version) 33 | SET (PACKAGE_FORMAT "DEB") 34 | #SET (PACKAGE_DEPS "libc6, libwxgtk3.0-0, libglu1-mesa (>= 7.0.0)") 35 | SET (LIB_INSTALL_DIR "lib") 36 | IF (CMAKE_SIZEOF_VOID_P MATCHES "8") 37 | SET (ARCH "amd64") 38 | ELSE (CMAKE_SIZEOF_VOID_P MATCHES "8") 39 | SET (ARCH "i386") 40 | ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8") 41 | ENDIF (EXISTS /etc/debian_version) 42 | IF (EXISTS /etc/redhat-release) 43 | SET (PACKAGE_FORMAT "RPM") 44 | SET (PACKAGE_DEPS "opencpn") 45 | IF (CMAKE_SIZEOF_VOID_P MATCHES "8") 46 | SET (ARCH "x86_64") 47 | SET (LIB_INSTALL_DIR "lib64") 48 | ELSE (CMAKE_SIZEOF_VOID_P MATCHES "8") 49 | SET (ARCH "i386") 50 | SET (LIB_INSTALL_DIR "lib") 51 | ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8") 52 | ENDIF (EXISTS /etc/redhat-release) 53 | ENDIF (UNIX AND NOT APPLE) 54 | endif(NOT WIN32) 55 | 56 | IF (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") 57 | SET (ARCH "armhf") 58 | ADD_DEFINITIONS( -DARMHF ) 59 | ENDIF (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") 60 | 61 | MESSAGE (STATUS "*** Build Architecture is ${ARCH}") 62 | 63 | 64 | IF(DEFINED _wx_selected_config) 65 | 66 | # May be overridden 67 | IF(NOT DEFINED Qt_Build) 68 | SET(Qt_Build "android_armv7") 69 | ENDIF(NOT DEFINED Qt_Build) 70 | 71 | MESSAGE (STATUS "selected config ${_wx_selected_config}") 72 | 73 | IF(_wx_selected_config MATCHES "androideabi-qt") 74 | MESSAGE (STATUS "Building for wxQt-Android") 75 | MESSAGE (STATUS "Qt_Base/Build: " ${Qt_Base} "/" ${Qt_Build}) 76 | MESSAGE (STATUS "wxQt_Base/Build: " ${wxQt_Base} "/" ${wxQt_Build}) 77 | SET(QT_ANDROID "ON") 78 | SET(QT_LINUX "OFF") 79 | SET(QT "ON") 80 | ENDIF(_wx_selected_config MATCHES "androideabi-qt") 81 | 82 | ENDIF(DEFINED _wx_selected_config) 83 | 84 | 85 | MESSAGE (STATUS "*** Staging to build ${PACKAGE_NAME} ***") 86 | 87 | include ("VERSION.cmake") 88 | 89 | # Do the version.h configuration into the build output directory, 90 | # thereby allowing building from a read-only source tree. 91 | IF(NOT SKIP_VERSION_CONFIG) 92 | configure_file(${PROJECT_SOURCE_DIR}/cmake/version.h.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include/version.h) 93 | configure_file(cmake/wxWTranslateCatalog.h.in ${PROJECT_SOURCE_DIR}/src/wxWTranslateCatalog.h) 94 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/include) 95 | ENDIF(NOT SKIP_VERSION_CONFIG) 96 | 97 | SET(PLUGIN_VERSION "${PLUGIN_VERSION_MAJOR}.${PLUGIN_VERSION_MINOR}.${PLUGIN_VERSION_PATCH}" ) 98 | 99 | INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src) 100 | 101 | # SET(PROFILING 1) 102 | 103 | # IF NOT DEBUGGING CFLAGS="-O2 -march=native" 104 | IF(NOT MSVC) 105 | IF(PROFILING) 106 | ADD_DEFINITIONS( "-Wall -g -fprofile-arcs -ftest-coverage -fexceptions -fPIC" ) 107 | ELSE(PROFILING) 108 | # ADD_DEFINITIONS( "-Wall -g -fexceptions" ) 109 | ADD_DEFINITIONS( "-Wall -Wno-unused-result -g -fexceptions -fPIC" ) 110 | ENDIF(PROFILING) 111 | 112 | IF(NOT APPLE) 113 | SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic") 114 | ELSE(NOT APPLE) 115 | SET(CMAKE_SHARED_LINKER_FLAGS "-Wl -undefined dynamic_lookup") 116 | ENDIF(NOT APPLE) 117 | 118 | ENDIF(NOT MSVC) 119 | 120 | # Add some definitions to satisfy MS 121 | IF(MSVC) 122 | ADD_DEFINITIONS(-D__MSVC__) 123 | ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE) 124 | ENDIF(MSVC) 125 | 126 | IF(NOT DEFINED wxWidgets_USE_FILE) 127 | SET(wxWidgets_USE_LIBS base core net xml html adv) 128 | ENDIF(NOT DEFINED wxWidgets_USE_FILE) 129 | 130 | 131 | # QT_ANDROID is a cross-build, so the native FIND_PACKAGE(wxWidgets...) and wxWidgets_USE_FILE is not useful. 132 | # We add the dependencies manually. 133 | IF(QT_ANDROID) 134 | ADD_DEFINITIONS(-D__WXQT__) 135 | ADD_DEFINITIONS(-D__OCPN__ANDROID__) 136 | ADD_DEFINITIONS(-DOCPN_USE_WRAPPER) 137 | ADD_DEFINITIONS(-DANDROID) 138 | INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include/android) 139 | 140 | SET(CMAKE_CXX_FLAGS "-pthread -s") 141 | 142 | ## Compiler flags 143 | # if(CMAKE_COMPILER_IS_GNUCXX) 144 | # set(CMAKE_CXX_FLAGS "-O2") ## Optimize 145 | set(CMAKE_EXE_LINKER_FLAGS "-s") ## Strip binary 146 | # endif() 147 | 148 | INCLUDE_DIRECTORIES("${Qt_Base}/${Qt_Build}/include/QtCore") 149 | INCLUDE_DIRECTORIES("${Qt_Base}/${Qt_Build}/include") 150 | INCLUDE_DIRECTORIES("${Qt_Base}/${Qt_Build}/include/QtWidgets") 151 | INCLUDE_DIRECTORIES("${Qt_Base}/${Qt_Build}/include/QtGui") 152 | INCLUDE_DIRECTORIES("${Qt_Base}/${Qt_Build}/include/QtOpenGL") 153 | INCLUDE_DIRECTORIES("${Qt_Base}/${Qt_Build}/include/QtTest") 154 | 155 | INCLUDE_DIRECTORIES( "${wxQt_Base}/${wxQt_Build}/lib/wx/include/arm-linux-androideabi-qt-unicode-static-3.1") 156 | INCLUDE_DIRECTORIES("${wxQt_Base}/include") 157 | 158 | ADD_DEFINITIONS(-DQT_WIDGETS_LIB) 159 | 160 | ENDIF(QT_ANDROID) 161 | 162 | 163 | IF(MSYS) 164 | # this is just a hack. I think the bug is in FindwxWidgets.cmake 165 | STRING( REGEX REPLACE "/usr/local" "\\\\;C:/MinGW/msys/1.0/usr/local" wxWidgets_INCLUDE_DIRS ${wxWidgets_INCLUDE_DIRS} ) 166 | ENDIF(MSYS) 167 | 168 | # QT_ANDROID is a cross-build, so the native FIND_PACKAGE(OpenGL) is not useful. 169 | # 170 | IF (NOT QT_ANDROID ) 171 | 172 | OPTION(OCPN_USE_SVG "Use SVG graphics" ON) 173 | 174 | IF(OCPN_USE_SVG) 175 | ADD_DEFINITIONS(-DOCPN_USE_SVG) 176 | ENDIF(OCPN_USE_SVG) 177 | 178 | 179 | FIND_PACKAGE(OpenGL) 180 | IF(OPENGL_GLU_FOUND) 181 | 182 | SET(wxWidgets_USE_LIBS ${wxWidgets_USE_LIBS} gl) 183 | INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) 184 | 185 | MESSAGE (STATUS "Found OpenGL..." ) 186 | #MESSAGE (STATUS " Lib: " ${OPENGL_LIBRARIES}) 187 | #MESSAGE (STATUS " Include: " ${OPENGL_INCLUDE_DIR}) 188 | ADD_DEFINITIONS(-DocpnUSE_GL) 189 | ELSE(OPENGL_GLU_FOUND) 190 | MESSAGE (STATUS "OpenGL not found..." ) 191 | ENDIF(OPENGL_GLU_FOUND) 192 | ENDIF(NOT QT_ANDROID) 193 | 194 | # Building for QT_ANDROID involves a cross-building environment, 195 | # So the OpenGL include directories, flags, etc must be stated explicitly 196 | # without trying to locate them on the host build system. 197 | IF(QT_ANDROID) 198 | SET(CMAKE_VERBOSE_MAKEFILE ON) 199 | ADD_DEFINITIONS(-DocpnUSE_GLES) 200 | ADD_DEFINITIONS(-DocpnUSE_GL) 201 | # ADD_DEFINITIONS(-DUSE_GLU_TESS) 202 | ADD_DEFINITIONS(-DARMHF) 203 | 204 | SET(OPENGLES_FOUND "YES") 205 | SET(OPENGL_FOUND "YES") 206 | 207 | 208 | SET(USE_GLES2 ON ) 209 | 210 | IF(USE_GLES2) 211 | MESSAGE (STATUS "Using GLESv2 for Android") 212 | ADD_DEFINITIONS(-DUSE_ANDROID_GLES2) 213 | ADD_DEFINITIONS(-DUSE_GLSL) 214 | ENDIF(USE_GLES2) 215 | 216 | ENDIF(QT_ANDROID) 217 | 218 | IF (NOT QT_ANDROID ) 219 | set (WXWIDGETS_FORCE_VERSION CACHE VERSION "Force usage of a specific wxWidgets version.") 220 | if(WXWIDGETS_FORCE_VERSION) 221 | set (wxWidgets_CONFIG_OPTIONS --version=${WXWIDGETS_FORCE_VERSION}) 222 | endif() 223 | FIND_PACKAGE(wxWidgets REQUIRED) 224 | INCLUDE(${wxWidgets_USE_FILE}) 225 | ENDIF (NOT QT_ANDROID ) 226 | 227 | # On Android, PlugIns need a specific linkage set.... 228 | IF (QT_ANDROID ) 229 | # These libraries are needed to create PlugIns on Android. 230 | 231 | SET(OCPN_Core_LIBRARIES 232 | # Presently, Android Plugins are built in the core tree, so the variables {wxQT_BASE}, etc. 233 | # flow to this module from above. If we want to build Android plugins out-of-core, this will need improvement. 234 | 235 | # TODO This is pretty ugly, but there seems no way to avoid specifying a full path in a cross build.... 236 | #/home/dsr/Projects/opencpn/build-opencpn-Production_build_Android_for_armeabi_v7a_GCC_4_8_Qt_5_5_0-Release/libopencpn.so 237 | /home/sean/build-opencpn-Production_Android_for_armeabi_v7a_Core_55_46_GCC_4_8_Qt_5_5_0-Release/libopencpn.so 238 | 239 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_baseu-3.1-arm-linux-androideabi.a 240 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_qtu_core-3.1-arm-linux-androideabi.a 241 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_qtu_html-3.1-arm-linux-androideabi.a 242 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_baseu_xml-3.1-arm-linux-androideabi.a 243 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_qtu_qa-3.1-arm-linux-androideabi.a 244 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_qtu_adv-3.1-arm-linux-androideabi.a 245 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_qtu_aui-3.1-arm-linux-androideabi.a 246 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_baseu_net-3.1-arm-linux-androideabi.a 247 | ${wxQt_Base}/${wxQt_Build}/lib/libwx_qtu_gl-3.1-arm-linux-androideabi.a 248 | ${Qt_Base}/${Qt_Build}/lib/libQt5Core.so 249 | ${Qt_Base}/${Qt_Build}/lib/libQt5OpenGL.so 250 | ${Qt_Base}/${Qt_Build}/lib/libQt5Widgets.so 251 | ${Qt_Base}/${Qt_Build}/lib/libQt5Gui.so 252 | ${Qt_Base}/${Qt_Build}/lib/libQt5AndroidExtras.so 253 | libGLESv2.so 254 | libEGL.so 255 | ) 256 | 257 | ENDIF(QT_ANDROID) 258 | 259 | 260 | 261 | 262 | SET(BUILD_SHARED_LIBS TRUE) 263 | 264 | FIND_PACKAGE(Gettext REQUIRED) 265 | 266 | 267 | IF(NOT WIN32) 268 | IF(NOT APPLE) 269 | SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic") 270 | ADD_DEFINITIONS( "-rdynamic" ) 271 | ELSE(NOT APPLE) 272 | SET(CMAKE_SHARED_LINKER_FLAGS "-Wl -undefined dynamic_lookup") 273 | ADD_DEFINITIONS( "-Wno-overloaded-virtual" ) 274 | ENDIF(NOT APPLE) 275 | 276 | ENDIF(NOT WIN32) 277 | 278 | 279 | # Add some definitions to satisfy MS 280 | IF(WIN32) 281 | ADD_DEFINITIONS(-D__MSVC__) 282 | ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE) 283 | ENDIF(WIN32) 284 | 285 | # Let cmake find additional modules private 286 | LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) 287 | 288 | 289 | ADD_DEFINITIONS(-DTIXML_USE_STL) 290 | 291 | -------------------------------------------------------------------------------- /cmake/PluginPackage.cmake: -------------------------------------------------------------------------------- 1 | ##--------------------------------------------------------------------------- 2 | ## Author: Pavel Kalian (Based on the work of Sean D'Epagnier) 3 | ## Copyright: 2014 4 | ## License: GPLv3+ 5 | ##--------------------------------------------------------------------------- 6 | 7 | IF(NOT QT_ANDROID) 8 | 9 | # build a CPack driven installer package 10 | #include (InstallRequiredSystemLibraries) 11 | 12 | SET(CPACK_PACKAGE_NAME "${PACKAGE_NAME}") 13 | SET(CPACK_PACKAGE_VENDOR "opencpn.org") 14 | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CPACK_PACKAGE_NAME} ${PACKAGE_VERSION}) 15 | SET(PACKAGE_VERSION "${PLUGIN_VERSION_MAJOR}.${PLUGIN_VERSION_MINOR}.${PLUGIN_VERSION_PATCH}" ) 16 | SET(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION}) 17 | SET(CPACK_PACKAGE_VERSION_MAJOR ${PLUGIN_VERSION_MAJOR}) 18 | SET(CPACK_PACKAGE_VERSION_MINOR ${PLUGIN_VERSION_MINOR}) 19 | SET(CPACK_PACKAGE_VERSION_PATCH ${PLUGIN_VERSION_PATCH}) 20 | SET(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${PACKAGE_NAME};ALL;/") 21 | SET(CPACK_PACKAGE_EXECUTABLES OpenCPN ${PACKAGE_NAME}) 22 | SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) 23 | 24 | IF(WIN32) 25 | # to protect against confusable windows users, let us _not_ generate zip packages 26 | # SET(CPACK_GENERATOR "NSIS;ZIP") 27 | 28 | # override install directory to put package files in the opencpn directory 29 | SET(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenCPN") 30 | 31 | # CPACK_NSIS_DIR ?? 32 | # CPACK_BUILDWIN_DIR ?? 33 | # CPACK_PACKAGE_ICON ?? 34 | 35 | SET(CPACK_NSIS_PACKAGE_NAME "${PACKAGE_NAME}") 36 | 37 | # Let cmake find NSIS.template.in 38 | SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/buildwin") 39 | 40 | # These lines set the name of the Windows Start Menu shortcut and the icon that goes with it 41 | # SET(CPACK_NSIS_INSTALLED_ICON_NAME "${PACKAGE_NAME}") 42 | SET(CPACK_NSIS_DISPLAY_NAME "OpenCPN ${PACKAGE_NAME}") 43 | 44 | SET(CPACK_NSIS_DIR "${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode") #Gunther 45 | SET(CPACK_BUILDWIN_DIR "${PROJECT_SOURCE_DIR}/buildwin") #Gunther 46 | 47 | ELSE(WIN32) 48 | SET(CPACK_PACKAGE_INSTALL_DIRECTORY ${PACKAGE_NAME}) 49 | ENDIF(WIN32) 50 | 51 | SET(CPACK_STRIP_FILES "${PACKAGE_NAME}") 52 | 53 | SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/gpl.txt") 54 | 55 | IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/README") 56 | # MESSAGE(STATUS "Using generic cpack package description file.") 57 | SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") 58 | SET(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README") 59 | ENDIF () 60 | 61 | #SET(CPACK_SOURCE_GENERATOR "TGZ") 62 | 63 | # The following components are regex's to match anywhere (unless anchored) 64 | # in absolute path + filename to find files or directories to be excluded 65 | # from source tarball. 66 | set(CPACK_SOURCE_IGNORE_FILES 67 | "^${CMAKE_CURRENT_SOURCE_DIR}/.git/*" 68 | "^${CMAKE_CURRENT_SOURCE_DIR}/build*" 69 | "^${CPACK_PACKAGE_INSTALL_DIRECTORY}/*" 70 | ) 71 | 72 | IF(UNIX AND NOT APPLE) 73 | # INCLUDE(UseRPMTools) 74 | # IF(RPMTools_FOUND) 75 | # RPMTools_ADD_RPM_TARGETS(packagename ${PROJECT_SOURCE_DIR}/package.spec) 76 | # ENDIF(RPMTools_FOUND) 77 | 78 | # need apt-get install rpm, for rpmbuild 79 | SET(PACKAGE_DEPS "opencpn, bzip2, gzip") 80 | SET(PACKAGE_RELEASE 1) 81 | 82 | 83 | IF (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*") 84 | SET (ARCH "armhf") 85 | # don't bother with rpm on armhf 86 | SET(CPACK_GENERATOR "DEB;RPM;TBZ2") 87 | ELSE () 88 | SET(CPACK_GENERATOR "DEB;RPM;TBZ2") 89 | 90 | IF (CMAKE_SIZEOF_VOID_P MATCHES "8") 91 | SET (ARCH "amd64") 92 | SET(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") 93 | ELSE (CMAKE_SIZEOF_VOID_P MATCHES "8") 94 | SET (ARCH "i386") 95 | # note: in a chroot must use "setarch i686 make package" 96 | SET(CPACK_RPM_PACKAGE_ARCHITECTURE "i686") 97 | ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8") 98 | ENDIF () 99 | 100 | SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${PACKAGE_DEPS}) 101 | SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS ${PACKAGE_RECS}) 102 | SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${ARCH}) 103 | SET(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") 104 | SET(CPACK_DEBIAN_PACKAGE_SECTION "misc") 105 | SET(CPACK_DEBIAN_COMPRESSION_TYPE "xz") # requires my patches to cmake 106 | 107 | SET(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}") 108 | SET(CPACK_RPM_PACKAGE_REQUIRES ${PACKAGE_DEPS}) 109 | # SET(CPACK_RPM_PACKAGE_GROUP "Applications/Engineering") 110 | SET(CPACK_RPM_PACKAGE_LICENSE "gplv3+") 111 | 112 | SET(CPACK_RPM_COMPRESSION_TYPE "xz") 113 | # SET(CPACK_RPM_USER_BINARY_SPECFILE "${PROJECT_SOURCE_DIR}/opencpn.spec.in") 114 | 115 | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_NAME} PlugIn for OpenCPN") 116 | SET(CPACK_PACKAGE_DESCRIPTION "${PACKAGE_NAME} PlugIn for OpenCPN") 117 | # SET(CPACK_SET_DESTDIR ON) 118 | SET(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 119 | 120 | 121 | SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}_${PACKAGE_VERSION}-${PACKAGE_RELEASE}_${ARCH}" ) 122 | ENDIF(UNIX AND NOT APPLE) 123 | 124 | IF(TWIN32 AND NOT UNIX) 125 | # configure_file(${PROJECT_SOURCE_DIR}/src/opencpn.rc.in ${PROJECT_SOURCE_DIR}/src/opencpn.rc) 126 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_GERMAN.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_GERMAN.nsh" @ONLY) 127 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_FRENCH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_FRENCH.nsh" @ONLY) 128 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_CZECH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_CZECH.nsh" @ONLY) 129 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_DANISH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_DANISH.nsh" @ONLY) 130 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_SPANISH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_SPANISH.nsh" @ONLY) 131 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_ITALIAN.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_ITALIAN.nsh" @ONLY) 132 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_DUTCH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_DUTCH.nsh" @ONLY) 133 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_POLISH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_POLISH.nsh" @ONLY) 134 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_PORTUGUESEBR.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_PORTUGUESEBR.nsh" @ONLY) 135 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_PORTUGUESE.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_PORTUGUESE.nsh" @ONLY) 136 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_RUSSIAN.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_RUSSIAN.nsh" @ONLY) 137 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_SWEDISH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_SWEDISH.nsh" @ONLY) 138 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_FINNISH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_FINNISH.nsh" @ONLY) 139 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_NORWEGIAN.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_NORWEGIAN.nsh" @ONLY) 140 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_CHINESETW.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_CHINESETW.nsh" @ONLY) 141 | configure_file("${PROJECT_SOURCE_DIR}/buildwin/NSIS_Unicode/Language files/Langstrings_TURKISH.nsh.in" "${PROJECT_SOURCE_DIR}//buildwin/NSIS_Unicode/Include/Langstrings_TURKISH.nsh" @ONLY) 142 | ENDIF(TWIN32 AND NOT UNIX) 143 | 144 | 145 | # this dummy target is necessary to make sure the ADDITIONAL_MAKE_CLEAN_FILES directive is executed. 146 | # apparently, the base CMakeLists.txt file must have "some" target to activate all the clean steps. 147 | #ADD_CUSTOM_TARGET(dummy COMMENT "dummy: Done." DEPENDS ${PACKAGE_NAME}) 148 | 149 | 150 | INCLUDE(CPack) 151 | 152 | IF(NOT STANDALONE MATCHES "BUNDLED") 153 | IF(APPLE) 154 | MESSAGE (STATUS "*** Staging to build PlugIn OSX Package ***") 155 | 156 | # Copy a bunch of files so the Packages installer builder can find them 157 | # relative to ${CMAKE_CURRENT_BINARY_DIR} 158 | # This avoids absolute paths in the chartdldr_pi.pkgproj file 159 | 160 | configure_file(${PROJECT_SOURCE_DIR}/cmake/gpl.txt 161 | ${CMAKE_CURRENT_BINARY_DIR}/license.txt COPYONLY) 162 | 163 | configure_file(${PROJECT_SOURCE_DIR}/buildosx/InstallOSX/pkg_background.jpg 164 | ${CMAKE_CURRENT_BINARY_DIR}/pkg_background.jpg COPYONLY) 165 | 166 | # Patch the pkgproj.in file to make the output package name conform to Xxx-Plugin_x.x.pkg format 167 | # Key is: 168 | # NAME 169 | # ${VERBOSE_NAME}-Plugin_${VERSION_MAJOR}.${VERSION_MINOR} 170 | 171 | configure_file(${PROJECT_SOURCE_DIR}/buildosx/InstallOSX/${PACKAGE_NAME}.pkgproj.in 172 | ${CMAKE_CURRENT_BINARY_DIR}/${VERBOSE_NAME}.pkgproj) 173 | 174 | ADD_CUSTOM_COMMAND( 175 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${VERBOSE_NAME}-Plugin.pkg 176 | COMMAND /usr/local/bin/packagesbuild -F ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${VERBOSE_NAME}.pkgproj 177 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 178 | DEPENDS ${PACKAGE_NAME} 179 | COMMENT "create-pkg [${PACKAGE_NAME}]: Generating pkg file." 180 | ) 181 | 182 | ADD_CUSTOM_TARGET(create-pkg COMMENT "create-pkg: Done." 183 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${VERBOSE_NAME}-Plugin.pkg ) 184 | 185 | 186 | ENDIF(APPLE) 187 | 188 | IF(WIN32) 189 | SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${PLUGIN_VERSION_MAJOR}.${PLUGIN_VERSION_MINOR}-win32.exe" ) 190 | MESSAGE(STATUS "FILE: ${CPACK_PACKAGE_FILE_NAME}") 191 | add_custom_command(OUTPUT ${CPACK_PACKAGE_FILE_NAME} 192 | COMMAND signtool sign /v /f \\cert\\OpenCPNSPC.pfx /d http://www.opencpn.org /t http://timestamp.verisign.com/scripts/timstamp.dll ${CPACK_PACKAGE_FILE_NAME} 193 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 194 | DEPENDS ${PACKAGE_NAME} 195 | COMMENT "Code-Signing: ${CPACK_PACKAGE_FILE_NAME}") 196 | ADD_CUSTOM_TARGET(codesign COMMENT "code signing: Done." 197 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME} ) 198 | 199 | ENDIF(WIN32) 200 | ENDIF(NOT STANDALONE MATCHES "BUNDLED") 201 | 202 | ENDIF(NOT QT_ANDROID) 203 | -------------------------------------------------------------------------------- /src/zlib-1.2.3/zconf.h: -------------------------------------------------------------------------------- 1 | /* zconf.h -- configuration of the zlib compression library 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | 7 | #ifndef ZCONF_H 8 | #define ZCONF_H 9 | 10 | /* 11 | * If you *really* need a unique prefix for all types and library functions, 12 | * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. 13 | */ 14 | #ifdef Z_PREFIX 15 | # define deflateInit_ z_deflateInit_ 16 | # define deflate z_deflate 17 | # define deflateEnd z_deflateEnd 18 | # define inflateInit_ z_inflateInit_ 19 | # define inflate z_inflate 20 | # define inflateEnd z_inflateEnd 21 | # define deflateInit2_ z_deflateInit2_ 22 | # define deflateSetDictionary z_deflateSetDictionary 23 | # define deflateCopy z_deflateCopy 24 | # define deflateReset z_deflateReset 25 | # define deflateParams z_deflateParams 26 | # define deflateBound z_deflateBound 27 | # define deflatePrime z_deflatePrime 28 | # define inflateInit2_ z_inflateInit2_ 29 | # define inflateSetDictionary z_inflateSetDictionary 30 | # define inflateSync z_inflateSync 31 | # define inflateSyncPoint z_inflateSyncPoint 32 | # define inflateCopy z_inflateCopy 33 | # define inflateReset z_inflateReset 34 | # define inflateBack z_inflateBack 35 | # define inflateBackEnd z_inflateBackEnd 36 | # define compress z_compress 37 | # define compress2 z_compress2 38 | # define compressBound z_compressBound 39 | # define uncompress z_uncompress 40 | # define adler32 z_adler32 41 | # define crc32 z_crc32 42 | # define get_crc_table z_get_crc_table 43 | # define zError z_zError 44 | 45 | # define alloc_func z_alloc_func 46 | # define free_func z_free_func 47 | # define in_func z_in_func 48 | # define out_func z_out_func 49 | # define Byte z_Byte 50 | # define uInt z_uInt 51 | # define uLong z_uLong 52 | # define Bytef z_Bytef 53 | # define charf z_charf 54 | # define intf z_intf 55 | # define uIntf z_uIntf 56 | # define uLongf z_uLongf 57 | # define voidpf z_voidpf 58 | # define voidp z_voidp 59 | #endif 60 | 61 | #if defined(__MSDOS__) && !defined(MSDOS) 62 | # define MSDOS 63 | #endif 64 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) 65 | # define OS2 66 | #endif 67 | #if defined(_WINDOWS) && !defined(WINDOWS) 68 | # define WINDOWS 69 | #endif 70 | #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) 71 | # ifndef WIN32 72 | # define WIN32 73 | # endif 74 | #endif 75 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) 76 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) 77 | # ifndef SYS16BIT 78 | # define SYS16BIT 79 | # endif 80 | # endif 81 | #endif 82 | 83 | /* 84 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more 85 | * than 64k bytes at a time (needed on systems with 16-bit int). 86 | */ 87 | #ifdef SYS16BIT 88 | # define MAXSEG_64K 89 | #endif 90 | #ifdef MSDOS 91 | # define UNALIGNED_OK 92 | #endif 93 | 94 | #ifdef __STDC_VERSION__ 95 | # ifndef STDC 96 | # define STDC 97 | # endif 98 | # if __STDC_VERSION__ >= 199901L 99 | # ifndef STDC99 100 | # define STDC99 101 | # endif 102 | # endif 103 | #endif 104 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) 105 | # define STDC 106 | #endif 107 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) 108 | # define STDC 109 | #endif 110 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) 111 | # define STDC 112 | #endif 113 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) 114 | # define STDC 115 | #endif 116 | 117 | #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ 118 | # define STDC 119 | #endif 120 | 121 | #ifndef STDC 122 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ 123 | # define const /* note: need a more gentle solution here */ 124 | # endif 125 | #endif 126 | 127 | /* Some Mac compilers merge all .h files incorrectly: */ 128 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) 129 | # define NO_DUMMY_DECL 130 | #endif 131 | 132 | /* Maximum value for memLevel in deflateInit2 */ 133 | #ifndef MAX_MEM_LEVEL 134 | # ifdef MAXSEG_64K 135 | # define MAX_MEM_LEVEL 8 136 | # else 137 | # define MAX_MEM_LEVEL 9 138 | # endif 139 | #endif 140 | 141 | /* Maximum value for windowBits in deflateInit2 and inflateInit2. 142 | * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 143 | * created by gzip. (Files created by minigzip can still be extracted by 144 | * gzip.) 145 | */ 146 | #ifndef MAX_WBITS 147 | # define MAX_WBITS 15 /* 32K LZ77 window */ 148 | #endif 149 | 150 | /* The memory requirements for deflate are (in bytes): 151 | (1 << (windowBits+2)) + (1 << (memLevel+9)) 152 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 153 | plus a few kilobytes for small objects. For example, if you want to reduce 154 | the default memory requirements from 256K to 128K, compile with 155 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 156 | Of course this will generally degrade compression (there's no free lunch). 157 | 158 | The memory requirements for inflate are (in bytes) 1 << windowBits 159 | that is, 32K for windowBits=15 (default value) plus a few kilobytes 160 | for small objects. 161 | */ 162 | 163 | /* Type declarations */ 164 | 165 | #ifndef OF /* function prototypes */ 166 | # ifdef STDC 167 | # define OF(args) args 168 | # else 169 | # define OF(args) () 170 | # endif 171 | #endif 172 | 173 | /* The following definitions for FAR are needed only for MSDOS mixed 174 | * model programming (small or medium model with some far allocations). 175 | * This was tested only with MSC; for other MSDOS compilers you may have 176 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 177 | * just define FAR to be empty. 178 | */ 179 | #ifdef SYS16BIT 180 | # if defined(M_I86SM) || defined(M_I86MM) 181 | /* MSC small or medium model */ 182 | # define SMALL_MEDIUM 183 | # ifdef _MSC_VER 184 | # define FAR _far 185 | # else 186 | # define FAR far 187 | # endif 188 | # endif 189 | # if (defined(__SMALL__) || defined(__MEDIUM__)) 190 | /* Turbo C small or medium model */ 191 | # define SMALL_MEDIUM 192 | # ifdef __BORLANDC__ 193 | # define FAR _far 194 | # else 195 | # define FAR far 196 | # endif 197 | # endif 198 | #endif 199 | 200 | #if defined(WINDOWS) || defined(WIN32) 201 | /* If building or using zlib as a DLL, define ZLIB_DLL. 202 | * This is not mandatory, but it offers a little performance increase. 203 | */ 204 | # ifdef ZLIB_DLL 205 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) 206 | # ifdef ZLIB_INTERNAL 207 | # define ZEXTERN extern __declspec(dllexport) 208 | # else 209 | # define ZEXTERN extern __declspec(dllimport) 210 | # endif 211 | # endif 212 | # endif /* ZLIB_DLL */ 213 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, 214 | * define ZLIB_WINAPI. 215 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. 216 | */ 217 | # ifdef ZLIB_WINAPI 218 | # ifdef FAR 219 | # undef FAR 220 | # endif 221 | # include 222 | /* No need for _export, use ZLIB.DEF instead. */ 223 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ 224 | # define ZEXPORT WINAPI 225 | # ifdef WIN32 226 | # define ZEXPORTVA WINAPIV 227 | # else 228 | # define ZEXPORTVA FAR CDECL 229 | # endif 230 | # endif 231 | #endif 232 | 233 | #if defined (__BEOS__) 234 | # ifdef ZLIB_DLL 235 | # ifdef ZLIB_INTERNAL 236 | # define ZEXPORT __declspec(dllexport) 237 | # define ZEXPORTVA __declspec(dllexport) 238 | # else 239 | # define ZEXPORT __declspec(dllimport) 240 | # define ZEXPORTVA __declspec(dllimport) 241 | # endif 242 | # endif 243 | #endif 244 | 245 | #ifndef ZEXTERN 246 | # define ZEXTERN extern 247 | #endif 248 | #ifndef ZEXPORT 249 | # define ZEXPORT 250 | #endif 251 | #ifndef ZEXPORTVA 252 | # define ZEXPORTVA 253 | #endif 254 | 255 | #ifndef FAR 256 | # define FAR 257 | #endif 258 | 259 | #if !defined(__MACTYPES__) 260 | typedef unsigned char Byte; /* 8 bits */ 261 | #endif 262 | typedef unsigned int uInt; /* 16 bits or more */ 263 | typedef unsigned long uLong; /* 32 bits or more */ 264 | 265 | #ifdef SMALL_MEDIUM 266 | /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ 267 | # define Bytef Byte FAR 268 | #else 269 | typedef Byte FAR Bytef; 270 | #endif 271 | typedef char FAR charf; 272 | typedef int FAR intf; 273 | typedef uInt FAR uIntf; 274 | typedef uLong FAR uLongf; 275 | 276 | #ifdef STDC 277 | typedef void const *voidpc; 278 | typedef void FAR *voidpf; 279 | typedef void *voidp; 280 | #else 281 | typedef Byte const *voidpc; 282 | typedef Byte FAR *voidpf; 283 | typedef Byte *voidp; 284 | #endif 285 | 286 | #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ 287 | # include /* for off_t */ 288 | # include /* for SEEK_* and off_t */ 289 | # ifdef VMS 290 | # include /* for off_t */ 291 | # endif 292 | # define z_off_t off_t 293 | #endif 294 | #ifndef SEEK_SET 295 | # define SEEK_SET 0 /* Seek from beginning of file. */ 296 | # define SEEK_CUR 1 /* Seek from current position. */ 297 | # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 298 | #endif 299 | #ifndef z_off_t 300 | # define z_off_t long 301 | #endif 302 | 303 | #if defined(__OS400__) 304 | # define NO_vsnprintf 305 | #endif 306 | 307 | #if defined(__MVS__) 308 | # define NO_vsnprintf 309 | # ifdef FAR 310 | # undef FAR 311 | # endif 312 | #endif 313 | 314 | /* MVS linker does not support external names larger than 8 bytes */ 315 | #if defined(__MVS__) 316 | # pragma map(deflateInit_,"DEIN") 317 | # pragma map(deflateInit2_,"DEIN2") 318 | # pragma map(deflateEnd,"DEEND") 319 | # pragma map(deflateBound,"DEBND") 320 | # pragma map(inflateInit_,"ININ") 321 | # pragma map(inflateInit2_,"ININ2") 322 | # pragma map(inflateEnd,"INEND") 323 | # pragma map(inflateSync,"INSY") 324 | # pragma map(inflateSetDictionary,"INSEDI") 325 | # pragma map(compressBound,"CMBND") 326 | # pragma map(inflate_table,"INTABL") 327 | # pragma map(inflate_fast,"INFA") 328 | # pragma map(inflate_copyright,"INCOPY") 329 | #endif 330 | 331 | #endif /* ZCONF_H */ 332 | -------------------------------------------------------------------------------- /src/geodesic.c: -------------------------------------------------------------------------------- 1 | /* 2 | Geodesic Forward and Reverse calculation functions 3 | Abstracted and adapted from PROJ-4.5.0 by David S.Register (bdbcat@yahoo.com) 4 | 5 | Original source code contains the following license: 6 | 7 | Copyright (c) 2000, Frank Warmerdam 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a 10 | copy of this software and associated documentation files (the "Software"), 11 | to deal in the Software without restriction, including without limitation 12 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 | and/or sell copies of the Software, and to permit persons to whom the 14 | Software is furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included 17 | in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | 29 | #include 30 | 31 | #ifndef PI 32 | #define PI 3.1415926535897931160E0 /* pi */ 33 | #endif 34 | #define DEGREE (PI/180.0) 35 | #define RADIAN (180.0/PI) 36 | 37 | static const double WGS84_semimajor_axis_meters = 6378137.0; // WGS84 semimajor axis 38 | static const double mercator_k0 = 0.9996; 39 | static const double WGSinvf = 298.257223563; /* WGS84 1/f */ 40 | 41 | 42 | #define DTOL 1e-12 43 | 44 | #define HALFPI 1.5707963267948966 45 | #define SPI 3.14159265359 46 | #define TWOPI 6.2831853071795864769 47 | #define ONEPI 3.14159265358979323846 48 | #define MERI_TOL 1e-9 49 | 50 | static double th1,costh1,sinth1,sina12,cosa12,M,N,c1,c2,D,P,s1; 51 | static int merid, signS; 52 | 53 | /* Input/Output from geodesic functions */ 54 | static double al12; /* Forward azimuth */ 55 | static double al21; /* Back azimuth */ 56 | static double geod_S; /* Distance */ 57 | static double phi1, lam1, phi2, lam2; 58 | 59 | static int ellipse; 60 | static double geod_f; 61 | static double geod_a; 62 | static double es, onef, f, f64, f2, f4; 63 | 64 | static double adjlon (double lon) { 65 | if (fabs(lon) <= SPI) return( lon ); 66 | lon += ONEPI; /* adjust to 0..2pi rad */ 67 | lon -= TWOPI * floor(lon / TWOPI); /* remove integral # of 'revolutions'*/ 68 | lon -= ONEPI; /* adjust back to -pi..pi rad */ 69 | return( lon ); 70 | } 71 | 72 | 73 | 74 | static void geod_inv() { 75 | double th1,th2,thm,dthm,dlamm,dlam,sindlamm,costhm,sinthm,cosdthm, 76 | sindthm,L,E,cosd,d,X,Y,T,sind,tandlammp,u,v,D,A,B; 77 | 78 | 79 | /* Stuff the WGS84 projection parameters as necessary 80 | To avoid having to include 81 | */ 82 | 83 | ellipse = 1; 84 | f = 1.0 / WGSinvf; /* WGS84 ellipsoid flattening parameter */ 85 | geod_a = WGS84_semimajor_axis_meters; 86 | 87 | es = 2 * f - f * f; 88 | onef = sqrt(1. - es); 89 | geod_f = 1 - onef; 90 | f2 = geod_f/2; 91 | f4 = geod_f/4; 92 | f64 = geod_f*geod_f/64; 93 | 94 | 95 | if (ellipse) { 96 | th1 = atan(onef * tan(phi1)); 97 | th2 = atan(onef * tan(phi2)); 98 | } else { 99 | th1 = phi1; 100 | th2 = phi2; 101 | } 102 | thm = .5 * (th1 + th2); 103 | dthm = .5 * (th2 - th1); 104 | dlamm = .5 * ( dlam = adjlon(lam2 - lam1) ); 105 | if (fabs(dlam) < DTOL && fabs(dthm) < DTOL) { 106 | al12 = al21 = geod_S = 0.; 107 | return; 108 | } 109 | sindlamm = sin(dlamm); 110 | costhm = cos(thm); sinthm = sin(thm); 111 | cosdthm = cos(dthm); sindthm = sin(dthm); 112 | L = sindthm * sindthm + (cosdthm * cosdthm - sinthm * sinthm) 113 | * sindlamm * sindlamm; 114 | d = acos(cosd = 1 - L - L); 115 | if (ellipse) { 116 | E = cosd + cosd; 117 | sind = sin( d ); 118 | Y = sinthm * cosdthm; 119 | Y *= (Y + Y) / (1. - L); 120 | T = sindthm * costhm; 121 | T *= (T + T) / L; 122 | X = Y + T; 123 | Y -= T; 124 | T = d / sind; 125 | D = 4. * T * T; 126 | A = D * E; 127 | B = D + D; 128 | geod_S = geod_a * sind * (T - f4 * (T * X - Y) + 129 | f64 * (X * (A + (T - .5 * (A - E)) * X) - 130 | Y * (B + E * Y) + D * X * Y)); 131 | tandlammp = tan(.5 * (dlam - .25 * (Y + Y - E * (4. - X)) * 132 | (f2 * T + f64 * (32. * T - (20. * T - A) 133 | * X - (B + 4.) * Y)) * tan(dlam))); 134 | } else { 135 | geod_S = geod_a * d; 136 | tandlammp = tan(dlamm); 137 | } 138 | u = atan2(sindthm , (tandlammp * costhm)); 139 | v = atan2(cosdthm , (tandlammp * sinthm)); 140 | al12 = adjlon(TWOPI + v - u); 141 | al21 = adjlon(TWOPI - v - u); 142 | } 143 | 144 | 145 | 146 | 147 | static void geod_pre(void) { 148 | 149 | /* Stuff the WGS84 projection parameters as necessary 150 | To avoid having to include 151 | */ 152 | ellipse = 1; 153 | f = 1.0 / WGSinvf; /* WGS84 ellipsoid flattening parameter */ 154 | geod_a = WGS84_semimajor_axis_meters; 155 | 156 | es = 2 * f - f * f; 157 | onef = sqrt(1. - es); 158 | geod_f = 1 - onef; 159 | f2 = geod_f/2; 160 | f4 = geod_f/4; 161 | f64 = geod_f*geod_f/64; 162 | 163 | al12 = adjlon(al12); /* reduce to +- 0-PI */ 164 | signS = fabs(al12) > HALFPI ? 1 : 0; 165 | th1 = ellipse ? atan(onef * tan(phi1)) : phi1; 166 | costh1 = cos(th1); 167 | sinth1 = sin(th1); 168 | if ((merid = fabs(sina12 = sin(al12)) < MERI_TOL)) { 169 | sina12 = 0.; 170 | cosa12 = fabs(al12) < HALFPI ? 1. : -1.; 171 | M = 0.; 172 | } else { 173 | cosa12 = cos(al12); 174 | M = costh1 * sina12; 175 | } 176 | N = costh1 * cosa12; 177 | if (ellipse) { 178 | if (merid) { 179 | c1 = 0.; 180 | c2 = f4; 181 | D = 1. - c2; 182 | D *= D; 183 | P = c2 / D; 184 | } else { 185 | c1 = geod_f * M; 186 | c2 = f4 * (1. - M * M); 187 | D = (1. - c2)*(1. - c2 - c1 * M); 188 | P = (1. + .5 * c1 * M) * c2 / D; 189 | } 190 | } 191 | if (merid) s1 = HALFPI - th1; 192 | else { 193 | s1 = (fabs(M) >= 1.) ? 0. : acos(M); 194 | s1 = sinth1 / sin(s1); 195 | s1 = (fabs(s1) >= 1.) ? 0. : acos(s1); 196 | } 197 | } 198 | 199 | 200 | static void geod_for(void) { 201 | double d,sind,u,V,X,ds,cosds,sinds,ss,de; 202 | ellipse = 1; 203 | ss = 0.; 204 | 205 | if (ellipse) { 206 | d = geod_S / (D * geod_a); 207 | if (signS) d = -d; 208 | u = 2. * (s1 - d); 209 | V = cos(u + d); 210 | X = c2 * c2 * (sind = sin(d)) * cos(d) * (2. * V * V - 1.); 211 | ds = d + X - 2. * P * V * (1. - 2. * P * cos(u)) * sind; 212 | ss = s1 + s1 - ds; 213 | } else { 214 | ds = geod_S / geod_a; 215 | if (signS) ds = - ds; 216 | } 217 | cosds = cos(ds); 218 | sinds = sin(ds); 219 | if (signS) sinds = - sinds; 220 | al21 = N * cosds - sinth1 * sinds; 221 | if (merid) { 222 | phi2 = atan( tan(HALFPI + s1 - ds) / onef); 223 | if (al21 > 0.) { 224 | al21 = PI; 225 | if (signS) 226 | de = PI; 227 | else { 228 | phi2 = - phi2; 229 | de = 0.; 230 | } 231 | } else { 232 | al21 = 0.; 233 | if (signS) { 234 | phi2 = - phi2; 235 | de = 0; 236 | } else 237 | de = PI; 238 | } 239 | } else { 240 | al21 = atan(M / al21); 241 | if (al21 > 0) 242 | al21 += PI; 243 | if (al12 < 0.) 244 | al21 -= PI; 245 | al21 = adjlon(al21); 246 | phi2 = atan(-(sinth1 * cosds + N * sinds) * sin(al21) / 247 | (ellipse ? onef * M : M)); 248 | de = atan2(sinds * sina12 , 249 | (costh1 * cosds - sinth1 * sinds * cosa12)); 250 | if (ellipse){ 251 | if (signS) 252 | de += c1 * ((1. - c2) * ds + 253 | c2 * sinds * cos(ss)); 254 | else 255 | de -= c1 * ((1. - c2) * ds - 256 | c2 * sinds * cos(ss)); 257 | } 258 | } 259 | lam2 = adjlon( lam1 + de ); 260 | } 261 | 262 | 263 | /* --------------------------------------------------------------------------------- */ 264 | /* 265 | // Given the lat/long of starting point, and traveling a specified distance, 266 | // at an initial bearing, calculates the lat/long of the resulting location. 267 | // using elliptic earth model. 268 | */ 269 | /* --------------------------------------------------------------------------------- */ 270 | 271 | void ll_gc_ll(double lat, double lon, double brg, double dist, double *dlat, double *dlon) 272 | { 273 | /* Setup the static parameters */ 274 | phi1 = lat * DEGREE; /* Initial Position */ 275 | lam1 = lon * DEGREE; 276 | al12 = brg * DEGREE; /* Forward azimuth */ 277 | geod_S = dist * 1852.0; /* Distance */ 278 | 279 | geod_pre(); 280 | geod_for(); 281 | 282 | *dlat = phi2 / DEGREE; 283 | *dlon = lam2 / DEGREE; 284 | } 285 | 286 | void ll_gc_ll_reverse(double lat1, double lon1, double lat2, double lon2, 287 | double *bearing, double *dist) 288 | { 289 | /* Setup the static parameters */ 290 | phi1 = lat1 * DEGREE; /* Initial Position */ 291 | lam1 = lon1 * DEGREE; 292 | phi2 = lat2 * DEGREE; 293 | lam2 = lon2 * DEGREE; 294 | 295 | geod_inv(); 296 | if(al12 < 0) 297 | al12 += 2*PI; 298 | 299 | if(bearing) 300 | *bearing = al12 / DEGREE; 301 | if(dist) 302 | *dist = geod_S / 1852.0; 303 | } 304 | 305 | --------------------------------------------------------------------------------