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

Imperial Area Calculations #320

Closed
CrokinoleMaster opened this issue Sep 4, 2014 · 6 comments
Closed

Imperial Area Calculations #320

CrokinoleMaster opened this issue Sep 4, 2014 · 6 comments

Comments

@CrokinoleMaster
Copy link

Hi, Just wanted to let you know that the Imperial area calculations are off by quite a bit. Around 30%

@jacobtoye
Copy link
Member

The conversion from metric to imperial can be seen here: https://github.com/Leaflet/Leaflet.draw/blob/master/src/ext/GeometryUtil.js#L32

The method for calculating an area on a sphere is based off here: http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409

Could you give some example of where the actual area is out by 30%?

@CrokinoleMaster
Copy link
Author

It's the number of acres that is off. I've just been using metric, getting the hectares then converting to acres. I'll take some screenshots when I have time!

@CrokinoleMaster
Copy link
Author

I have an example field that is suppose to be ~160 acres. The default code calculates it incorrectly

incorrect

incorrect

But doing this then makes it correct since the metric area appears to be good.

            // area *= 0.836127; // Square yards in 1 meter
            //
            // if (area >= 3097600) { //3097600 square yards in 1 square mile
            //  areaStr = (area / 3097600).toFixed(2) + ' mi²';
            // } else if (area >= 4840) {//48040 square yards in 1 acre
            //  areaStr = (area / 4840).toFixed(2) + ' acres';
            // } else {
            //  areaStr = Math.ceil(area) + ' yd²';
            // }
                areaStr = (area * 0.0001 * 2.47105).toFixed(2) + ' acres';

correct

@CrokinoleMaster
Copy link
Author

well that was easy! Thanks!

@jacobtoye
Copy link
Member

Awesome stuff @huaruiwu! Silly bug from me :( I was converting from metres to yards incorrectly.

@CrokinoleMaster
Copy link
Author

no problem. Thanks for all the leaflet work. It's great!

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

No branches or pull requests

2 participants