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

added convert distance method to TurfHelper #481

Merged
merged 3 commits into from
Jun 13, 2017
Merged

Conversation

cammace
Copy link

@cammace cammace commented Jun 13, 2017

Adds the convertDistance method https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/index.js#L396. It also adds support for centimeters and feet.

cc: @zugaldia

if (factor == null) {
throw new TurfException("Invalid unit.");
} else if (!(distance >= 0)) {
throw new TurfException("distance must be a positive number");
Copy link
Member

Choose a reason for hiding this comment

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

Please change the message to Distance must be a positive number. for consistency.

Double factor = factors.get(originalUnit);
if (factor == null) {
throw new TurfException("Invalid unit.");
} else if (!(distance >= 0)) {
Copy link
Member

Choose a reason for hiding this comment

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

This case doesn't seem to be tested (negative distance), only invalid units are.

thrown.expectMessage(startsWith("Invalid unit."));
TurfHelpers.convertDistance(1, "foo");
}

Copy link
Member

Choose a reason for hiding this comment

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

nit: extra space.

@cammace cammace merged commit f7233aa into master Jun 13, 2017
@cammace cammace deleted the cam-turf-helper-convert branch June 13, 2017 21:59
@zugaldia zugaldia mentioned this pull request Jun 20, 2017
10 tasks
@cammace cammace mentioned this pull request Jul 20, 2017
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants