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

Getting too large numbers for Longitude? #758

Closed
haywood1 opened this issue May 27, 2017 · 2 comments
Closed

Getting too large numbers for Longitude? #758

haywood1 opened this issue May 27, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@haywood1
Copy link

haywood1 commented May 27, 2017

For some reason i keep getting latitude in the number of 100822540197861.69 any ideas why. I was hoping more to have hexagons as a half but stayed at 1km and still keep getting this issue.

The code and some of the GeoJSON is here as the GeoJSON is quite large: https://jsfiddle.net/nxcn02dt/

@DenisCarriere DenisCarriere changed the title Getting too large numbers for Latitude? Getting too large numbers for Longitude? May 28, 2017
@DenisCarriere
Copy link
Member

DenisCarriere commented May 28, 2017

@haywood1 Thanks for reporting this, however this bug seems to have larger issues.

I've been able to fix the Longitude issue by using Center coordinates to calculate the xFraction/cellWidth & yFraction/cellHeight.

1. Distance Issue

Also calculating distance([-180, -90], [180, -90]) causes issues in the results when the latitude is the same:

Edit: Not an issue distance([-180, -90], [180, -90]) should equal to 0.

> distance([-180, -90], [180, 90])
20021.369981327753
> distance([-180, -90], [180, -90])
9.557969094904018e-29
> distance([-180, 90], [180, 90])
9.557969094904018e-29
> distance([-180, 90], [180, -90])
20021.369981327753

2. Hexgrid distortion

Would be opened as a separate issue

When the bbox extents becomes larger the grids become more and more distorted.

Solution: This could be resolved by transforming the coordinates to an equidistance projection, applying the grid, then converting back to degrees.

hexgrid([-185, -90, 180, 90], 500, 'kilometers');

Hex Grid using World BBox
image

Hex Triangle Grid
image

@DenisCarriere DenisCarriere added this to the 5.0.0 milestone May 28, 2017
DenisCarriere added a commit that referenced this issue May 28, 2017
* Add longitude tests #758 @turf/hex-grid

* Drop meta from tests

* Center x & y Fraction using mid point

* Add tests for distance
@DenisCarriere DenisCarriere modified the milestones: 4.4.0, 5.0.0 May 28, 2017
@DenisCarriere
Copy link
Member

DenisCarriere commented May 28, 2017

Published a patch release for @turf/hex-grid v4.3.1 with the fix.

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

2 participants