Fix federating geo coordinates

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-09-06 12:46:29 +02:00
parent 7c71e9e04f
commit cc197d7638
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -36,15 +36,16 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Address do
}) })
end end
if is_nil(object["latitude"]) or is_nil(object["longitude"]) do latitude = Map.get(object, "latitude")
res longitude = Map.get(object, "longitude")
else
geo = %Geo.Point{
coordinates: {object["longitude"], object["latitude"]},
srid: 4326
}
Map.put(res, "geom", geo) if is_float(latitude) and is_float(longitude) do
Map.put(res, "geom", %Geo.Point{
coordinates: {longitude, latitude},
srid: 4326
})
else
res
end end
end end
@ -72,8 +73,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Address do
res res
else else
res res
|> Map.put("longitude", address.geom.coordinates |> elem(1)) |> Map.put("longitude", address.geom.coordinates |> elem(0))
|> Map.put("latitude", address.geom.coordinates |> elem(0)) |> Map.put("latitude", address.geom.coordinates |> elem(1))
end end
end end
end end