Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New minor release! Turf 5.1.0 🎉 #1162

Closed
DenisCarriere opened this issue Dec 7, 2017 · 10 comments
Closed

New minor release! Turf 5.1.0 🎉 #1162

DenisCarriere opened this issue Dec 7, 2017 · 10 comments
Assignees
Labels
Milestone

Comments

@DenisCarriere
Copy link
Member

DenisCarriere commented Dec 7, 2017

New minor release! Turf 5.1.0 🎉

TurfJS releases are being tracked using Milestones.

Contributors

Crowdsourced Funding

Why we're looking for support

TurfJS is a community-driven project maintained by a small group of core contributors who work on the project in their spare time. Time is spent supporting users, improving documentation, fixing bugs as well as creating new modules. Your funding will directly go to development costs, marketing campaigns, promotional events & any other financial costs to operate & maintain TurfJS.

In particular, we're looking for corporate sponsors who use TurfJS in revenue-generating ways, either by creating applications for clients, or through use in an app used by customers. Of course individuals are welcome to support us as well if TurfJS has helped you :)

https://opencollective.com/turf

Help TurfJS by becoming a Backer for only 2$/mo.

🚀 New Modules

@turf/center-median

Takes a FeatureCollection of points and calculates the median center, algorithimically. The median center is understood as the point that is requires the least total travel from all other points.

(PR #1122 - Author @muziejus)

@turf/center-mean

Takes a Feature or FeatureCollection and returns the mean center. Can be weighted.

(PR #1089 - Author @muziejus)

artboard 1

@turf/standard-deviational-ellipse

Takes a FeatureCollection and returns a standard deviational ellipse, also known as a “directional distribution.” The standard deviational ellipse aims to show the direction and the distribution of a dataset by drawing an ellipse that contains about one standard deviation’s worth (~ 70%) of the data.

This module mirrors the functionality of Directional Distribution in ArcGIS and the QGIS Standard Deviational Ellipse Plugin

(PR #1120 - Author @muziejus)

screen shot 2017-11-24 at 23 41 13

@turf/ellipse

Takes a Point and calculates the ellipse polygon given two semi-axes expressed in variable units and steps for precision.

(PR #1087 - Author @muziejus)

ellipse

📖 Documentation

  • TurfJS's website has a fresh new look! 🚀 http://turfjs.org (Author @rowanwins PR Initial commit SSR pages turf-www#127)
    • This uses nuxt to generate the pages as static html which should be better for search engines
    • The docs are now all on a single page
    • Built sizes are much better than the current
    • The map moves to a module when its description comes into view, I think this functions reasonably nicely.

🏅 New Features/Enhancements

<script type='module'>
  import {point} from "https://unpkg.com/@turf/helpers?module"

  console.log(point([100, 0]));
</script>

🐛 Bug Fixes

Twitter: https://twitter.com/DenisCarriere/status/938895355541778432
CC: @Turfjs/ownership

@rowanwins
Copy link
Member

Thanks particularly to @muziejus for getting involved in the past month, lots of really valuable contributions, code & thoughts & documentation, so thank you!

@muziejus
Copy link
Collaborator

muziejus commented Dec 7, 2017

Thanks. I've been using Turf on and off as a solution to put my various geospatial analysis on the web in presentations for about a year, but lately I've been getting more and more frustrated w/ ArcMap and QGIS and working between them and Leaflet. Turf takes up a great middle ground, and I'm glad that my solution to "I wish Turf did x" was "Let me try to do it; the worst that happens is the team tells me I was wrong and fixes it."

Turf is also useful towards the curriculum (of sorts) of free, light, JavaScript solutions for scholars in the humanities that I'm designing. I've got high hopes for this little (huge) library, and I have to thank you all for putting it together in the first place!

@brianreavis
Copy link

brianreavis commented Dec 8, 2017

For any turf users out there also using webpack and babel to compile to ES5 for browsers, make sure your test line (if you have one) now matches .mjs files:

rules: [{
  test: /\.m?jsx?$/,
  include: /* ... */,
  use: [{
    loader: 'babel-loader',
    // ...

Otherwise, lines like this one will now creep into your bundle. That, or set resolve.mainFields to prioritize "main" over "module".

@DenisCarriere
Copy link
Member Author

@brianreavis What is creeping into your bundle? the Callback?

For the module bundle, I changed it to .mjs since that will be the new file extension standard for ES Modules, let me know if this is more of a headache then a solution, we can always use turf.es.js as the file extension for ES modules.

@brianreavis
Copy link

@brianreavis What is creeping into your bundle? the Callback?

Just the {bbox, id} shorthand.

For the module bundle, I changed it to .mjs since that will be the new file extension standard for ES Modules, let me know if this is more of a headache then a solution, we can always use turf.es.js as the file extension for ES modules.

I wouldn't worry about it. Just a growing pain! I wasn't familiar with the *.mjs convention, but am now. For anyone else wanting the reading: The Michael Jackson Solution

@DenisCarriere
Copy link
Member Author

Actually {bbox, id} shorthand should be transpiled to ES5... 🤔 Which isn't happening... I'll look into the new buble Rollup configuration.

@DenisCarriere
Copy link
Member Author

Nevermind.. buble is transpiling the code to proper ES5 (without shorthand), try using the main in the package.json.

https://unpkg.com/@turf/meta@5.1.0/main.js

main.js

function flattenEach(geojson, callback) {
    geomEach(geojson, function (geometry, featureIndex, properties, bbox, id) {
        // Callback for single geometry
        var type = (geometry === null) ? null : geometry.type;
        switch (type) {
        case null:
        case 'Point':
        case 'LineString':
        case 'Polygon':
            callback(helpers.feature(geometry, properties, {bbox: bbox, id: id}), featureIndex, 0);
            return;
        }

@brianreavis
Copy link

brianreavis commented Dec 8, 2017

Yep, that all is working fine! The main kicker is that webpack picks "module" over "main" by default (documentation here). Again, no problem with turf – just a bit of a head scratcher on the tooling side if you're not aware :)

Edit: updated my original comment to note the resolve.mainFields trick.

@DenisCarriere
Copy link
Member Author

@brianreavis Thanks for the heads up, moving forward more and more libraries will support "module" by default since there are many benefits of using ES Modules and most popular bundlers now support it (Webpack, Rollup). One of my personal favorites is the ability to import an ES module directly in the browser (Chrome 61+) without even having to bundle it.

Using "module" directly in Chrome

<script type='module'>
  import {point} from "https://unpkg.com/@turf/helpers?module"

  console.log(point([100, 0]));
</script>

@DenisCarriere
Copy link
Member Author

Seems like most v5.1 issues have now been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants