locationtech / locationtech/spatial4j
Double resolution trimmed in GeoJSONWriter
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 961
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
I'm wondering if there is a reason for setting the lat/lon resolution in GeoJSONWriter to 6 decimal places?
I came across the following SW, NE bounding box from a geocoder
(53.3747317, -2.2614302
53.3747324, -2.2608337)
The GeoJSONWriter (using JtsSpatialContext.GEO) returned the following:
{
"type": "Polygon",
"coordinates": [
[
[
-2.26143,
53.374732
],
[
-2.26143,
53.374732
],
[
-2.260834,
53.374732
],
[
-2.260834,
53.374732
],
[
-2.26143,
53.374732
]
]
]
}
The first and second point are identical, which threw an exception when I tried to index it within Elasticsearch.
Is there an alternative way to convert the Shape to GeoJSON so it does not trim the values?
In the meantime, I am using BigDecimal.valueOf(doubleValue).toPlainString(). Is that something that can / should be changed in Spatial4j?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at GeoJSONWriter and trace how coordinate resolution is selected for JtsSpatialContext.GEO. Reproduce the reported bounding box output, then verify that the resulting GeoJSON preserves sufficient coordinate precision and does not create duplicate points that Elasticsearch rejects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100