Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Polygon.toJson() does not serialize double values with precisions over 8 digits properly

Open
#1,085 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Start at Polygon.toJson() and trace how the polygon's coordinate values are serialized. Reproduce the issue with the latitude and longitude values in the report, then verify that the resulting JSON preserves the reported precision. The payload does not name a source file or test, so those will need to be located in the repository.

Written by the indexing model from the issue text.

Description

GeoJson

When I covert the lat, lan values below to polygon and convert the polygon to json using toJson method it removes some digits from lat, lan values(it takes just 6 - 7 digits).

Lat Lan
34.8859309407532 -93.1640625
-15.6230368315283 -82.265625
-22.917922936146 -35.15625
-7.01366792756663 18.28125
45.5832897560063 2.4609375
54.3677585240684 -64.3359375

Here is the json output
{
"type": "Polygon",
"coordinates": [
[
[
-93.1640625,
34.8859309
],
[
-82.265625,
-15.6230368
],
[
-35.15625,
-22.9179229
],
[
18.28125,
-7.0136679
],
[
2.4609375,
45.5832898
],
[
-64.3359375,
54.3677585
],
[
-93.1640625,
34.8859309
]
]
]
}

it should construct json correctly. could not use the library

Dominant language
Java
Stars
438
Forks
117
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mapbox/mapbox-java

All issues in mapbox/mapbox-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.