### Encode and Decode WKB/EWKB with Geo Source: https://hexdocs.pm/geo/v4.1.0/geo/readme Illustrates encoding and decoding of Well-Known Binary (WKB) and Extended Well-Known Binary (EWKB) formats using the Geo.WKB module. Examples include handling points with and without SRID. ```elixir iex(1)> {:ok, point} = Geo.WKB.decode("0101000000000000000000F03F000000000000F03F") %Geo.Point{ coordinates: {1.0, 1.0}, srid: nil } iex(2)> Geo.WKB.encode!(point) "00000000013FF00000000000003FF0000000000000" iex(3)> point = Geo.WKB.decode!("0101000020E61000009EFB613A637B4240CF2C0950D3735EC0") %Geo.Point{ coordinates: {36.9639657, -121.8097725}, srid: 4326 } iex(4)> Geo.WKB.encode!(point) "0020000001000010E640427B633A61FB9EC05E73D350092CCF" ``` -------------------------------- ### Encode and Decode WKT/EWKT with Geo Source: https://hexdocs.pm/geo/v4.1.0/geo/readme Demonstrates encoding and decoding of Well-Known Text (WKT) and Extended Well-Known Text (EWKT) formats using the Geo.WKT module. This includes handling points with and without SRID. ```elixir iex(1)> {:ok, point} = Geo.WKT.decode("POINT(30 -90)") %Geo.Point{ coordinates: {30, -90}, srid: nil} iex(2)> Geo.WKT.encode!(point) "POINT(30 -90)" iex(3)> point = Geo.WKT.decode!("SRID=4326;POINT(30 -90)") %Geo.Point{coordinates: {30, -90}, srid: 4326} ``` -------------------------------- ### Add Geo Dependency to Elixir Project Source: https://hexdocs.pm/geo/v4.1.0/geo/readme This snippet shows how to add the Geo library as a dependency in an Elixir project's `mix.exs` file. Ensure you are using a compatible version of the Geo library. ```elixir defp deps do [ {:geo, "~> 4.0"} ] end ``` -------------------------------- ### Encode and Decode GeoJSON with Geo Source: https://hexdocs.pm/geo/v4.1.0/geo/readme Shows how to encode and decode GeoJSON representations of geometries using the Geo.JSON module. This process requires prior JSON encoding/decoding using a JSON library like `Jason`. ```elixir # Examples using JSON as the JSON parser iex(1)> Geo.JSON.encode(point) {:ok, %{ "type" => "Point", "coordinates" => [100.0, 0.0] }} iex(2)> point = JSON.decode!("{\"type\": \"Point\", \"coordinates\": [100.0, 0.0] }") |> Geo.JSON.decode {:ok, %Geo.Point{coordinates: {100.0, 0.0}, srid: 4326, properties: %{}} iex(3)> Geo.JSON.encode!(point) |> JSON.encode! "{\"coordinates\":[100.0,0.0],\"type\":\"Point\"}" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.