ADD: new track message, Entity class and Position class
This commit is contained in:
53
libs/geographiclib/wrapper/excel/CMakeLists.txt
Normal file
53
libs/geographiclib/wrapper/excel/CMakeLists.txt
Normal file
@@ -0,0 +1,53 @@
|
||||
cmake_minimum_required (VERSION 3.13.0)
|
||||
project (cgeodesic)
|
||||
|
||||
# Set a default build type for single-configuration cmake generators if
|
||||
# no build type is set.
|
||||
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set (CMAKE_BUILD_TYPE Release)
|
||||
endif ()
|
||||
|
||||
# Make the compiler more picky.
|
||||
if (MSVC)
|
||||
string (REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
string (REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||
else ()
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
message (WARNING "This has only been tested on Windows")
|
||||
endif ()
|
||||
|
||||
find_package (GeographicLib 1.51 REQUIRED COMPONENTS SHARED)
|
||||
|
||||
set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||
add_library (${PROJECT_NAME} SHARED ${PROJECT_NAME}.cpp)
|
||||
target_link_libraries (${PROJECT_NAME} ${GeographicLib_LIBRARIES})
|
||||
|
||||
if (WIN32)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set (INSTALL_MSG
|
||||
"copy DLLs fron ${CMAKE_CFG_INTDIR} to C:\\Program Files (x86)\\Microsoft Office\\root\\Office16")
|
||||
else ()
|
||||
set (INSTALL_MSG "copy DLLs from ${CMAKE_CFG_INTDIR} to C:\\Program Files\\Microsoft Office\\root\\Office16")
|
||||
endif ()
|
||||
elseif (APPLE)
|
||||
set (INSTALL_MSG "copy DYLIBs from ${CMAKE_CFG_INTDIR} to /Library/Application Support/Microsoft")
|
||||
endif ()
|
||||
|
||||
get_target_property (GEOGRAPHICLIB_LIB_TYPE ${GeographicLib_LIBRARIES} TYPE)
|
||||
if (GEOGRAPHICLIB_LIB_TYPE STREQUAL "SHARED_LIBRARY")
|
||||
if (TRUE)
|
||||
add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E
|
||||
copy $<TARGET_FILE:${GeographicLib_LIBRARIES}> ${CMAKE_CFG_INTDIR}
|
||||
COMMENT "Installing shared library in build tree
|
||||
${INSTALL_MSG}")
|
||||
else ()
|
||||
# Set the run time path for shared libraries for non-Windows machines.
|
||||
set_target_properties (${PROJECT_NAME}
|
||||
PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
endif ()
|
||||
endif ()
|
||||
132
libs/geographiclib/wrapper/excel/Geodesic.bas
Normal file
132
libs/geographiclib/wrapper/excel/Geodesic.bas
Normal file
@@ -0,0 +1,132 @@
|
||||
Attribute VB_Name = "Geodesic"
|
||||
Option Explicit
|
||||
|
||||
' Declare the DLL functions
|
||||
|
||||
Private Declare PtrSafe Sub gdirect Lib "cgeodesic.dll" _
|
||||
(ByVal lat1 As Double, ByVal lon1 As Double, _
|
||||
ByVal azi1 As Double, ByVal s12 As Double, _
|
||||
ByRef lat2 As Double, ByRef lon2 As Double, ByRef azi2 As Double)
|
||||
|
||||
Private Declare PtrSafe Sub ginverse Lib "cgeodesic.dll" _
|
||||
(ByVal lat1 As Double, ByVal lon1 As Double, _
|
||||
ByVal lat2 As Double, ByVal lon2 As Double, _
|
||||
ByRef s12 As Double, ByRef azi1 As Double, ByRef azi2 As Double)
|
||||
|
||||
Private Declare PtrSafe Sub rdirect Lib "cgeodesic.dll" _
|
||||
(ByVal lat1 As Double, ByVal lon1 As Double, _
|
||||
ByVal azi12 As Double, ByVal s12 As Double, _
|
||||
ByRef lat2 As Double, ByRef lon2 As Double)
|
||||
|
||||
Private Declare PtrSafe Sub rinverse Lib "cgeodesic.dll" _
|
||||
(ByVal lat1 As Double, ByVal lon1 As Double, _
|
||||
ByVal lat2 As Double, ByVal lon2 As Double, _
|
||||
ByRef s12 As Double, ByRef azi12 As Double)
|
||||
|
||||
' Define the custom worksheet functions that call the DLL functions
|
||||
|
||||
Function geodesic_direct_lat2(lat1 As Double, lon1 As Double, _
|
||||
azi1 As Double, s12 As Double) As Double
|
||||
Attribute geodesic_direct_lat2.VB_Description = _
|
||||
"Solves direct geodesic problem for lat2."
|
||||
Dim lat2 As Double
|
||||
Dim lon2 As Double
|
||||
Dim azi2 As Double
|
||||
Call gdirect(lat1, lon1, azi1, s12, lat2, lon2, azi2)
|
||||
geodesic_direct_lat2 = lat2
|
||||
End Function
|
||||
|
||||
Function geodesic_direct_lon2(lat1 As Double, lon1 As Double, _
|
||||
azi1 As Double, s12 As Double) As Double
|
||||
Attribute geodesic_direct_lon2.VB_Description = _
|
||||
"Solves direct geodesic problem for lon2."
|
||||
Dim lat2 As Double
|
||||
Dim lon2 As Double
|
||||
Dim azi2 As Double
|
||||
Call gdirect(lat1, lon1, azi1, s12, lat2, lon2, azi2)
|
||||
geodesic_direct_lon2 = lon2
|
||||
End Function
|
||||
|
||||
Function geodesic_direct_azi2(lat1 As Double, lon1 As Double, _
|
||||
azi1 As Double, s12 As Double) As Double
|
||||
Attribute geodesic_direct_azi2.VB_Description = _
|
||||
"Solves direct geodesic problem for azi2."
|
||||
Dim lat2 As Double
|
||||
Dim lon2 As Double
|
||||
Dim azi2 As Double
|
||||
Call gdirect(lat1, lon1, azi1, s12, lat2, lon2, azi2)
|
||||
geodesic_direct_azi2 = azi2
|
||||
End Function
|
||||
|
||||
Function geodesic_inverse_s12(lat1 As Double, lon1 As Double, _
|
||||
lat2 As Double, lon2 As Double) As Double
|
||||
Attribute geodesic_inverse_s12.VB_Description = _
|
||||
"Solves inverse geodesic problem for s12."
|
||||
Dim s12 As Double
|
||||
Dim azi1 As Double
|
||||
Dim azi2 As Double
|
||||
Call ginverse(lat1, lon1, lat2, lon2, s12, azi1, azi2)
|
||||
geodesic_inverse_s12 = s12
|
||||
End Function
|
||||
|
||||
Function geodesic_inverse_azi1(lat1 As Double, lon1 As Double, _
|
||||
lat2 As Double, lon2 As Double) As Double
|
||||
Attribute geodesic_inverse_azi1.VB_Description = _
|
||||
"Solves inverse geodesic problem for azi1."
|
||||
Dim s12 As Double
|
||||
Dim azi1 As Double
|
||||
Dim azi2 As Double
|
||||
Call ginverse(lat1, lon1, lat2, lon2, s12, azi1, azi2)
|
||||
geodesic_inverse_azi1 = azi1
|
||||
End Function
|
||||
|
||||
Function geodesic_inverse_azi2(lat1 As Double, lon1 As Double, _
|
||||
lat2 As Double, lon2 As Double) As Double
|
||||
Attribute geodesic_inverse_azi2.VB_Description = _
|
||||
"Solves inverse geodesic problem for azi2."
|
||||
Dim s12 As Double
|
||||
Dim azi1 As Double
|
||||
Dim azi2 As Double
|
||||
Call ginverse(lat1, lon1, lat2, lon2, s12, azi1, azi2)
|
||||
geodesic_inverse_azi2 = azi2
|
||||
End Function
|
||||
|
||||
Function rhumb_direct_lat2(lat1 As Double, lon1 As Double, _
|
||||
azi12 As Double, s12 As Double) As Double
|
||||
Attribute rhumb_direct_lat2.VB_Description = _
|
||||
"Solves direct rhumb problem for lat2."
|
||||
Dim lat2 As Double
|
||||
Dim lon2 As Double
|
||||
Call rdirect(lat1, lon1, azi12, s12, lat2, lon2)
|
||||
rhumb_direct_lat2 = lat2
|
||||
End Function
|
||||
|
||||
Function rhumb_direct_lon2(lat1 As Double, lon1 As Double, _
|
||||
azi12 As Double, s12 As Double) As Double
|
||||
Attribute rhumb_direct_lon2.VB_Description = _
|
||||
"Solves direct rhumb problem for lon2."
|
||||
Dim lat2 As Double
|
||||
Dim lon2 As Double
|
||||
Call rdirect(lat1, lon1, azi12, s12, lat2, lon2)
|
||||
rhumb_direct_lon2 = lon2
|
||||
End Function
|
||||
|
||||
Function rhumb_inverse_s12(lat1 As Double, lon1 As Double, _
|
||||
lat2 As Double, lon2 As Double) As Double
|
||||
Attribute rhumb_inverse_s12.VB_Description = _
|
||||
"Solves inverse rhumb problem for s12."
|
||||
Dim s12 As Double
|
||||
Dim azi12 As Double
|
||||
Call rinverse(lat1, lon1, lat2, lon2, s12, azi12)
|
||||
rhumb_inverse_s12 = s12
|
||||
End Function
|
||||
|
||||
Function rhumb_inverse_azi12(lat1 As Double, lon1 As Double, _
|
||||
lat2 As Double, lon2 As Double) As Double
|
||||
Attribute rhumb_inverse_azi12.VB_Description = _
|
||||
"Solves inverse rhumb problem for azi12."
|
||||
Dim s12 As Double
|
||||
Dim azi12 As Double
|
||||
Call rinverse(lat1, lon1, lat2, lon2, s12, azi12)
|
||||
rhumb_inverse_azi12 = azi12
|
||||
End Function
|
||||
94
libs/geographiclib/wrapper/excel/README.md
Normal file
94
libs/geographiclib/wrapper/excel/README.md
Normal file
@@ -0,0 +1,94 @@
|
||||
# Calling the GeographicLib C++ library from Excel
|
||||
|
||||
You can call GeographicLib functions from Excel. Thanks to Thomas
|
||||
Warner <warnerta@gmail.com>, for showing me how. This prescription
|
||||
has only been tested for Excel running on a Windows machine. Please
|
||||
let me know if you figure out how to get this working on MacOS
|
||||
versions of Excel.
|
||||
|
||||
Here's the overview
|
||||
|
||||
* Write and compile little interface routines to invoke the
|
||||
functionality you want.
|
||||
|
||||
* Copy the resulting DLLs to where Excel can find them.
|
||||
|
||||
* Write an interface script in Visual Basic. This tells Visual Basic
|
||||
about your interfrace routines and it includes definitions of the actual
|
||||
functions you will see exposed in Excel.
|
||||
|
||||
Here are the step-by-step instructions for compiling and using the
|
||||
sample routines given here (which solve the direct and inverse geodesic
|
||||
problems and the corresponding rhumb line problems):
|
||||
|
||||
1. Install binary distribution for GeographicLib (either 64-bit or
|
||||
32-bit to match your version of Excel).
|
||||
|
||||
2. Install a recent version of cmake.
|
||||
|
||||
3. Start a command prompt window and run
|
||||
```bash
|
||||
mkdir BUILD
|
||||
cd BUILD
|
||||
cmake -G "Visual Studio 16" -A x64 ..
|
||||
```
|
||||
This configures your build. Any of Visual Studio 14, 15, or 16
|
||||
(corresponding the VS 2015, 2017, 2019) will work. If your Excel is
|
||||
32-bit, change `-A x64` to `-A win32`. If necessary include `-D
|
||||
CMAKE_PREFIX_PATH=DIR` to specify where GeographicLib is installed
|
||||
(specified when you ran the GeographicLib installer). Compile the
|
||||
interface with
|
||||
```bash
|
||||
cmake --build . --config Release
|
||||
```
|
||||
|
||||
4. Copy
|
||||
```bash
|
||||
Release\cgeodesic.dll # the interface routines
|
||||
Release\GeographicLib.dll # the main GeographicLib library
|
||||
```
|
||||
to the directory where the Excel executable lives. You can find this
|
||||
directory by launching Excel, launching Task Manager, right-clicking on
|
||||
Excel within Task Manager and selecting Open file location. It's
|
||||
probably something like
|
||||
```bash
|
||||
C:\Program Files\Microsoft Office\root\Office16
|
||||
```
|
||||
and you will probably need administrator privileges to do the copy.
|
||||
If it's in `Program Files (x86)`, then you have a 32-bit version of
|
||||
Excel and you need to compile your interface routines in 32-bit by
|
||||
specitying `-A win32` when you first run cmake.
|
||||
|
||||
5. Open the Excel workbook within which you would like to use the
|
||||
geodesic and rhumb routines.<br>
|
||||
Type `Alt-F11` to open Excel's Visual Basic editor.<br>
|
||||
In the left sidebar, right-click on `VBAProject (%yourworksheetname%)`
|
||||
and select Import File<br>
|
||||
Browse to `Geodesic.bas`, select it and click Open<br>
|
||||
Save your Workbook as Excel Macro-Enabled Workbook (`*.xlsm`)
|
||||
|
||||
6. You will now have 10 new functions available:
|
||||
* Solve the direct geodesic problem for
|
||||
```
|
||||
lat2: geodesic_direct_lat2(lat1, lon1, azi1, s12)
|
||||
lon2: geodesic_direct_lon2(lat1, lon1, azi1, s12)
|
||||
azi2: geodesic_direct_azi2(lat1, lon1, azi1, s12)
|
||||
```
|
||||
* Solve the inverse geodesic problem for
|
||||
```
|
||||
s12: geodesic_inverse_s12(lat1, lon1, lat2, lon2)
|
||||
azi1: geodesic_inverse_azi1(lat1, lon1, lat2, lon2)
|
||||
azi2: geodesic_inverse_azi2(lat1, lon1, lat2, lon2)
|
||||
```
|
||||
* Solve the direct rhumb problem for
|
||||
```
|
||||
lat2: rhumb_direct_lat2(lat1, lon1, azi12, s12)
|
||||
lon2: rhumb_direct_lon2(lat1, lon1, azi12, s12)
|
||||
```
|
||||
* Solve the inverse rhumb problem for
|
||||
```
|
||||
s12: rhumb_inverse_s12(lat1, lon1, lat2, lon2)
|
||||
azi12: rhumb_inverse_azi12(lat1, lon1, lat2, lon2)
|
||||
```
|
||||
Latitudes, longitudes, and azimuths are in degrees. Distances are
|
||||
in meters.
|
||||
31
libs/geographiclib/wrapper/excel/cgeodesic.cpp
Normal file
31
libs/geographiclib/wrapper/excel/cgeodesic.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "cgeodesic.h"
|
||||
#include "GeographicLib/Geodesic.hpp"
|
||||
#include "GeographicLib/Rhumb.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
void gdirect(double lat1, double lon1, double azi1, double s12,
|
||||
double& lat2, double& lon2, double& azi2) {
|
||||
GeographicLib::Geodesic::WGS84().Direct(lat1, lon1, azi1, s12,
|
||||
lat2, lon2, azi2);
|
||||
}
|
||||
|
||||
void ginverse(double lat1, double lon1, double lat2, double lon2,
|
||||
double& s12, double& azi1, double& azi2) {
|
||||
GeographicLib::Geodesic::WGS84().Inverse(lat1, lon1, lat2, lon2,
|
||||
s12, azi1, azi2);
|
||||
}
|
||||
|
||||
void rdirect(double lat1, double lon1, double azi12, double s12,
|
||||
double& lat2, double& lon2) {
|
||||
GeographicLib::Rhumb::WGS84().Direct(lat1, lon1, azi12, s12,
|
||||
lat2, lon2);
|
||||
}
|
||||
|
||||
void rinverse(double lat1, double lon1, double lat2, double lon2,
|
||||
double& s12, double& azi12) {
|
||||
GeographicLib::Rhumb::WGS84().Inverse(lat1, lon1, lat2, lon2,
|
||||
s12, azi12);
|
||||
}
|
||||
|
||||
}
|
||||
24
libs/geographiclib/wrapper/excel/cgeodesic.h
Normal file
24
libs/geographiclib/wrapper/excel/cgeodesic.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#if !defined(CGEODESIC_H)
|
||||
#define CGEODESIC_H 1
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void gdirect(double lat1, double lon1, double azi1, double s12,
|
||||
double& lat2, double& lon2, double& azi2);
|
||||
|
||||
void ginverse(double lat1, double lon1, double lat2, double lon2,
|
||||
double& s12, double& azi1, double& azi2);
|
||||
|
||||
void rdirect(double lat1, double lon1, double azi12, double s12,
|
||||
double& lat2, double& lon2);
|
||||
|
||||
void rinverse(double lat1, double lon1, double lat2, double lon2,
|
||||
double& s12, double& azi12);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CGEODESIC_H */
|
||||
Reference in New Issue
Block a user