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

Fix circle radius calculation #7338

Merged
merged 1 commit into from Aug 20, 2014

Conversation

Projects
None yet
3 participants
@colings86
Copy link
Member

colings86 commented Aug 19, 2014

This change fixes the creation circle shapes o it calculates it correctly instead of essentially using the diameter as the radius. The radius has to be converted into degrees but calculating the ratio of the desired radius to the circumference of the earth and then multiplying it by 360 (number of degrees around the earths circumference). This issue here was that it was only multiplied by 180 making the result out by a factor of 2. Also made the test for circles actually check to make sure it has the correct centre and radius.

Closes #7301

@colings86 colings86 added the review label Aug 19, 2014

@colings86 colings86 self-assigned this Aug 19, 2014

ShapeBuilder.newCircleBuilder().center(-180, 0).radius("100m").build();
ShapeBuilder.newCircleBuilder().center(0, 90).radius("100m").build();
ShapeBuilder.newCircleBuilder().center(0, -90).radius("100m").build();
double earthCircumference = 40075016.69;

This comment has been minimized.

Copy link
@jpountz

jpountz Aug 20, 2014

Contributor

maybe reuse GeoUtils.EARTH_EQUATOR?

@jpountz

This comment has been minimized.

Copy link
Contributor

jpountz commented Aug 20, 2014

LGTM

@jpountz jpountz removed the review label Aug 20, 2014

Geo: fixes circle radius calculation
This change fixes the creation circle shapes o it calculates it correctly instead of essentially using the diameter as the radius.  The radius has to be converted into degrees but calculating the ratio of the desired radius to the circumference of the earth and then multiplying it by 360 (number of degrees around the earths circumference).  This issue here was that it was only multiplied by 180 making the result out by a factor of 2.  Also made the test for circles actually check to make sure it has the correct centre and radius.

Closes #7301

@colings86 colings86 force-pushed the colings86:fix/7301 branch to f7ae4d9 Aug 20, 2014

@colings86 colings86 merged commit f7ae4d9 into elastic:master Aug 20, 2014

@colings86 colings86 assigned colings86 and unassigned colings86 Aug 21, 2014

@colings86 colings86 deleted the colings86:fix/7301 branch Aug 21, 2014

@clintongormley clintongormley changed the title Geo: fixes circle radius calculation Geo: Fix circle radius calculation Sep 11, 2014

@clintongormley clintongormley changed the title Geo: Fix circle radius calculation Fix circle radius calculation Jun 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.