changed
CHANGELOG.md
|
@@ -1,5 +1,9 @@
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+ ## v4.0.1 — 2024-09-23
|
4
|
+
|
5
|
+ [Fix error raised when decoding JSON with string representations of integer values in coordinates](https://github.com/felt/geo/pull/221) by new contributor @IceDragon200.
|
6
|
+
|
3
7
|
## v4.0.0 — 2024-09-17
|
4
8
|
|
5
9
|
### Potentially breaking change: [Default decoded GeoJSON to SRID 4326 (WGS 84)](https://github.com/felt/geo/pull/219)
|
changed
hex_metadata.config
|
@@ -1,6 +1,6 @@
|
1
1
|
{<<"links">>,[{<<"GitHub">>,<<"https://github.com/felt/geo">>}]}.
|
2
2
|
{<<"name">>,<<"geo">>}.
|
3
|
- {<<"version">>,<<"4.0.0">>}.
|
3
|
+ {<<"version">>,<<"4.0.1">>}.
|
4
4
|
{<<"description">>,<<"Encodes and decodes WKB, WKT, and GeoJSON formats.">>}.
|
5
5
|
{<<"elixir">>,<<"~> 1.10">>}.
|
6
6
|
{<<"app">>,<<"geo">>}.
|
changed
lib/geo/json/decoder.ex
|
@@ -262,7 +262,7 @@ defmodule Geo.JSON.Decoder do
|
262
262
|
|
263
263
|
str when is_binary(str) ->
|
264
264
|
try do
|
265
|
- String.to_float(str)
|
265
|
+ Geo.Utils.string_to_float!(str)
|
266
266
|
catch
|
267
267
|
ArgumentError ->
|
268
268
|
raise ArgumentError, "expected a numeric coordinate, got the string #{inspect(str)}"
|
changed
lib/geo/utils.ex
|
@@ -1,6 +1,31 @@
|
1
1
|
defmodule Geo.Utils do
|
2
2
|
@moduledoc false
|
3
3
|
|
4
|
+ @spec string_to_float(String.t()) :: {:ok, float()} | {:error, term}
|
5
|
+ def string_to_float(str) when is_binary(str) do
|
6
|
+ case Float.parse(str) do
|
7
|
+ :error ->
|
8
|
+ {:error, :bad_arg}
|
9
|
+
|
10
|
+ {flt, ""} ->
|
11
|
+ {:ok, flt}
|
12
|
+
|
13
|
+ {_flt, _rest} ->
|
14
|
+ {:error, :bad_arg}
|
15
|
+ end
|
16
|
+ end
|
17
|
+
|
18
|
+ @spec string_to_float!(String.t()) :: float() | no_return()
|
19
|
+ def string_to_float!(str) when is_binary(str) do
|
20
|
+ case string_to_float(str) do
|
21
|
+ {:ok, flt} ->
|
22
|
+ flt
|
23
|
+
|
24
|
+ {:error, :bad_arg} ->
|
25
|
+ raise ArgumentError, "given string is not a textual representation of a float"
|
26
|
+ end
|
27
|
+ end
|
28
|
+
|
4
29
|
@doc """
|
5
30
|
Turns a hex string or an integer of base 16 into its floating point
|
6
31
|
representation.
|
changed
mix.exs
|
@@ -2,7 +2,7 @@ defmodule Geo.Mixfile do
|
2
2
|
use Mix.Project
|
3
3
|
|
4
4
|
@source_url "https://github.com/felt/geo"
|
5
|
- @version "4.0.0"
|
5
|
+ @version "4.0.1"
|
6
6
|
|
7
7
|
def project do
|
8
8
|
[
|