Skip to content

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