question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement Truncate module - drop to 6 decimal precision

See original GitHub issue

Just 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:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
DenisCarrierecommented, Jan 31, 2017

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

0reactions
rowanwinscommented, Feb 1, 2017

Nice one @DenisCarriere , this will be handy!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found