Visualize.Geo.Circle (Visualize v0.2.35)

Copy Markdown View Source

A circle on the sphere as a GeoJSON Polygon: d3-geo's geoCircle (spec/07 §2.5, D-131).

polygon/1 returns the small circle of angular radius degrees about center, as %{"type" => "Polygon", "coordinates" => [ring]}, one ring of [lon, lat] positions in degrees. The ring is d3-geo 3.1.1's, point for point and in d3's order and winding, so Visualize.Geo.Path, which clips on the sphere as d3 does (spec/07 §2.2.1, D-127), fills the cap of radius about center under every projection — a hemisphere at 90°.

iex> %{"type" => "Polygon", "coordinates" => [ring]} =
...>   Visualize.Geo.Circle.polygon(center: [0, 0], radius: 10, precision: 90)
iex> length(ring)
5

The ring starts at the circle's angle radius about its axis, not at its southernmost point, and runs every precision degrees back round to it, as d3's does.

Options:

  • :center — [lon, lat] in degrees (default [0, 0])
  • :radius — the angular radius in degrees (default 90)
  • :precision — the step between the ring's points, in degrees of the circle's own angle (default 6); 0 gives an empty ring, as in d3

Summary

Functions

The circle of radius degrees about center, every precision degrees, as a GeoJSON Polygon (spec/07 §2.5).

Types

position()

@type position() :: [float()]

t()

@type t() :: %{required(String.t()) => String.t() | [[position()]]}

Functions

polygon(opts \\ [])

@spec polygon(keyword()) :: t()

The circle of radius degrees about center, every precision degrees, as a GeoJSON Polygon (spec/07 §2.5).