Skip to content

Commit bc87c7a

Browse files
committed
Fixed bug in Encoder.encode to retrieve shortest code
1 parent 67c96a6 commit bc87c7a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/main/java/com/mapcode/Encoder.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ else if (mapcoderData.isNameless()) { // auto-pipe 21/22
152152

153153
// The result should not be stored yet.
154154
if (!results.contains(newResult)) {
155-
results.add(newResult);
155+
if (limitToOneResult) {
156+
results.clear();
157+
results.add(newResult);
158+
}
159+
else {
160+
results.add(newResult);
161+
}
156162
}
157163
else {
158164
LOG.error("encode: Duplicate results found, newResult={}, results={} items",

src/site/apt/ReleaseNotes.apt.vm

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ Release Notes (Version ${project.version})
99
In any case, never depend on them for your own non-<<<SNAPSHOT>>> releases.
1010
#end
1111

12-
* 1.41.2
13-
14-
* To be done.
12+
* 1.42
13+
14+
* Fixed a bug in <<<MapcodeCodec.encodeToShortest>>> which would not always return the shortest code (see
15+
next bullet). Reproducible with <<<curl -X GET http://localhost:8080/mapcode/to/47.1243/-111.28564/local>>>.
16+
17+
* Fixed a bug where <<<Encoder.encode>>> would sometime retrieve more than one result even if result set
18+
was limited to 1 result.
1519

1620
[]
1721

1822
* 1.41.1
19-
23+
2024
* Added convenience method to Mapcode.
2125

2226
[]

0 commit comments

Comments
 (0)