Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion lib/schemas.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ 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
Expand Down Expand Up @@ -256,7 +261,7 @@ defmodule ValueFormatters.Schemas.Format do
}
},
required: [:field],
additionalProperties: false
additionalProperties: true
}
]
}
Expand Down
7 changes: 5 additions & 2 deletions lib/value_formatters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,22 @@ 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