Packages

GridSquare calculator for encoding/decoding between latitude/longitude and Maidenhead Locator System grid references

Current section

5 Versions

Jump to

Compare versions

4 files changed
+22 additions
-9 deletions
  @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5 5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6 6 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 7
8 + ## [0.3.0] - 2026-02-10
9 +
10 + ### Fixed
11 + - Longitude normalization now handles arbitrary wraps (e.g. 1080.0, -560.0) using modular arithmetic instead of single-wrap
12 + - Extended precision encoding formula fixed — was producing "00" for the first base 10 pair due to off-by-one in divisor calculation
13 + - Extended precision decoding — `decode/1` now parses characters beyond position 6 and returns progressively smaller width/height
14 + - `distance_between/2` normalizes both refs to 6-char subsquare level for consistent adjacency detection with mixed-precision inputs
15 + - Odd precision values (7, 9, etc.) now raise `FunctionClauseError` instead of being silently accepted
16 + - Removed stale `excoveralls` entry from `mix.lock`
17 +
18 + ### Changed
19 + - `from_base18`/`from_base24` replaced with O(1) byte arithmetic instead of `Enum.find_index`
20 +
8 21 ## [0.2.0] - 2025-06-30
9 22
10 23 ### Added
  @@ -21,7 +21,7 @@ The package can be installed by adding `gridsquare` to your list of dependencies
21 21 ```elixir
22 22 def deps do
23 23 [
24 - {:gridsquare, "~> 0.1.0"}
24 + {:gridsquare, "~> 0.3.0"}
25 25 ]
26 26 end
27 27 ```
  @@ -37,7 +37,7 @@ Gridsquare.encode(-111.866785, 40.363840)
37 37
38 38 # Extended precision (10-character precision)
39 39 Gridsquare.encode(-111.866785, 40.363840, 10)
40 - # Returns: %Gridsquare.EncodeResult{grid_reference: "DN40BI00OR", subsquare: "dn40bi"}
40 + # Returns: %Gridsquare.EncodeResult{grid_reference: "DN40BI57XH", subsquare: "dn40bi"}
41 41 ```
42 42
43 43 ### Decoding grid square to coordinates
  @@ -81,7 +81,7 @@ Encodes latitude and longitude coordinates to a Maidenhead grid square reference
81 81 **Parameters:**
82 82 - `longitude` (float): Longitude coordinate (-180 to 180)
83 83 - `latitude` (float): Latitude coordinate (-90 to 90)
84 - - `precision` (integer): Number of characters in the grid reference (6 to 20, default: 6)
84 + - `precision` (integer): Number of characters in the grid reference (even values 6 to 20, default: 6)
85 85
86 86 **Returns:** `%Gridsquare.EncodeResult{grid_reference: String.t(), subsquare: String.t()}`
87 87
  @@ -120,11 +120,11 @@ Each additional pair increases precision by approximately 10x.
120 120 ```elixir
121 121 # High precision encoding for precise location
122 122 precise_grid = Gridsquare.encode(-111.866785, 40.363840, 12)
123 - # %Gridsquare.EncodeResult{grid_reference: "DN40BI00OR12", subsquare: "dn40bi"}
123 + # %Gridsquare.EncodeResult{grid_reference: "DN40BI57XH67", subsquare: "dn40bi"}
124 124
125 - # Decode back to coordinates
126 - precise_location = Gridsquare.decode("DN40BI00OR12")
127 - # Returns %Gridsquare.DecodeResult{} with much higher precision
125 + # Decode back to coordinates with progressively smaller grid dimensions
126 + precise_location = Gridsquare.decode("DN40BI57XH67")
127 + # Returns %Gridsquare.DecodeResult{} with higher precision width/height
128 128 ```
129 129
130 130 ## Contributing
  @@ -2,7 +2,7 @@
2 2 [{<<"GitHub">>,<<"https://github.com/gmcintire/gridsquare">>},
3 3 {<<"HexDocs">>,<<"https://hexdocs.pm/gridsquare">>}]}.
4 4 {<<"name">>,<<"gridsquare">>}.
5 - {<<"version">>,<<"0.3.0">>}.
5 + {<<"version">>,<<"0.3.1">>}.
6 6 {<<"description">>,
7 7 <<"GridSquare calculator for encoding/decoding between latitude/longitude and Maidenhead Locator System grid references">>}.
8 8 {<<"elixir">>,<<"~> 1.16">>}.
  @@ -1,7 +1,7 @@
1 1 defmodule Gridsquare.MixProject do
2 2 use Mix.Project
3 3
4 - @version "0.3.0"
4 + @version "0.3.1"
5 5 @source_url "https://github.com/gmcintire/gridsquare"
6 6
7 7 def project do