Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/schemas.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ defmodule ValueFormatters.Schemas do
default: true,
description:
"Whether the formatter should include the radius/accuracy information (if present)."
}
},
separator: %{
type: :string,
default: ", ",
description: "The string used to separate latitude, longitude and radius values."
}
}
end
end

Expand Down Expand Up @@ -114,7 +119,7 @@ defmodule ValueFormatters.Schemas.Format do
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
},
required: [:format],
additionalProperties: false
Expand Down Expand Up @@ -238,7 +243,7 @@ defmodule ValueFormatters.Schemas.Format do
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},
},
coordinates_options()
),
Expand All @@ -253,10 +258,11 @@ defmodule ValueFormatters.Schemas.Format do
type: :string,
description:
"If the value is an object, the field to extract the formattable entity from."
}
},

},
required: [:field],
additionalProperties: false
additionalProperties: true
}
]
}
Expand Down
5 changes: 3 additions & 2 deletions lib/value_formatters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,20 @@ defmodule ValueFormatters do
format_number(lat, %{"format" => "number", "precision" => 5}, opts),
{:ok, lng_formatted} <-
format_number(lng, %{"format" => "number", "precision" => 5}, opts) do
separator = get_in(coordinate_definition, ["separator"]) || ", "
if get_in(coordinate_definition, ["radius_display"]) != false and radius != nil do
with {:ok, radius_formatted} <-
format_number(
radius,
%{"format" => "number", "precision" => 0, "unit" => "m"},
opts
) do
{:ok, "#{lat_formatted}\u{00B0}, #{lng_formatted}\u{00B0}, #{radius_formatted}"}
{:ok, "#{lat_formatted}\u{00B0}#{separator}#{lng_formatted}\u{00B0}#{separator}#{radius_formatted}"}
else
{:error, reason} -> {:error, reason}
end
else
{:ok, "#{lat_formatted}\u{00B0}, #{lng_formatted}\u{00B0}"}
{:ok, "#{lat_formatted}\u{00B0}#{separator}#{lng_formatted}\u{00B0}"}
end
else
{:error, _reason} -> {:error, "Value #{value} cannot be parsed as a coordinate"}
Expand Down
Loading