You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A golang port of [geographiclib](https://geographiclib.sourceforge.io/).
6
6
7
-
###Aims
7
+
## Aims
8
8
- Mimic the [rust port](https://github.com/georust/geographiclib-rs), the [python port](https://pypi.org/project/geographiclib/), and the [java port](https://github.com/geographiclib/geographiclib-java) as closely as possible
9
9
- Test as extensively as possible. Match all the rust, python, and java tests
10
10
11
-
### Progress
11
+
## Outline:
12
+
-[Background: Geodesics on an Ellipsoid](#background-geodesics-on-an-ellipsoid)
- Given a latitude/longitude point, an angle from due North, and a distance, calculate the latitude/longitude of the new point. This is calculated with any function starting with `DirectCalc...`
22
+
- Given two latitude/longitude points, calculate the distance between them, and the angles formed from due North to the line connecting the two points. This is calculated with any function starting with `InverseCalc...`
23
+
- Given a set of points or edges that form a polygon, calculate the area of said polygon. This is done by calling `NewPolygonArea()`, adding the points, and finally calling the `Compute()` method to get both the area and the perimeter of the polygon.
24
+
- Given a set of points or edges that form a polyline (a set of connected lines), calculate the perimeter of the line. This is done by calling `NewPolygonArea()` with `is_polyline` set to true, adding the points, and finally calling the `Compute()` method to get the length of the lines.
25
+
26
+
## Long Explanation of Library
27
+
This section is copied from the [python documentation](https://geographiclib.sourceforge.io/Python/doc/geodesics.html)
28
+
### Introduction
29
+
Consider an ellipsoid of revolution with equatorial radius $a$, polar semi-axis $b$, and flattening $f = (a − b)/a$ . Points on the surface of the ellipsoid are characterized by their latitude $\phi$ and longitude $\lambda$. (Note that latitude here means the geographical latitude, the angle between the normal to the ellipsoid and the equatorial plane).
30
+
31
+
The shortest path between two points on the ellipsoid at $(\phi_1, \lambda_1)$ and $(\phi_2, \lambda_2)$ is called the geodesic. Its length is $s_{12}$ and the geodesic from point 1 to point 2 has forward azimuths $\alpha_1$ and $\alpha_2$ at the two end points. In this figure, we have $\lambda_{12} = \lambda_2 − \lambda_1$.
32
+
33
+

34
+
A geodesic can be extended indefinitely by requiring that any sufficiently small segment is a shortest path; geodesics are also the straightest curves on the surface.
35
+
36
+
### Solution of Geodesic Problems
37
+
Traditionally two geodesic problems are considered:
38
+
39
+
- the direct problem — given $\phi_1$, $\lambda_1$, $\alpha_1$, $s_{12}$, determine $\phi_2$, $\lambda_2$, and $\alpha_2$; this is solved by the various functions starting with `DirectCalc...`
40
+
41
+
- the inverse problem — given $\phi_1$, $\lambda_1$, $\phi_2$, $\lambda_2$, determine $s_{12}$, $\alpha_1$, and $\alpha_2$; this is solved by the various functions starting with `InverseCalc...`
42
+
43
+
### Aditional Properties
44
+
The routines also calculate several other quantities of interest
45
+
46
+
- $S_{12}$ is the area between the geodesic from point 1 to point 2 and the equator; i.e., it is the area, measured counter-clockwise, of the quadrilateral with corners $(\phi_1,\lambda_1), (0,\lambda_1), (0,\lambda_2)$, and $(\phi_2,\lambda_2)$. It is given in $\text{meters}^2$.
47
+
48
+
- $m_{12}$, the reduced length of the geodesic is defined such that if the initial azimuth is perturbed by $\delta\alpha_1$ (radians) then the second point is displaced by $m_{12}\ \delta\alpha_1$ in the direction perpendicular to the geodesic. $m_{12}$ is given in meters. On a curved surface the reduced length obeys a symmetry relation, $m_{12} + m_{21} = 0$. On a flat surface, we have $m_{12} = s_{12}$.
49
+
50
+
- $M_{12}$ and $M_{21}$ are geodesic scales. If two geodesics are parallel at point 1 and separated by a small distance $\delta t$, then they are separated by a distance $M_{12} \delta t$ at point 2. $M_{21}$ is defined similarly (with the geodesics being parallel to one another at point 2). $M_{12}$ and $M_{21}$ are dimensionless quantities. On a flat surface, we have $M_{12} = M_{21} = 1$.
51
+
52
+
- $\sigma_{12}$ is the arc length on the auxiliary sphere. This is a construct for converting the problem to one in spherical trigonometry. The spherical arc length from one equator crossing to the next is always $180 \degree$.
53
+
54
+
If points 1, 2, and 3 lie on a single geodesic, then the following addition rules hold:
The shortest distance found by solving the inverse problem is (obviously) uniquely defined. However, in a few special cases there are multiple azimuths which yield the same shortest distance. Here is a catalog of those cases:
66
+
67
+
- $\phi_1 = −\phi_2$ (with neither point at a pole). If $\alpha_1 = \alpha_2$, the geodesic is unique. Otherwise there are two geodesics and the second one is obtained by setting
(This occurs when the longitude difference is near $\pm 180 \degree$ for oblate ellipsoids.)
73
+
- $\lambda_2 = \lambda_1 \pm 180 \degree$ (with neither point at a pole). If $\alpha_1 = 0 \degree$ or $\pm 180 \degree$, the geodesic is unique. Otherwise there are two geodesics and the second one is obtained by setting
(This occurs when $\phi_2$ is near $−\phi_1$ for prolate ellipsoids.)
78
+
- Points 1 and 2 at opposite poles. There are infinitely many geodesics which can be generated by setting $[\alpha1,\alpha2] \leftarrow [\alpha1,\alpha2] + [\delta,−\delta]$, for arbitrary $\delta$. (For spheres, this prescription applies when points 1 and 2 are antipodal.)
79
+
- $s_{12} = 0$ (coincident points). There are infinitely many geodesics which can be generated by setting $[\alpha1,\alpha2] \leftarrow [\alpha1,\alpha2] + [\delta,\delta]$, for arbitrary $\delta$.
80
+
81
+
82
+
### Area of a Polygon
83
+
The area of a geodesic polygon can be determined by summing $S_{12}$ for successive edges of the polygon ($S_{12}$ is negated so that clockwise traversal of a polygon gives a positive area). However, if the polygon encircles a pole, the sum must be adjusted by $\pm A/2$, where $A$ is the area of the full ellipsoid, with the sign chosen to place the result in $(-A/2, A/2]$.
84
+
85
+
## The library Interface
86
+
87
+
## GeographicLib API
88
+
89
+
## Examples
90
+
-[ ] Add Examples to README
91
+
-[ ] Examples of direct case on Earth
92
+
-[ ] Examples of direct case on Mars
93
+
-[ ] Examples of inverse case
94
+
-[ ] Examples of calculating an area
95
+
96
+
97
+
## Progress
12
98
-[X] Go translation
13
99
-[X] Geomath
14
100
-[X] Geomath tests
@@ -21,14 +107,4 @@ A golang port of [geographiclib](https://geographiclib.sourceforge.io/).
21
107
-[X] Geodisic Inverse tests
22
108
-[X] Polygon Area
23
109
-[X] Polygon Area tests
24
-
-[X] Add DirectAndInverse interface
25
-
-[ ] Explain it in README
26
-
-[ ] Add description of the direct and inverse problem, with pictures
27
-
-[ ] Add Examples to README
28
-
-[ ] Examples of direct case on Earth
29
-
-[ ] Examples of direct case on Mars
30
-
-[ ] Examples of inverse case
31
-
-[ ] Examples of calculating an area
32
-
-[ ] Consider switching from having units in names to using github.com/golang/geo/
33
-
which uses types for units. It would perhaps involve more allocations; need to do some
34
-
testing.
110
+
-[ ] Consider switching from having units in names to using github.com/golang/geo/ which uses types for units. It would perhaps involve more allocations; need to do some testing.
0 commit comments