Skip to content
Snippets Groups Projects
Commit 9240e818 authored by Alex Reisner's avatar Alex Reisner
Browse files

Add bounding box calculation tests.

parent 4f309a9e
No related branches found
No related tags found
No related merge requests found
......@@ -176,6 +176,26 @@ class GeocoderTest < Test::Unit::TestCase
assert_equal [0.0, 0.5], Geocoder::Calculations.geographic_center([p1, p2])
end
def test_bounding_box_calculation_in_miles
center = [51, 7] # Cologne, DE
radius = 10 # miles
dlon = radius / Geocoder::Calculations.latitude_degree_distance
dlat = radius / Geocoder::Calculations.longitude_degree_distance(center[0])
corners = [50.86, 6.77, 51.14, 7.23]
assert_equal corners.map{ |i| (i * 100).round },
Geocoder::Calculations.bounding_box(center[0], center[1], radius).map{ |i| (i * 100).round }
end
def test_bounding_box_calculation_in_kilometers
center = [51, 7] # Cologne, DE
radius = 111 # kilometers (= 1 degree latitude)
dlon = radius / Geocoder::Calculations.latitude_degree_distance(:km)
dlat = radius / Geocoder::Calculations.longitude_degree_distance(center[0], :km)
corners = [50, 5.41, 52, 8.59]
assert_equal corners.map{ |i| (i * 100).round },
Geocoder::Calculations.bounding_box(center[0], center[1], radius, :units => :km).map{ |i| (i * 100).round }
end
# --- bearing ---
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment