Opened 4 years ago

Closed 4 years ago

#2832 closed defect (fixed)

Rounding issue in raw geojson

Reported by: gBecker Owned by: jng
Priority: medium Milestone: 4.0
Component: Feature Service Version:
Severity: minor Keywords:
Cc: External ID:

Description

There is a rounding issue with the geojson format MapGuide 4 is producing. When you have a number like for example 476706.999999999 in your coordinates (request with a precision set to 7) then this leads to a number with a decimal point at the end

476707.

instead of just

476706

You can see the original data I requested with SELECTFEATURES in the screenshot from developer tools. Although it is shown in web developer console there is an error message when requesting in the browser:

SyntaxError: JSON.parse: unterminated fractional number at line 1 column 317 of the JSON data

So, OpenLayers doesn't show this geojson. Of course, I can choose a higher precision to solve the issue with this specific coordinate but I have plenty of other coordinates that have the same problem even with a higher precision.

By the way, with MapGuide Rest the geojson output is correct.

Change History (5)

comment:1 by gBecker, 4 years ago

Sorry, trac doesn't allow me to let me attach the sreenshot!

comment:2 by jng, 4 years ago

Owner: set to jng

comment:3 by jng, 4 years ago

Do you have the WKT of the offending geometry that is blowing up the operation?

comment:4 by gBecker, 4 years ago

Unfortunatly all editors I tried produce WKT with numbers rounded to 3 digits. So I tried to adjust it by hand. I don't know if this helps:

POLYGON ((486750.766 5784456.011, 486728.359 5784446.655, 486706.876 5784437.296, 486690.777 5784429.9, 486676.834 5784422.189, 486659.232 5784411.444, 486646.087 5784401.948, 486648.067 5784395.8, 486651.508 5784385.121, 486652.819 5784381.05, 486655.289 5784373.384, 486657.158 5784367.581, 486667.279 5784336.166, 486668.836 5784331.334, 486672.166 5784320.995, 486679.091 5784299.499, 486680.004 5784296.665, 486657.192 5784287.844, 486652.536 5784286.043, 486650.669 5784285.322, 486652.693 5784279.674, 486646.319 5784277.197, 486607.544 5784262.129, 486611.782 5784254.856, 486619.71 5784241.874, 486641.348 5784265.104, 486664.672 5784243.409, 486693.607 5784248.872, 486704.871 5784250.998, 486706.382 5784246.318, 486711.838 5784229.225, 486715.044 5784219.176, 486735.317 5784222.052, 486746.793 5784224.479, 486746.643 5784225.14, 486753.34 5784226.848, 486760.007 5784228.698, 486766.554 5784230.807, 486772.999999999 5784233.246, 486779.257 5784236.075, 486785.374 5784239.294, 486797.129 5784246.463, 486802.768 5784250.362, 486813.835 5784258.681, 486814.204 5784258.151, 486825.248 5784266.724, 486827.881 5784268.769, 486828.191 5784268.399, 486846.766 5784284.326, 486847.798 5784285.214, 486835.598 5784319.835, 486820.899 5784364.066, 486835.747 5784374.205, 486823.91 5784435.848, 486846.995 5784450.096, 486846.814 5784457.889, 486846.658 5784464.636, 486846.617 5784468.126, 486846.57 5784470.327, 486846.732 5784481.668, 486846.22 5784483.886, 486843.72 5784484.496, 486841.391 5784484.935, 486820.463 5784478.249, 486799.031 5784472.704, 486775.631 5784464.912, 486750.766 5784456.011))

comment:5 by jng, 4 years ago

Resolution: fixed
Status: newclosed

In 9826:

Fix incorrect trailing decimal 0s truncation in MgUtil::DoubleToString, exposed through converting certain geometry coordinates to GeoJSON. Test cases added to catch this.

Fixes #2832

Note: See TracTickets for help on using tickets.