Implement Truncate module - drop to 6 decimal precision
See original GitHub issueJust generated some random points/polygons using turf-random
and the coordinates have 14 digit precision, which is a bit excessive for a completely randomly generated feature.
Proposal
Drop to 6 decimals according to the GeoJSON spec RFC 7946 (Everything you need to know by @tmcw)
random('point')
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
70.46923055566859,
58.11088890802906
]
},
"properties": {}
}
]
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to truncate float values? - python - Stack Overflow
def truncate(f, n): '''Truncates/pads a float f to n decimal places without rounding''' s = '{}'.format(f) if 'e' in s or 'E' in...
Read more >Truncate numbers to decimal places in Python - Kodify.net
How to truncate numbers to a number of decimal places in Python? When we truncate values, we remove the decimal portion of a...
Read more >Decimal.Truncate(Decimal) Method (System) - Microsoft Learn
Returns the integral digits of the specified Decimal; any fractional digits are discarded.
Read more >decimal — Decimal fixed point and floating point arithmetic ...
The decimal module provides support for fast correctly rounded decimal floating point arithmetic. It offers several advantages over the float datatype: Decimal ......
Read more >How to remove all decimals from a number using Python?
There are numerous mathematical functions defined in math( ) module. To use the truncate function, first, the math module must be imported, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
New module released 🚀 💥
Turf
3.9.0
now has@turf/truncate
, this module truncates the geometry precision for all GeoJSON coordinates, more details can be found within this issue.FYI: I can confirm that this module is “public” 🤓
We can close this issue when we’ve confirmed the latest
@turf/turf
is still working for everyone.CC: @Turfjs/ownership
Nice one @DenisCarriere , this will be handy!