Skip to content

Commit

Permalink
Fix compile warnings (#186)
Browse files Browse the repository at this point in the history
This was breaking the build because we were unintentionally duplicating these function clauses (see the `for {endian, endian_atom, modifier} . . .` stuff).
  • Loading branch information
s3cur3 authored Sep 19, 2023
1 parent 726667a commit d56d8a4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/geo/wkb/encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ defmodule Geo.WKB.Encoder do

def encode!(geom, endian \\ :ndr)

def do_encode(%Point{coordinates: nil}, :ndr) do
{@point, [<<00, 00, 00, 00, 00, 00, 248, 127>>, <<00, 00, 00, 00, 00, 00, 248, 127>>]}
end

def do_encode(%Point{coordinates: nil}, :xdr) do
{@point, [<<127, 248, 00, 00, 00, 00, 00, 00>>, <<127, 248, 00, 00, 00, 00, 00, 00>>]}
end

for {endian, endian_atom, modifier} <- [{1, :ndr, quote(do: little)}, {0, :xdr, quote(do: big)}] do
def encode!(geom, unquote(endian_atom)) do
{type, rest} = do_encode(geom, unquote(endian_atom))
Expand All @@ -55,14 +63,6 @@ defmodule Geo.WKB.Encoder do
[unquote(endian), binary, rest]
end

def do_encode(%Point{coordinates: nil}, :ndr) do
{@point, [<<00, 00, 00, 00, 00, 00, 248, 127>>, <<00, 00, 00, 00, 00, 00, 248, 127>>]}
end

def do_encode(%Point{coordinates: nil}, :xdr) do
{@point, [<<127, 248, 00, 00, 00, 00, 00, 00>>, <<127, 248, 00, 00, 00, 00, 00, 00>>]}
end

def do_encode(%Point{coordinates: {x, y}}, unquote(endian_atom)) do
{@point, [<<x::unquote(modifier)-float-64>>, <<y::unquote(modifier)-float-64>>]}
end
Expand Down

0 comments on commit d56d8a4

Please sign in to comment.