Created
October 30, 2017 12:18
-
-
Save Linuus/78ffab2e7eadd4d90e3d048e5f5e156a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defimpl Ecto.DataType, for: Map do | |
def cast(%{lat: lat, long: long}, Geo.Point), do: cast(%{"lat" => lat, "long" => long}, Geo.Point) | |
def cast(%{"lat" => lat, "long" => long}, Geo.Point) do | |
{:ok, %Geo.Point{coordinates: {long, lat}, srid: 4326}} | |
end | |
def cast(arg1, arg2) do | |
:error | |
end | |
def dump(%Geo.Point{} = point), do: {:ok, point} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment