Optional
options: GeodesicOptionsresulting linestring
Calculates the distance between two positions on the earths surface
1st position
2nd position
the distance in meters
This is the wrapper-function to generate a geodesic line. It's just for future backwards-compatibility if there is another algorithm used to create the actual line.
The steps
-property is used to define the number of resulting vertices of the linestring: vertices == 1 + 2 ** (steps + 1)
The value for steps
is currently limited to 8 (513 vertices) for performance reasons until another algorithm is found.
start position
destination
resulting linestring
A geodesic line between start
and dest
is created with this recursive function.
It calculates the geodesic midpoint between start
and dest
and uses this midpoint to call itself again (twice!).
The results are then merged into one continuous linestring.
The number of resulting vertices (incl. start
and dest
) depends on the initial value for iterations
and can be calculated with: vertices == 1 + 2 ** (initialIterations + 1)
As this is an exponential function, be extra careful to limit the initial value for iterations
(8 results in 513 vertices).
start position
destination
resulting linestring
Handles splitting of circles at the antimeridian.
a linestring that resembles the geodesic circle
a multilinestring that consist of one or two linestrings
Is much (10x) faster than the previous implementation:
Benchmark (no split): splitLine x 459,044 ops/sec ±0.53% (95 runs sampled)
Benchmark (split): splitLine x 42,999 ops/sec ±0.51% (97 runs sampled)
Linestrings of a given multilinestring that cross the antimeridian will be split in two separate linestrings. This function is used to wrap lines around when they cross the antimeridian It iterates over all linestrings and reconstructs the step-by-step if no split is needed. In case the line was split, the linestring ends at the antimeridian and a new linestring is created for the remaining points of the original linestring.
another multilinestring where segments crossing the antimeridian are split
Linestrings of a given multilinestring will be wrapped (+- 360°) to show a continuous line w/o any weird discontinuities
when wrap
is set to false
in the geodesic class
another multilinestring where the points of each linestring are wrapped accordingly
Creates a circular (constant radius), closed (1st pos == last pos) geodesic linestring. The number of vertices is calculated with:
vertices == steps + 1
(where 1st == last)