diff --git a/spec/geo_spec.cr b/spec/geo_spec.cr new file mode 100644 index 0000000..eeb7f1b --- /dev/null +++ b/spec/geo_spec.cr @@ -0,0 +1,27 @@ +require "./spec_helper" + +describe Geo do + context "DISTANCE_UNITS" do + it do + distance_units = { + :centimeters, + :centimetres, + :degrees, + :feet, + :inches, + :kilometers, + :kilometres, + :meters, + :metres, + :miles, + :millimeters, + :millimetres, + :nautical_miles, + :radians, + :yards, + } + + Geo::DISTANCE_UNITS.should eq(distance_units) + end + end +end diff --git a/src/geo.cr b/src/geo.cr index 0506838..c63ff8f 100644 --- a/src/geo.cr +++ b/src/geo.cr @@ -1,10 +1,14 @@ require "convex_hull" require "geohash" require "geo_bearing" +require "haversine" require "./geo/utils" require "./geo/coord" require "./geo/polygon" +require "./geo/distance" module Geo VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }} + + DISTANCE_UNITS = Haversine::FACTORS.keys end diff --git a/src/geo/distance.cr b/src/geo/distance.cr index 932924f..1936f78 100644 --- a/src/geo/distance.cr +++ b/src/geo/distance.cr @@ -1,5 +1,3 @@ -require "haversine" - module Geo struct Coord # Calculates distance to `other`.