Skip to content

Conversation

@tschaub
Copy link
Member

@tschaub tschaub commented Aug 11, 2017

This adds getLength() and getArea() methods for doing spherical calculations on geometries. By default, the mean radius of the earth is used (from the WGS84 ellipsoid). And by default, geometries are assumed to be in Web Mercator. Both the sphere radius and the projection can be provided as options.

Previously, spherical calculations used by ol.proj.pointResolution() were using the radius for the Clarke 1866 Authalic Sphere. I'm not sure where this came from, but I think using the mean radius with WGS84 ellipsoid values is the right thing to do.

Tacking these functions onto ol.Sphere is awkward, because users never need to construct a sphere. It would be nice to have ol.sphere instead. We can get rid of the ol.Sphere constructor and use ol.sphere in a major release. For now, ol package users can still have nice things:

import sphere from 'ol/sphere';
// ...
sphere.getArea(polygon);

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! The measure.html example could be simplified now, using the new functions. But that doesn't need to be part of this pull request.

@tschaub tschaub merged commit f2c51cb into openlayers:master Aug 11, 2017
@tschaub tschaub deleted the sphere branch August 11, 2017 02:47
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

Successfully merging this pull request may close these issues.

2 participants