diff --git a/lib/schemas.ex b/lib/schemas.ex index bf69b89..573bee2 100644 --- a/lib/schemas.ex +++ b/lib/schemas.ex @@ -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 @@ -256,7 +261,7 @@ defmodule ValueFormatters.Schemas.Format do } }, required: [:field], - additionalProperties: false + additionalProperties: true } ] } diff --git a/lib/value_formatters.ex b/lib/value_formatters.ex index e9c0e96..9817ba2 100644 --- a/lib/value_formatters.ex +++ b/lib/value_formatters.ex @@ -365,6 +365,8 @@ 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( @@ -372,12 +374,13 @@ defmodule ValueFormatters do %{"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"}