Geo

Build StatusHex.pm

A collection of GIS functions. Handles conversions to and from WKT, WKB, and GeoJSON for the following geometries:

Note: If you are looking for the Postgrex PostGIS extension, check out geo_postgis

Note: If you are looking to do geospatial calculations in memory with Geo's structs, check out topo

defp deps do
  [{:geo, "~> 3.0"}]
end

Documentation

Examples

Geo only encodes and decodes maps shaped as GeoJSON. JSON encoding and decoding must be done before and after.

#Examples using Poison as the JSON parser

iex(1)> Geo.JSON.encode(point)
{:ok, %{ "type" => "Point", "coordinates" => [100.0, 0.0] }}

iex(2)> point = Poison.decode!("{ \"type\": \"Point\", \"coordinates\": [100.0, 0.0] }") |> Geo.JSON.decode
%Geo.Point{ coordinates: {100.0, 0.0}, srid: nil }

iex(3)> Geo.JSON.encode!(point) |> Poison.encode!
"{\"type\":\"Point\",\"coordinates\":[100.0,0.0]}"