

Geocalc — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/README.md#L1 "View Source")

Geocalc

===========================================================================================================

[![Build Status](https://github.com/yltsrc/geocalc/actions/workflows/elixir.yml/badge.svg?branch=master)](https://github.com/yltsrc/geocalc/actions/workflows/elixir.yml?query=branch%3Amaster)

[![Module Version](https://img.shields.io/hexpm/v/geocalc.svg)](https://hex.pm/packages/geocalc)

[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/geocalc/)

[![Total Download](https://img.shields.io/hexpm/dt/geocalc.svg)](https://hex.pm/packages/geocalc)

[![License](https://img.shields.io/hexpm/l/geocalc.svg)](https://github.com/yltsrc/geocalc/blob/master/LICENSE.md)

[![Last Updated](https://img.shields.io/github/last-commit/yltsrc/geocalc.svg)](https://github.com/yltsrc/geocalc/commits/master)

Calculate distance, bearing and more between latitude/longitude points.

All the formulas are adapted from

<http://www.movable-type.co.uk/scripts/latlong.html>.

Area calculations are implemented from

[ETSI EN 302 931 v1.1.1](https://www.etsi.org/deliver/etsi_en/302900_302999/302931/01.01.01_60/en_302931v010101p.pdf) standard.

[installation](#installation)

 Installation

--------------------------------------------

First, add `:geocalc` to your `mix.exs` dependencies:

```

def deps do

 [

 {:geocalc, "~> 0.8"}

 ]

end

```

And then fetch your dependencies:

```

$ mix deps.get

```

[usage](#usage)

 Usage

-----------------------

### 

[calculate-distance-in-meters-between-2-points](#calculate-distance-in-meters-between-2-points)

 Calculate distance (in meters) between 2 points

```

Geocalc.distance\_between([50.0663889, -5.7147222], [58.6438889, -3.07])

# => 968853.5464535094

```

### 

[calculate-if-point-is-inside-a-circle-given-by-a-center-point-and-a-radius-in-meters](#calculate-if-point-is-inside-a-circle-given-by-a-center-point-and-a-radius-in-meters)

 Calculate if point is inside a circle given by a center point and a radius (in meters)

```

san\_juan = [18.4655, 66.1057]

puerto\_rico = [18.2208, 66.5901]

Geocalc.within?(170\_000, san\_juan, puerto\_rico)

# => true

```

### 

[get-destination-point-given-distance-meters-from-start-and-end-point](#get-destination-point-given-distance-meters-from-start-and-end-point)

 Get destination point given distance (meters) from start and end point

```

Geocalc.destination\_point([50.0663889, -5.7147222], [58.6438889, -3.07], 100\_000)

# => {:ok, [50.95412546615634, -5.488452905258299]}

```

### 

[get-destination-point-given-distance-meters-and-bearing-from-start-point](#get-destination-point-given-distance-meters-and-bearing-from-start-point)

 Get destination point given distance (meters) and bearing from start point

```

Geocalc.destination\_point([50.0663889, -5.7147222], 2.123, 100\_000)

# => {:ok, [49.58859917965055, -4.533613856982982]}

```

### 

[calculate-bearing-from-start-and-end-points](#calculate-bearing-from-start-and-end-points)

 Calculate bearing from start and end points

```

Geocalc.bearing([50.0663889, -5.7147222], [58.6438889, -3.07])

# => 0.1591708517503001

```

### 

[get-intersection-point-given-start-points-and-bearings](#get-intersection-point-given-start-points-and-bearings)

 Get intersection point given start points and bearings

```

Geocalc.intersection\_point([50.0663889, -5.7147222], 2.123, [55.0663889, -15.7147222], 2.123)

# => {:ok, [48.04228582473962, -1.0347033632388496]}

Geocalc.intersection\_point([50.0663889, -5.7147222], 2.123, [50.0663889, -5.7147222], 2.123)

# => {:error, "No intersection point found"}

```

### 

[get-bounding-box-from-a-point-and-radius](#get-bounding-box-from-a-point-and-radius)

 Get bounding box from a point and radius

```

berlin = [52.5075419, 13.4251364]

radius = 10\_000

Geocalc.bounding\_box(berlin, radius)

# => [[52.417520954378574, 13.277235453275123], [52.59756284562143, 13.573037346724874]]

```

### 

[get-bounding-box-from-a-list-of-points](#get-bounding-box-from-a-list-of-points)

 Get bounding box from a list of points

```

berlin = [52.5075419, 13.4251364]

rome = [41.9102415, 12.3959161]

minsk = [53.8838884, 27.5949741]

Geocalc.bounding\_box\_for\_points([berlin, rome, minsk])

# => [[41.9102415, 12.3959161], [53.8838884, 27.5949741]]

```

### 

[get-geographical-center-point](#get-geographical-center-point)

 Get geographical center point

```

berlin = [52.5075419, 13.4251364]

london = [51.5286416, -0.1015987]

rome = [41.9102415, 12.3959161]

Geocalc.geographic\_center([berlin, london, rome])

# => [48.810406537400254, 8.785092188535195]

```

### 

[get-maximum-latitude-reached-when-travelling-on-a-great-circle-on-given-bearing-from-the-point](#get-maximum-latitude-reached-when-travelling-on-a-great-circle-on-given-bearing-from-the-point)

 Get maximum latitude reached when travelling on a great circle on given bearing from the point

```

berlin = [52.5075419, 13.4251364]

paris = [48.8588589, 2.3475569]

bearing = Geocalc.bearing(berlin, paris)

Geocalc.max\_latitude(berlin, bearing)

# => 55.953467429882835

```

### 

[get-distance-from-the-point-to-great-circle-defined-by-start-point-and-end-point](#get-distance-from-the-point-to-great-circle-defined-by-start-point-and-end-point)

 Get distance from the point to great circle defined by start-point and end-point

```

berlin = [52.5075419, 13.4251364]

london = [51.5286416, -0.1015987]

paris = [48.8588589, 2.3475569]

Geocalc.cross\_track\_distance\_to(berlin, london, paris)

# => -877680.2992295175

```

### 

[calculate-how-far-the-point-is-along-a-path-from-from-start-point-heading-towards-end-point](#calculate-how-far-the-point-is-along-a-path-from-from-start-point-heading-towards-end-point)

 Calculate how far the point is along a path from from start-point, heading towards end-point

```

berlin = [52.5075419, 13.4251364]

london = [51.5286416, -0.1015987]

paris = [48.8588589, 2.3475569]

Geocalc.along\_track\_distance\_to(berlin, london, paris)

# => 310412.6031976226

```

### 

[get-the-pair-of-meridians-at-which-a-great-circle-defined-by-two-points-crosses-the-given-latitude](#get-the-pair-of-meridians-at-which-a-great-circle-defined-by-two-points-crosses-the-given-latitude)

 Get the pair of meridians at which a great circle defined by two points crosses the given latitude

```

berlin = [52.5075419, 13.4251364]

paris = [48.8588589, 2.3475569]

Geocalc.crossing\_parallels(berlin, paris, 12.3456)

# => {:ok, 123.179463369946, -39.81144878508576}

```

### 

[convert-degrees-to-radians](#convert-degrees-to-radians)

 Convert degrees to radians

```

Geocalc.degrees\_to\_radians(245)

# => -2.007128639793479

```

### 

[convert-radians-to-degrees](#convert-radians-to-degrees)

 Convert radians to degrees

```

Geocalc.radians\_to\_degrees(1.234)

# => 70.70299191914359

```

[geocalc-shape](#geocalc-shape)

 Geocalc.Shape

-----------------------------------------------

Contains geometrical shapes designed for geofencing calculations, ie: determine if one point is inside or outside a geographical area.

Three area shapes are defined:

* Circle

* Rectangle

* Ellipse

### 

[check-if-a-point-is-inside-an-area](#check-if-a-point-is-inside-an-area)

 Check if a point is inside an area

```

area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 1000}

point = %{lat: 48.856612, lng: 2.3522217}

Geocalc.in\_area?(area, point)

# => true

```

### 

[check-if-a-point-is-outside-an-area](#check-if-a-point-is-outside-an-area)

 Check if a point is outside an area

```

area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 10}

point = %{lat: 48.856418, lng: 2.365871}

Geocalc.outside\_area?(area, point)

# => true

```

### 

[check-if-a-point-is-at-the-border-of-an-area](#check-if-a-point-is-at-the-border-of-an-area)

 Check if a point is at the border of an area

```

area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 1000}

point = %{lat: 48.856418, lng: 2.365871}

Geocalc.at\_area\_border?(area, point)

# => true

```

### 

[check-if-a-point-at-the-center-point-of-an-area](#check-if-a-point-at-the-center-point-of-an-area)

 Check if a point at the center point of an area

```

area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 100}

point = %{lat: 48.856614, lng: 2.3522219}

Geocalc.at\_center\_point?(area, point)

# => true

```

[geocalc-point-protocol](#geocalc-point-protocol)

 Geocalc.Point protocol

--------------------------------------------------------------------------

Everything which implements [`Geocalc.Point`](Geocalc.Point.html) protocol can be passed as a point

argument for any function in this library.

We already have implementations for [`List`](https://hexdocs.pm/elixir/List.html), [`Tuple`](https://hexdocs.pm/elixir/Tuple.html) and [`Map`](https://hexdocs.pm/elixir/Map.html).

You can define your own implementations if you need, everything we need to know

to do calculations are `latitude` and `longitude`.

[geocalc-dms](#geocalc-dms)

 Geocalc.DMS

-----------------------------------------

[`Geocalc.DMS`](Geocalc.DMS.html) is a struct which contains degrees, minutes and seconds, which also can be used in [`Geocalc.Point`](Geocalc.Point.html).

### 

[additionally-now-there-is-an-options-to-convert-geocalc-dms-to-decimal-degrees](#additionally-now-there-is-an-options-to-convert-geocalc-dms-to-decimal-degrees)

 Additionally now there is an options to convert [`Geocalc.DMS`](Geocalc.DMS.html) to decimal degrees.

```

dms = %Geocalc.DMS{hours: 13, minutes: 31, seconds: 59.998, direction: "N"}

Geocalc.DMS.to\_degrees(dms)

# => 13.533332777777778

```

[benchmark](#benchmark)

 Benchmark

-----------------------------------

Run this command to generate the benchmark result:

```

$ MIX\_ENV=bench mix bench

Settings:

 duration: 1.0 s

## GeocalcBench

[03:00:36] 1/10: bearing

[03:00:37] 2/10: bounding box

[03:00:39] 3/10: bounding box for points

[03:00:53] 3/10: degrees to radians

[03:01:03] 5/10: destination point

[03:01:06] 6/10: distance between

[03:01:08] 7/10: intersection point

[03:01:11] 8/10: radians to degrees

[03:01:13] 9/10: within?/2

[03:01:15] 10/10: within?/3

Finished in 31.32 seconds

## GeocalcBench

benchmark name iterations average time

degrees to radians 100000000 0.09 µs/op

radians to degrees 10000000 0.17 µs/op

bounding box 1000000 1.51 µs/op

bearing 1000000 1.65 µs/op

destination point 1000000 1.89 µs/op

within?/3 1000000 2.10 µs/op

distance between 1000000 2.33 µs/op

intersection point 500000 4.96 µs/op

bounding box for points 500000 7.26 µs/op

within?/2 100000 12.17 µs/op

```

[copyright-and-license](#copyright-and-license)

 Copyright and License

-----------------------------------------------------------------------

Copyright (c) 2015 Yura Tolstik

Released under the MIT License, which can be found in the repository in [LICENSE.md](license.html).

[← Previous Page

 

License](license.html)





Geocalc — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L1 "View Source")

Geocalc

(Geocalc v0.8.5)

=================================================================================================================================

Calculate distance, bearing and more between Latitude/Longitude points.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[point\_or\_bearing()](#t:point_or_bearing/0)

[Functions](#functions)

------------------------

[along\_track\_distance\_to(point, path\_start\_point, path\_end\_point)](#along_track_distance_to/3)

Calculates how far the point is along a path from from start-point, heading

towards end-point.

[area\_size(area)](#area_size/1)

Calculate the given `area` surface.

[at\_area\_border?(area, point)](#at_area_border?/2)

Check if a `point` is at the border of `area`.

[at\_center\_point?(area, point)](#at_center_point?/2)

Check if a `point` at the center point of `area`.

[bearing(point\_1, point\_2)](#bearing/2)

Calculates bearing.

[bounding\_box(point, radius\_in\_m)](#bounding_box/2)

Calculates a bounding box around a point with a radius in meters.

[bounding\_box\_for\_points(points)](#bounding_box_for_points/1)

Calculates a bounding box for a list of points.

[contains\_point?(bounding\_box, point)](#contains_point?/2)

Returns `true` if the bounding box contains the given point.

[cross\_track\_distance\_to(point, path\_start\_point, path\_end\_point)](#cross_track_distance_to/3)

Compute distance from the point to great circle defined by start-point

and end-point.

[crossing\_parallels(point\_1, path\_2, latitude)](#crossing_parallels/3)

Calculates the pair of meridians at which a great circle defined by two points

crosses the given latitude.

[degrees\_to\_radians(degrees)](#degrees_to_radians/1)

Converts degrees to radians.

[destination\_point(point\_1, point\_2, distance)](#destination_point/3)

Finds point between start and end points in direction to end point

with given distance (in meters).

[distance\_between(point\_1, point\_2)](#distance_between/2)

Calculates distance between 2 points.

[extend\_bounding\_box(bounding\_box\_1, bounding\_box\_2)](#extend_bounding_box/2)

Extend the bounds to contain the given bounds.

[geographic\_center(points)](#geographic_center/1)

Compute the geographic center (aka geographic midpoint, center of gravity)

for an array of geocoded objects and/or [lat,lon] arrays (can be mixed).

[in\_area?(area, point)](#in_area?/2)

Check if a `point` is inside `area`.

[intersection\_point(point\_1, bearing\_1, point\_2, bearing\_2)](#intersection_point/4)

Finds intersection point from start points with given bearings.

[intersects\_bounding\_box?(bounding\_box\_1, bounding\_box\_2)](#intersects_bounding_box?/2)

Returns `true` if the bounding box intersects the given bounds.

[max\_latitude(point, bearing)](#max_latitude/2)

Calculates maximum latitude reached when travelling on a great circle on given

bearing from the point (Clairaut's formula). Negate the result for the

minimum latitude (in the Southern hemisphere).

[outside\_area?(area, point)](#outside_area?/2)

Check if a `point` is outside `area`.

[overlaps\_bounding\_box?(bounding\_box\_1, bounding\_box\_2)](#overlaps_bounding_box?/2)

Returns `true` if the bounding box overlaps the given bounds.

[radians\_to\_degrees(radians)](#radians_to_degrees/1)

Converts radians to degrees.

[within?(poly, point)](#within?/2)

Calculates if a point is within a polygon.

[within?(radius, center, point)](#within?/3)

Calculates if a point is within radius of the center of a circle.

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:point_or_bearing/0 "Link to this type")

point\_or\_bearing()

====================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L158 "View Source")

```

@type point_or_bearing() :: [Geocalc.Point.t](Geocalc.Point.html#t:t/0)() | [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#along_track_distance_to/3 "Link to this function")

along\_track\_distance\_to(point, path\_start\_point, path\_end\_point)

=======================================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L440 "View Source")

```

@spec along_track_distance_to([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()) ::

  [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates how far the point is along a path from from start-point, heading

towards end-point.

That is, if a perpendicular is drawn from the point to the (great circle)

path, the along-track distance is the distance from the start point to where

the perpendicular crosses the path.

[examples](#along_track_distance_to/3-examples)

 Examples

----------------------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> london = [51.5286416, -0.1015987]

iex> paris = [48.8588589, 2.3475569]

iex> Geocalc.along\_track\_distance\_to(berlin, london, paris)

310412.6031976226

```

[Link to this function](#area_size/1 "Link to this function")

area\_size(area)

================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L558 "View Source")

```

@spec area_size(

  [Geocalc.Shape.Circle.t](Geocalc.Shape.Circle.html#t:t/0)()

  | [Geocalc.Shape.Rectangle.t](Geocalc.Shape.Rectangle.html#t:t/0)()

  | [Geocalc.Shape.Ellipse.t](Geocalc.Shape.Ellipse.html#t:t/0)()

) ::

  [non\_neg\_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()

```

Calculate the given `area` surface.

Returns `area` surface in square meters.

[examples](#area_size/1-examples)

 Examples

--------------------------------------------

```

iex> area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 1000}

iex> Geocalc.area\_size(area)

3141592.653589793

```

[Link to this function](#at_area_border?/2 "Link to this function")

at\_area\_border?(area, point)

==============================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L522 "View Source")

```

@spec at_area_border?(

  [Geocalc.Shape.Circle.t](Geocalc.Shape.Circle.html#t:t/0)()

  | [Geocalc.Shape.Rectangle.t](Geocalc.Shape.Rectangle.html#t:t/0)()

  | [Geocalc.Shape.Ellipse.t](Geocalc.Shape.Ellipse.html#t:t/0)(),

  [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()

) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Check if a `point` is at the border of `area`.

Returns true if at border, false if not.

[examples](#at_area_border?/2-examples)

 Examples

--------------------------------------------------

```

iex> area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 1000}

iex> point = %{lat: 48.856418, lng: 2.365871}

iex> Geocalc.at\_area\_border?(area, point)

true

```

[Link to this function](#at_center_point?/2 "Link to this function")

at\_center\_point?(area, point)

===============================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L541 "View Source")

```

@spec at_center_point?(

  [Geocalc.Shape.Circle.t](Geocalc.Shape.Circle.html#t:t/0)()

  | [Geocalc.Shape.Rectangle.t](Geocalc.Shape.Rectangle.html#t:t/0)()

  | [Geocalc.Shape.Ellipse.t](Geocalc.Shape.Ellipse.html#t:t/0)(),

  [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()

) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Check if a `point` at the center point of `area`.

Returns true if at center point, false if not

[examples](#at_center_point?/2-examples)

 Examples

---------------------------------------------------

```

iex> area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 100}

iex> point = %{lat: 48.856614, lng: 2.3522219}

iex> Geocalc.at\_center\_point?(area, point)

true

```

[Link to this function](#bearing/2 "Link to this function")

bearing(point\_1, point\_2)

===========================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L114 "View Source")

```

@spec bearing([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()) :: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates bearing.

Returns radians.

[examples](#bearing/2-examples)

 Examples

------------------------------------------

```

iex> berlin = {52.5075419, 13.4251364}

iex> paris = {48.8588589, 2.3475569}

iex> Geocalc.bearing(berlin, paris)

-1.9739245359361486

iex> Geocalc.bearing(paris, berlin)

1.0178267866082613

iex> berlin = %{lat: 52.5075419, lon: 13.4251364}

iex> paris = %{latitude: 48.8588589, longitude: 2.3475569}

iex> Geocalc.bearing(berlin, paris)

-1.9739245359361486

```

[Link to this function](#bounding_box/2 "Link to this function")

bounding\_box(point, radius\_in\_m)

===================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L225 "View Source")

```

@spec bounding_box([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates a bounding box around a point with a radius in meters.

Returns an array with 2 points (list format). The bottom left (southwest) point,

and the top-right (northeast) one.

[examples](#bounding_box/2-examples)

 Examples

-----------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> radius = 10\_000

iex> Geocalc.bounding\_box(berlin, radius)

[[52.417520954378574, 13.277235453275123], [52.59756284562143, 13.573037346724874]]

```

[Link to this function](#bounding_box_for_points/1 "Link to this function")

bounding\_box\_for\_points(points)

==================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L245 "View Source")

```

@spec bounding_box_for_points([list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates a bounding box for a list of points.

Returns an array with 2 points (list format). The bottom left (southwest) point,

and the top-right (northeast) one.

[examples](#bounding_box_for_points/1-examples)

 Examples

----------------------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> london = [51.5286416, -0.1015987]

iex> paris = [48.8588589, 2.3475569]

iex> Geocalc.bounding\_box\_for\_points([berlin, london, paris])

[[48.8588589, -0.1015987], [52.5075419, 13.4251364]]

```

[Link to this function](#contains_point?/2 "Link to this function")

contains\_point?(bounding\_box, point)

======================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L280 "View Source")

```

@spec contains_point?([list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Returns `true` if the bounding box contains the given point.

[examples](#contains_point?/2-examples)

 Examples

--------------------------------------------------

```

iex> germany = [[47.27, 5.87], [55.1, 15.04]]

iex> berlin = [52.5075419, 13.4251364]

iex> Geocalc.contains\_point?(germany, berlin)

true

```

[Link to this function](#cross_track_distance_to/3 "Link to this function")

cross\_track\_distance\_to(point, path\_start\_point, path\_end\_point)

=======================================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L418 "View Source")

```

@spec cross_track_distance_to([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()) ::

  [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Compute distance from the point to great circle defined by start-point

and end-point.

Returns distance in meters.

[examples](#cross_track_distance_to/3-examples)

 Examples

----------------------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> london = [51.5286416, -0.1015987]

iex> paris = [48.8588589, 2.3475569]

iex> Geocalc.cross\_track\_distance\_to(berlin, london, paris)

-877680.2992295175

```

[Link to this function](#crossing_parallels/3 "Link to this function")

crossing\_parallels(point\_1, path\_2, latitude)

================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L465 "View Source")

```

@spec crossing_parallels([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [tuple](https://hexdocs.pm/elixir/typespecs.html#basic-types)()

```

Calculates the pair of meridians at which a great circle defined by two points

crosses the given latitude.

Returns longitudes.

[examples](#crossing_parallels/3-examples)

 Examples

-----------------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> paris = [48.8588589, 2.3475569]

iex> Geocalc.crossing\_parallels(berlin, paris, 12.3456)

{:ok, 123.179463369946, -39.81144878508576}

iex> point\_1 = %{lat: 0, lng: 0}

iex> point\_2 = %{lat: -180, lng: -90}

iex> latitude = 45.0

iex> Geocalc.crossing\_parallels(point\_1, point\_2, latitude)

{:error, "Not found"}

```

[Link to this function](#degrees_to_radians/1 "Link to this function")

degrees\_to\_radians(degrees)

=============================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L374 "View Source")

```

@spec degrees_to_radians([number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Converts degrees to radians.

Returns radians.

[examples](#degrees_to_radians/1-examples)

 Examples

-----------------------------------------------------

```

iex> Geocalc.degrees\_to\_radians(143.67156782221554)

2.5075419

iex> Geocalc.degrees\_to\_radians(-10.735322818996854)

-0.18736672945597435

```

[Link to this function](#destination_point/3 "Link to this function")

destination\_point(point\_1, point\_2, distance)

================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L160 "View Source")

```

@spec destination_point([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [point\_or\_bearing](#t:point_or_bearing/0)(), [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [tuple](https://hexdocs.pm/elixir/typespecs.html#basic-types)()

```

Finds point between start and end points in direction to end point

with given distance (in meters).

Finds point from start point with given distance (in meters) and bearing.

Returns array with latitude and longitude.

[examples](#destination_point/3-examples)

 Examples

----------------------------------------------------

Find destination point by bearing:

```

iex> berlin = [52.5075419, 13.4251364]

iex> paris = [48.8588589, 2.3475569]

iex> bearing = Geocalc.bearing(berlin, paris)

iex> distance = 400\_000

iex> Geocalc.destination\_point(berlin, bearing, distance)

{:ok, [50.97658022467569, 8.165929595956982]}

iex> zero\_point = {0.0, 0.0}

iex> equator\_degrees = 90.0

iex> equator\_bearing = Geocalc.degrees\_to\_radians(equator\_degrees)

iex> distance = 1\_000\_000

iex> Geocalc.destination\_point(zero\_point, equator\_bearing, distance)

{:ok, [5.484172965344896e-16, 8.993216059187306]}

iex> berlin = %{lat: 52.5075419, lon: 13.4251364}

iex> bearing = -1.9739245359361486

iex> distance = 100\_000

iex> Geocalc.destination\_point(berlin, bearing, distance)

{:ok, [52.147030316318904, 12.076990111001148]}

```

Find destination point by point:

```

iex> berlin = [52.5075419, 13.4251364]

iex> paris = [48.8588589, 2.3475569]

iex> distance = 250\_000

iex> Geocalc.destination\_point(berlin, paris, distance)

{:ok, [51.578054644172525, 10.096282782248409]}

```

[Link to this function](#distance_between/2 "Link to this function")

distance\_between(point\_1, point\_2)

=====================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L34 "View Source")

```

@spec distance_between([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()) :: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates distance between 2 points.

Returns distance in meters.

[examples](#distance_between/2-examples)

 Examples

---------------------------------------------------

```

iex> berlin = [Decimal.new("52.5075419"), Decimal.new("13.4251364")]

iex> paris = [48.8588589, 2.3475569]

iex> Geocalc.distance\_between(berlin, paris)

878327.4291149472

iex> Geocalc.distance\_between(paris, berlin)

878327.4291149472

iex> berlin = %{lat: 52.5075419, lon: 13.4251364}

iex> london = %{lat: Decimal.new("51.5286416"), lng: Decimal.new("-0.1015987")}

iex> paris = %{latitude: 48.8588589, longitude: 2.3475569}

iex> Geocalc.distance\_between(berlin, paris)

878327.4291149472

iex> Geocalc.distance\_between(paris, london)

344229.88946533133

```

[Link to this function](#extend_bounding_box/2 "Link to this function")

extend\_bounding\_box(bounding\_box\_1, bounding\_box\_2)

=========================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L264 "View Source")

```

@spec extend_bounding_box([list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(), [list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Extend the bounds to contain the given bounds.

Returns an array with 2 points (list format). The bottom left (southwest) point,

and the top-right (northeast) one.

[examples](#extend_bounding_box/2-examples)

 Examples

------------------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> london = [51.5286416, -0.1015987]

iex> Geocalc.extend\_bounding\_box([berlin, berlin], [london, london])

[[51.5286416, -0.1015987], [52.5075419, 13.4251364]]

```

[Link to this function](#geographic_center/1 "Link to this function")

geographic\_center(points)

==========================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L336 "View Source")

```

@spec geographic_center([list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()

```

Compute the geographic center (aka geographic midpoint, center of gravity)

for an array of geocoded objects and/or [lat,lon] arrays (can be mixed).

Any objects missing coordinates are ignored. Follows the procedure

documented at <http://www.geomidpoint.com/calculation.html>.

[examples](#geographic_center/1-examples)

 Examples

----------------------------------------------------

```

iex> point\_1 = [0, 0]

iex> point\_2 = [0, 3]

iex> Geocalc.geographic\_center([point\_1, point\_2])

[0.0, 1.5]

```

[Link to this function](#in_area?/2 "Link to this function")

in\_area?(area, point)

======================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L484 "View Source")

```

@spec in_area?(

  [Geocalc.Shape.Circle.t](Geocalc.Shape.Circle.html#t:t/0)()

  | [Geocalc.Shape.Rectangle.t](Geocalc.Shape.Rectangle.html#t:t/0)()

  | [Geocalc.Shape.Ellipse.t](Geocalc.Shape.Ellipse.html#t:t/0)(),

  [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()

) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Check if a `point` is inside `area`.

Returns true if inside area, false if not.

[examples](#in_area?/2-examples)

 Examples

-------------------------------------------

```

iex> area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 1000}

iex> point = %{lat: 48.856612, lng: 2.3522217}

iex> Geocalc.in\_area?(area, point)

true

```

[Link to this function](#intersection_point/4 "Link to this function")

intersection\_point(point\_1, bearing\_1, point\_2, bearing\_2)

===============================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L204 "View Source")

```

@spec intersection_point(

  [Geocalc.Point.t](Geocalc.Point.html#t:t/0)(),

  [point\_or\_bearing](#t:point_or_bearing/0)(),

  [Geocalc.Point.t](Geocalc.Point.html#t:t/0)(),

  [point\_or\_bearing](#t:point_or_bearing/0)()

) ::

  [tuple](https://hexdocs.pm/elixir/typespecs.html#basic-types)()

```

Finds intersection point from start points with given bearings.

Returns array with latitude and longitude.

Raise an exception if no intersection point found.

[examples](#intersection_point/4-examples)

 Examples

-----------------------------------------------------

Find intersection point by bearing:

```

iex> berlin = [52.5075419, 13.4251364]

iex> berlin\_bearing = -2.102

iex> london = [51.5286416, -0.1015987]

iex> london\_bearing = 1.502

iex> Geocalc.intersection\_point(berlin, berlin\_bearing, london, london\_bearing)

{:ok, [51.49271112601574, 10.735322818996854]}

iex> berlin = %{lat: 52.5075419, lng: 13.4251364}

iex> bearing = Geocalc.degrees\_to\_radians(90.0)

iex> Geocalc.intersection\_point(berlin, bearing, berlin, bearing)

{:ok, [52.5075419, 13.4251364]}

```

Find intersection point by point:

```

iex> berlin = {52.5075419, 13.4251364}

iex> london = {51.5286416, -0.1015987}

iex> paris = {48.8588589, 2.3475569}

iex> Geocalc.intersection\_point(berlin, london, paris, london)

{:ok, [51.5286416, -0.10159869999998701]}

```

Raise exception when no intersection points:

```

iex> berlin\_1 = %{lat: 52.5075419, lng: 13.4251364}

iex> berlin\_2 = %{lat: 52.5075419, lng: 13.57}

iex> bearing = Geocalc.degrees\_to\_radians(90.0)

iex> Geocalc.intersection\_point(berlin\_1, bearing, berlin\_2, bearing)

{:error, "No intersection point found"}

```

[Link to this function](#intersects_bounding_box?/2 "Link to this function")

intersects\_bounding\_box?(bounding\_box\_1, bounding\_box\_2)

==============================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L298 "View Source")

```

@spec intersects_bounding_box?([list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(), [list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Returns `true` if the bounding box intersects the given bounds.

Two bounds intersect if they have at least one point in common.

[examples](#intersects_bounding_box?/2-examples)

 Examples

-----------------------------------------------------------

```

iex> germany = [[47.27, 5.87], [55.1, 15.04]]

iex> poland = [[49.0, 14.12], [55.03, 24.15]]

iex> Geocalc.intersects\_bounding\_box?(germany, poland)

true

```

[Link to this function](#max_latitude/2 "Link to this function")

max\_latitude(point, bearing)

=============================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L398 "View Source")

```

@spec max_latitude([Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates maximum latitude reached when travelling on a great circle on given

bearing from the point (Clairaut's formula). Negate the result for the

minimum latitude (in the Southern hemisphere).

The maximum latitude is independent of longitude; it will be the same for all

points on a given latitude.

Returns radians.

[examples](#max_latitude/2-examples)

 Examples

-----------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> paris = [48.8588589, 2.3475569]

iex> bearing = Geocalc.bearing(berlin, paris)

iex> Geocalc.max\_latitude(berlin, bearing)

55.953467429882835

```

[Link to this function](#outside_area?/2 "Link to this function")

outside\_area?(area, point)

===========================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L503 "View Source")

```

@spec outside_area?(

  [Geocalc.Shape.Circle.t](Geocalc.Shape.Circle.html#t:t/0)()

  | [Geocalc.Shape.Rectangle.t](Geocalc.Shape.Rectangle.html#t:t/0)()

  | [Geocalc.Shape.Ellipse.t](Geocalc.Shape.Ellipse.html#t:t/0)(),

  [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()

) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Check if a `point` is outside `area`.

Returns true if outside area, false if not

[examples](#outside_area?/2-examples)

 Examples

------------------------------------------------

```

iex> area = %Geocalc.Shape.Circle{latitude: 48.856614, longitude: 2.3522219, radius: 10}

iex> point = %{lat: 48.856418, lng: 2.365871}

iex> Geocalc.outside\_area?(area, point)

true

```

[Link to this function](#overlaps_bounding_box?/2 "Link to this function")

overlaps\_bounding\_box?(bounding\_box\_1, bounding\_box\_2)

============================================================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L316 "View Source")

```

@spec overlaps_bounding_box?([list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(), [list](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Returns `true` if the bounding box overlaps the given bounds.

Two bounds overlap if their intersection is an area.

[examples](#overlaps_bounding_box?/2-examples)

 Examples

---------------------------------------------------------

```

iex> germany = [[47.27, 5.87], [55.1, 15.04]]

iex> berlin\_suburbs = [[52.338261, 13.08835], [52.67551, 13.76116]]

iex> Geocalc.overlaps\_bounding\_box?(germany, berlin\_suburbs)

true

```

[Link to this function](#radians_to_degrees/1 "Link to this function")

radians\_to\_degrees(radians)

=============================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L355 "View Source")

```

@spec radians_to_degrees([number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()) :: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Converts radians to degrees.

Returns degrees.

[examples](#radians_to_degrees/1-examples)

 Examples

-----------------------------------------------------

```

iex> Geocalc.radians\_to\_degrees(2.5075419)

143.67156782221554

iex> Geocalc.radians\_to\_degrees(-0.1015987)

-5.821176714015797

```

[Link to this function](#within?/2 "Link to this function")

within?(poly, point)

====================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L89 "View Source")

```

@spec within?([[Geocalc.Point.t](Geocalc.Point.html#t:t/0)()], [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates if a point is within a polygon.

Returns boolean.

[examples](#within?/2-examples)

 Examples

------------------------------------------

```

iex> point = [14.952242, 60.1696017]

iex> poly = [[24.950899, 60.169158], [24.953492, 60.169158], [24.953510, 60.170104], [24.950958, 60.169990]]

iex> Geocalc.within?(poly, point)

false

iex> point = [24.952242, 60.1696017]

iex> poly = [[24.950899, 60.169158], [24.953492, 60.169158], [24.953510, 60.170104], [24.950958, 60.169990]]

iex> Geocalc.within?(poly, point)

true

iex> point = [24.976567, 60.1612500]

iex> poly = [[24.950899, 60.169158], [24.953492, 60.169158], [24.953510, 60.170104], [24.950958, 60.169990]]

iex> Geocalc.within?(poly, point)

false

```

[Link to this function](#within?/3 "Link to this function")

within?(radius, center, point)

==============================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc.ex#L59 "View Source")

```

@spec within?([number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)(), [Geocalc.Point.t](Geocalc.Point.html#t:t/0)()) :: [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

Calculates if a point is within radius of the center of a circle.

Returns boolean.

[examples](#within?/3-examples)

 Examples

------------------------------------------

```

iex> berlin = [52.5075419, 13.4251364]

iex> paris = [48.8588589, 2.3475569]

iex> Geocalc.within?(10, paris, berlin)

false

iex> Geocalc.within?(10, berlin, paris)

false

iex> san\_juan = %{lat: 18.4655, lon: 66.1057}

iex> puerto\_rico = %{lat: 18.2208, lng: 66.5901}

iex> Geocalc.within?(170\_000, puerto\_rico, san\_juan)

true

```





Geocalc.DMS — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/dms.ex#L1 "View Source")

Geocalc.DMS

(Geocalc v0.8.5)

=========================================================================================================================================

The [`Geocalc.DMS`](Geocalc.DMS.html#content) is a struct which contains degrees, minutes, seconds and

cardinal direction.

Also have functions to convert DMS to decimal degrees.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Functions](#functions)

------------------------

[to\_decimal(dms)](#to_decimal/1)

deprecated

[to\_degrees(dms)](#to_degrees/1)

Converts [`Geocalc.DMS`](Geocalc.DMS.html#content) to decimal degrees.

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:t/0 "Link to this type")

t()

===

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/dms.ex#L12 "View Source")

```

@type t() :: %Geocalc.DMS{

  direction: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  hours: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  minutes: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  seconds: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

}

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#to_decimal/1 "Link to this function")

to\_decimal(dms)

================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/dms.ex#L79 "View Source")

 This function is deprecated. Use to\_degrees/1 instead.

 

```

@spec to_decimal([t](#t:t/0)()) :: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | :error

```

[Link to this function](#to_degrees/1 "Link to this function")

to\_degrees(dms)

================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/dms.ex#L25 "View Source")

```

@spec to_degrees([t](#t:t/0)()) :: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | :error

```

Converts [`Geocalc.DMS`](Geocalc.DMS.html#content) to decimal degrees.

[examples](#to_degrees/1-examples)

 Examples

---------------------------------------------

```

iex> dms = %Geocalc.DMS{hours: 13, minutes: 31, seconds: 59.998, direction: "N"}

iex> Geocalc.DMS.to\_degrees(dms)

13.533332777777778

```





Geocalc.Point — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/point.ex#L1 "View Source")

Geocalc.Point protocol

(Geocalc v0.8.5)

======================================================================================================================================================

The [`Geocalc.Point`](Geocalc.Point.html#content) protocol is responsible for receiving latitude and

longitude from any Elixir data structure.

At this time it have implementations only for Map, Tuple and List, and Shape

defined inside this project.

Point values can be decimal degrees or DMS (degrees, minutes, seconds).

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Functions](#functions)

------------------------

[latitude(point)](#latitude/1)

Returns point latitude.

[longitude(point)](#longitude/1)

Returns point longitude.

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:t/0 "Link to this type")

t()

===

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/point.ex#L1 "View Source")

```

@type t() :: [term](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

```

[Link to this section](#functions)

Functions

=============================================

[Link to this function](#latitude/1 "Link to this function")

latitude(point)

===============

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/point.ex#L15 "View Source")

Returns point latitude.

[Link to this function](#longitude/1 "Link to this function")

longitude(point)

================

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/point.ex#L20 "View Source")

Returns point longitude.





Geocalc.Shape — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/shape.ex#L1 "View Source")

Geocalc.Shape

(Geocalc v0.8.5)

=============================================================================================================================================

[`Geocalc.Shape`](Geocalc.Shape.html#content) contains `Circle`, `Rectangle` and `Ellipse` shapes.

Those shapes define a geographical area projection and are designed to be

used for geofencing, ie: the user can determine if one point is inside or

outside a geographical zone.

Geographical zones are defined with a center point and several spatial

dimensions (see each shape documentation).





Geocalc.Shape.Circle — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/shape.ex#L13 "View Source")

Geocalc.Shape.Circle

(Geocalc v0.8.5)

=====================================================================================================================================================

`Circle` describes a circular geographical area, centered on `latitude`,

`longitude`, with a `radius` in meters.

`latitude` and `longitude` could be [`Decimal`](https://hexdocs.pm/decimal/2.0.0/Decimal.html) degrees or [`Geocalc.DMS`](Geocalc.DMS.html).

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:t/0 "Link to this type")

t()

===

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/shape.ex#L23 "View Source")

```

@type t() :: %Geocalc.Shape.Circle{

  latitude: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | [Decimal.t](https://hexdocs.pm/decimal/2.0.0/Decimal.html#t:t/0)() | [Geocalc.DMS.t](Geocalc.DMS.html#t:t/0)(),

  longitude: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | [Decimal.t](https://hexdocs.pm/decimal/2.0.0/Decimal.html#t:t/0)() | [Geocalc.DMS.t](Geocalc.DMS.html#t:t/0)(),

  radius: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

}

```





Geocalc.Shape.Ellipse — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/shape.ex#L58 "View Source")

Geocalc.Shape.Ellipse

(Geocalc v0.8.5)

======================================================================================================================================================

`Ellipse` describes an elliptic geographical area, centered on `latitude`,

`longitude` (could be [`Decimal`](https://hexdocs.pm/decimal/2.0.0/Decimal.html) degrees or [`Geocalc.DMS`](Geocalc.DMS.html)), with

`long_semi_axis` and `short_semi_axis` (both in meters) and an azimuth

`angle` (in degrees).

`long_semi_axis` is the length of the longest diameter, also called

semi-major axis.

`short_semi_axis` is the length of the shortest diameter, also called

semi-minor axis.

`angle` is the azimuth angle of the long semi-axis.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:t/0 "Link to this type")

t()

===

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/shape.ex#L76 "View Source")

```

@type t() :: %Geocalc.Shape.Ellipse{

  angle: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  latitude: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | [Decimal.t](https://hexdocs.pm/decimal/2.0.0/Decimal.html#t:t/0)() | [Geocalc.DMS.t](Geocalc.DMS.html#t:t/0)(),

  long_semi_axis: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  longitude: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | [Decimal.t](https://hexdocs.pm/decimal/2.0.0/Decimal.html#t:t/0)() | [Geocalc.DMS.t](Geocalc.DMS.html#t:t/0)(),

  short_semi_axis: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

}

```





Geocalc.Shape.Rectangle — Geocalc v0.8.5

 try {

 var settings = JSON.parse(localStorage.getItem('ex\_doc:settings') || '{}');

 if (settings.theme === 'dark' ||

 ((settings.theme === 'system' || settings.theme == null) &&

 window.matchMedia('(prefers-color-scheme: dark)').matches)

 ) {

 document.body.classList.add('dark')

 }

 } catch (error) { }

 

Settings

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/shape.ex#L30 "View Source")

Geocalc.Shape.Rectangle

(Geocalc v0.8.5)

========================================================================================================================================================

`Rectangle` describes a rectangular geographical area, centered on

`latitude`, `longitude` (could be [`Decimal`](https://hexdocs.pm/decimal/2.0.0/Decimal.html) degrees or [`Geocalc.DMS`](Geocalc.DMS.html)), with

`long_semi_axis` and `short_semi_axis` (both in meters) and an azimuth

`angle` (in degrees).

`long_semi_axis` is the distance between the center point and the short

side of the rectangle.

`short_semi_axis` is the distance between the center point and the long

side of the rectangle.

`angle` is the azimuth angle of the long side of the rectangle, ie: the

angle between north and `long_semi_axis`.

[Link to this section](#summary)

 Summary

==========================================

[Types](#types)

----------------

[t()](#t:t/0)

[Link to this section](#types)

Types

=====================================

[Link to this type](#t:t/0 "Link to this type")

t()

===

[View Source](https://github.com/yltsrc/geocalc/blob/0.8.5/lib/geocalc/shape.ex#L49 "View Source")

```

@type t() :: %Geocalc.Shape.Rectangle{

  angle: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  latitude: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | [Decimal.t](https://hexdocs.pm/decimal/2.0.0/Decimal.html#t:t/0)() | [Geocalc.DMS.t](Geocalc.DMS.html#t:t/0)(),

  long_semi_axis: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),

  longitude: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)() | [Decimal.t](https://hexdocs.pm/decimal/2.0.0/Decimal.html#t:t/0)() | [Geocalc.DMS.t](Geocalc.DMS.html#t:t/0)(),

  short_semi_axis: [number](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()

}

```

