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

collect by hexgrid has the same properties #1340

Closed
mysisi opened this Issue Mar 29, 2018 · 7 comments

Comments

Projects
None yet
3 participants
@mysisi

mysisi commented Mar 29, 2018

hey, i have some trouble with collect api, when the first argument is a feature collection created from hexgrid, the result features have the same outProperty, triangleGrid or squareGrid are ok...

@rowanwins

This comment has been minimized.

Member

rowanwins commented Mar 29, 2018

Hi @mysisi

Which version of turf are you using? I did resolve this bug although the patch is currently only available in v6 with the standalone module. The bundled turf is still running as v5 and so the patch hasn't been incorporated yet.

Cheers

@hw2312

This comment has been minimized.

hw2312 commented Apr 3, 2018

I'm using mapbox-gl-js/v0.44.1 and running into the same issue where all properties are the same for hexgrids.

@rowanwins

This comment has been minimized.

Member

rowanwins commented Apr 3, 2018

Hi @hw2312

The same question for you as above - what version of turf/hexgrid are you using?

@hw2312

This comment has been minimized.

hw2312 commented Apr 3, 2018

@rowanwins I've been using the CDN script <script src='https://npmcdn.com/@turf/turf/turf.min.js'></script>. Is there a way to add turf as a standalone module for web purposes?

[EDIT]
I saw your comment about v6 having resolved this issue and tried adding <script src='https://cdn.jsdelivr.net/npm/@turf/hex-grid@6.0.1/index.js'></script> at the head of my HTML file, but ran into the following error:

Uncaught ReferenceError: exports is not defined at index.js:2

Would you have any suggestions on how to resolve this? Thanks!

@mysisi

This comment has been minimized.

mysisi commented Apr 4, 2018

@rowanwins using the latest version 5.1.6

@rowanwins

This comment has been minimized.

Member

rowanwins commented Apr 4, 2018

When using a single module in a browser application people are typically using them via a build tool like webpack, these build tools compile all the dependencies and make them browser ready.

There are some fairly simple instructions on the getting started pages for how to generate a custom built browser-ready script using browserify (see section titled 'Creating custom builds for use in the browser').

Give those instructions a while and let me know how you get on

@rowanwins rowanwins closed this May 10, 2018

@mysisi

This comment has been minimized.

mysisi commented May 15, 2018

im using like this:

var turf = require("@turf/turf")

var bbox = [-10,-10,10,10];
var cellSide = 300;
var options = {units: 'miles'};
var hexgrid = turf.hexGrid(bbox, cellSide, options);

var pt1 = turf.point([0,0], {population: 400});
var pt2 = turf.point([-1,-3], {population: 600});
var pointFC = turf.featureCollection([pt1, pt2, pt3, pt4, pt5]);

var collected = turf.collect(hexgrid, pointFC, 'population', 'values');

when you log collected you will see the feature properties collect will always be the same as the first feature properties.
when i use turf-hex-grid, it's ok....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment