Permalink
Browse files

new

  • Loading branch information...
2 parents 4aaf3eb + 539c620 commit 3e78e14d21dcbc2097d54da4abebcff3a764bdc2 @kristianmandrup committed Jun 11, 2011
View
@@ -1,5 +1,8 @@
source "http://rubygems.org"
+gem "require_all", "~> 1.2.0"
+gem "sugar-high", "~> 0.4.5.2"
+
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
View
@@ -2,6 +2,18 @@ h1. Geo calculations
Geo Calculation library. Useful functions to add to your geo arsenal, fx when designing your own Geo library.
+h2. Status update (June 10, 2011)
+
+- Major refactoring splitting into more logical file/modular structure
+- Use autoload
+- Extract GeoUnits
+- Extract Dms with converter
+- GeoPoint can now have set :coords_mode which affects how Ruby Core objects such as String and Array are parsed into :lng and :lat.
+
+TODO:
+- The GeoPoint class should be extracted into separate gem, then this geo_calc gem should only have the more generic geo functionality as modules to be included
+where needed in other gems!
+
h2. Install
@require 'geo_calc'@
View
@@ -1 +1 @@
-0.6.1
+0.7.0
View
@@ -1 +1,6 @@
require 'geo_calc/geo_point'
+require 'geo_units'
+
+module GeoCalc
+ autoload :Dms, 'geo_calc/dms'
+end
View
@@ -1,27 +1,26 @@
module GeoCalc
autoload :PrettyPrint, 'geo_calc/pretty_print'
-
- module Calc
- end
end
-module GeoCalc::Calc
- autoload :Bearing, 'geo_calc/calc/bearing'
- autoload :Destination, 'geo_calc/calc/destination'
- autoload :Distance, 'geo_calc/calc/distance'
- autoload :Intersection, 'geo_calc/calc/intersection'
- autoload :Midpoint, 'geo_calc/calc/midpoint'
- autoload :Rhumb, 'geo_calc/calc/rhumb'
+module GeoCalc
+ module Calc
+ autoload :Bearing, 'geo_calc/calc/bearing'
+ autoload :Destination, 'geo_calc/calc/destination'
+ autoload :Distance, 'geo_calc/calc/distance'
+ autoload :Intersection, 'geo_calc/calc/intersection'
+ autoload :Midpoint, 'geo_calc/calc/midpoint'
+ autoload :Rhumb, 'geo_calc/calc/rhumb'
- module All
- def self.included base
- base.send :include, GeoCalc::Calc::Bearing
- base.send :include, GeoCalc::Calc::Destination
- base.send :include, GeoCalc::Calc::Distance
- base.send :include, GeoCalc::Calc::Intersection
- base.send :include, GeoCalc::Calc::Midpoint
- base.send :include, GeoCalc::Calc::Rhumb
- base.send :include, GeoCalc::PrettyPrint
- end
- end
+ module All
+ def self.included base
+ base.send :include, GeoCalc::Calc::Bearing
+ base.send :include, GeoCalc::Calc::Destination
+ base.send :include, GeoCalc::Calc::Distance
+ base.send :include, GeoCalc::Calc::Intersection
+ base.send :include, GeoCalc::Calc::Midpoint
+ base.send :include, GeoCalc::Calc::Rhumb
+ base.send :include, GeoCalc::PrettyPrint
+ end
+ end
+ end
end
@@ -14,7 +14,7 @@ def destination_point brng, dist
# Returns GeoPoint: Destination point
def self.destination_point base_point, brng, dist
- dist = dist / base_point.radius # convert dist to angular distance in radians
+ dist = dist / base_point.earth_radius_km # convert dist to angular distance in radians
brng = brng.to_rad
lat1 = base_point.lat.to_rad
lon1 = base_point.lon.to_rad
@@ -35,7 +35,7 @@ def self.distance_to base_point, point, precision = 4
a = Math.sin(dlat/2) * Math.sin(dlat/2) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dlon/2) * Math.sin(dlon/2)
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a))
- d = base_point.radius * c
+ d = base_point.earth_radius_km * c
d.round(precision)
end
end
@@ -29,7 +29,7 @@ def self.rhumb_distance_to base_point, point
# if dlon over 180° take shorter rhumb across 180° meridian:
dlon = 2*Math::PI - dlon if (dlon > Math::PI)
- dist = Math.sqrt(dlat*dlat + q*q*dlon*dlon) * base_point.radius;
+ dist = Math.sqrt(dlat*dlat + q*q*dlon*dlon) * base_point.earth_radius_km;
dist.round(4) # 4 sig figures reflects typical 0.3% accuracy of spherical model
end
@@ -69,7 +69,7 @@ def rhumb_destination_point brng, dist
# @returns {LatLon} Destination point
def self.rhumb_destination_point base_point, brng, dist
- d = dist / base_point.radius # d = angular distance covered on earth's surface
+ d = dist / base_point.earth_radius_km # d = angular distance covered on earth's surface
lat1 = base_point.lat.to_rad
lon1 = base_point.lon.to_rad
brng = brng.to_rad
Oops, something went wrong.

0 comments on commit 3e78e14

Please sign in to comment.