Opened 4 years ago
Closed 3 years ago
#4908 closed defect (wontfix)
ST_AsGeoJSON in POSTGIS-2.5 different than ST_AsGeoJSON in POSTGIS-3.0
Reported by: | maheshpusala | Owned by: | pramsey |
---|---|---|---|
Priority: | high | Milestone: | PostGIS 3.1.4 |
Component: | postgis | Version: | 2.5.x -- EOL |
Keywords: | Cc: | mloskot |
Description
facing issue as getting different JSON ouput when i am running ST_AsGeoJSON in POSTGIS-2.5 and ST_AsGeoJSON in POSTGIS-3.0, due to this in 2.5 when i am validating on returned geojson it is giving valid boundary, in 3.0 when i am validating on returned geojson it is giving self intersection error
please check and let me know anything i want update from my side, please find server , postgis version details
POSTGRES 12.5 POSTGIS 3.0
POSTGRES 11.6 POSTGIS 3.0
Attachments (3)
Change History (15)
comment:1 by , 4 years ago
by , 4 years ago
Attachment: | postgis_3.0_generated.geojson added |
---|
by , 4 years ago
Attachment: | postgis_2.5_generated.geojson added |
---|
by , 4 years ago
Attachment: | original_boundary.wkt added |
---|
comment:3 by , 4 years ago
attached required examples to debug further 1) oroginal WKT 2) postgis 2.5 converted geojson 3) postgis 3.0 converted geojson
comment:4 by , 4 years ago
This is due to the output coordinates being rounded off slightly in 3.0.
For example, in 2.9 there is a coordinate
-93.1687103416383 41.8543515079768
In 3.0 this is output as:
-93.168710342 41.854351508
This rounding is enough to cause the two polygons containing this point to become adjacent and hence invalid.
Is there a different default precision set in 3.0 GeoJSON output?
comment:5 by , 4 years ago
Actually it might be that with the improvements to floating-point output in 3.0 the ST_AsGeoJSON
default for precision (9 decimal digits) is now working (whereas before it was just outputting full precision).
This is effectively a regression. Also, it shows how having an output precision less than "full" can cause unexpected loss of data. Most other text output functions use precision=15 as their default. We should consider changing ST_AsGeoJSON
to use this valud as well.
comment:6 by , 4 years ago
Cc: | added |
---|
follow-up: 8 comment:7 by , 4 years ago
Actually it might be that with the improvements to floating-point output in 3.0
One correction, the improvements to floating point output were introduced in 3.1. The problem here comes from the change from a default 15 decimal digits to 9 which predates that change.
In any case, ST_AsGeoJSON has an option to set the number of decimal digits to however many you need and 15 decimal digits does not guarantee full precision output either. The good thing about 3.1 is that you can see a ask for a huge number of decimal digits and you'll only get significant ones (way less).
comment:8 by , 4 years ago
Replying to Algunenano:
Thanks for the clarification.
In any case, ST_AsGeoJSON has an option to set the number of decimal digits to however many you need
True, but that requires a code change by the user.
15 decimal digits does not guarantee full precision output either.
No, but it should make topology collapse errors much less likely.
comment:9 by , 4 years ago
Milestone: | PostGIS 3.1.2 → 3.1.3 |
---|
comment:12 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
As noted, if you want more precision, you can have it. We deliberately reduced output precision of GeoJSON because the pointless extra volume of precision has knock-on in things like data extracts and feeding web clients. It's a choose-your-poison situation and poison we have chosen is the occasional dimensional collapse.
Replying to maheshpusala: