Skip to content

Improve encoding/decoding consistency in tests #669

Open
2 of 8 issues completed
Open
2 of 8 issues completed
@drinckes

Description

@drinckes

We have known for a long time that the same lat/lng, on different platforms, operating systems and languages will encode to different plus codes (see for example #665). This is down to differences in floating point precision and implementations, as well as different compiler optimisations.

This last is kind of scary because it implies that encodings could change between language/compiler versions.

An alternative is that we stop trying to fight/solve this issue ourselves, and instead make use of the GNU MPFR floating point library.

The main goal of MPFR is to provide a library for multiple-precision floating-point computation which is both efficient and has a well-defined semantics. It copies the good ideas from the ANSI/IEEE-754 standard for double-precision floating-point arithmetic (53-bit significand).

Apart from anything else, this could improve the consistency of plus code encoding/decoding between languages and platforms.

The plus code languages in our repo and the MPFR status are:

Implementation Availability Note
c MPFR is natively in C
cpp there are multiple C++ interfaces for MPFR available. Care will need to be taken to choose one compatible with the other languages.
dart
go the float package references MPFR, it might be good enough?
java
js, js/closure
plpgsql
python
ruby
rust
visualbasic

This is a not insignificant amount of work. I would be interested in thoughts below, and suggest we come to a consensus before embarking on implementing?

Sub-issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions