Skip to content

Commit

Permalink
Merge pull request #157 from wojtekmach/wm-specs
Browse files Browse the repository at this point in the history
Update specs
  • Loading branch information
bryanjos authored Apr 10, 2021
2 parents c3cb663 + 54f384c commit 7b0aed4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/geo/json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defmodule Geo.JSON do
@doc """
Takes a map representing GeoJSON and returns a Geometry.
"""
@spec decode!(map()) :: Geo.geometry() | no_return
@spec decode!(map()) :: Geo.geometry()
defdelegate decode!(geo_json), to: Decoder

@doc """
Expand All @@ -42,7 +42,7 @@ defmodule Geo.JSON do
@doc """
Takes a Geometry and returns a map representing the GeoJSON.
"""
@spec encode!(Geo.geometry()) :: map() | no_return
@spec encode!(Geo.geometry()) :: map()
defdelegate encode!(geom), to: Encoder
defdelegate encode!(geom, opts), to: Encoder

Expand Down
2 changes: 1 addition & 1 deletion lib/geo/json/decoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Geo.JSON.Decoder do
@doc """
Takes a map representing GeoJSON and returns a Geometry.
"""
@spec decode!(map()) :: Geo.geometry() | no_return
@spec decode!(map()) :: Geo.geometry()
def decode!(geo_json) do
cond do
Map.has_key?(geo_json, "geometries") ->
Expand Down
16 changes: 9 additions & 7 deletions lib/geo/wkb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ defmodule Geo.WKB do
Takes a Geometry and returns a WKB string. The endian decides
what the byte order will be.
"""
@spec encode!(Geo.geometry(), Geo.endian()) :: binary | no_return
@spec encode!(Geo.geometry(), Geo.endian()) :: binary
def encode!(geom, endian \\ :xdr) do
geom |> Encoder.encode!(endian) |> IO.iodata_to_binary() |> Base.encode16()
end

@doc """
Takes a Geometry and returns a WKB string. The endian decides
what the byte order will be.
Takes a Geometry and returns a WKB string.
The endian decides what the byte order will be.
"""
@spec encode(binary, Geo.endian()) :: {:ok, binary} | {:error, Exception.t()}
def encode(geom, endian \\ :xdr) do
Expand All @@ -39,10 +40,11 @@ defmodule Geo.WKB do
end

@doc """
Takes a Geometry and returns a WKB as iodata. The endian decides
what the byte order will be.
Takes a Geometry and returns a WKB as iodata.
The endian decides what the byte order will be.
"""
@spec encode_to_iodata(Geo.geometry(), Geo.endian()) :: iodata() | no_return
@spec encode_to_iodata(Geo.geometry(), Geo.endian()) :: iodata()
def encode_to_iodata(geom, endian \\ :xdr) do
Encoder.encode!(geom, endian)
end
Expand Down Expand Up @@ -79,7 +81,7 @@ defmodule Geo.WKB do
@doc """
Takes a WKB string and returns a Geometry.
"""
@spec decode!(binary | iodata()) :: Geo.geometry() | no_return
@spec decode!(iodata()) :: Geo.geometry()
def decode!(wkb)

def decode!("00" <> _ = wkb) do
Expand Down
2 changes: 1 addition & 1 deletion lib/geo/wkt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ defmodule Geo.WKT do
@doc """
Takes a WKT string and returns a Geo.geometry struct or list of Geo.geometry.
"""
@spec decode!(binary) :: Geo.geometry() | no_return
@spec decode!(binary) :: Geo.geometry()
defdelegate decode!(wkt), to: Decoder
end
2 changes: 1 addition & 1 deletion lib/geo/wkt/decoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Geo.WKT.Decoder do
@doc """
Takes a WKT string and returns a Geo.geometry struct or list of Geo.geometry.
"""
@spec decode!(binary) :: Geo.geometry() | no_return
@spec decode!(binary) :: Geo.geometry()
def decode!(wkt) do
wkt_split = String.split(wkt, ";")

Expand Down

0 comments on commit 7b0aed4

Please sign in to comment.