
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
h1. GeoDistance - geo distance calculations
Calculates the Geo distance between two locations using longitude and latitude. This is done using "pure" Math formulas without resorting to Active Record or SQL DB functionality
This gem is meant to be a replacement for those geo distance utils out there that use built in SQL DB functionality for their calculations!
The formulas curently supported are
h2. Install & Usage
require 'geo-distance' it "should work" do lon1 = -104.88544 lat1 = 39.06546 lon2 = -104.80 lat2 = lat1 dist = GeoDistance.distance( lat1, lon1, lat2, lon2 ) # in radians dist = GeoDistance::Haversine.geo_distance( lat1, lon1, lat2, lon2 ).to_meters # Change to (lng, lat) mode GeoPoint.coord_mode = :lng_lat p1, p2 = [[lon1, lat1].geo_point, [lon2, lat2].geo_point] dist = GeoDistance::Haversine.geo_distance( lon1, lat1, lon2, lat2) dist = GeoDistance::Haversine.geo_distance( p1, p2).to_miles puts "the distance from #{lat1}, #{lon1} to #{lat2}, #{lon2} is: #{dist.meters} meters" dist.feet dist.meters dist.kms dist.miles end
h2. Distance API
The call to distance returns an instance of GeoDistance
@dist = GeoDistance::Haversine.distance( lat1, lon1, lat2, lon2 )@
The #kms, #meters, #miles and #feet methods return an instance og GeoUnit
@dist.kms@
h3. Setting default algorithm
You can also set a default algorithm to use... The following will use the Haversine algorithm:
GeoDistance.default_algorithm = :haversine dist = GeoDistance.distance( lat1, lon1, lat2, lon2 )
GeoDistance is used in the "geo_magic":https://github.com/kristianmandrup/geo_magic gem
h2. Contributing to geo-distance
h2. Copyright
Copyright (c) 2011 Kristian Mandrup. See LICENSE.txt for further details.
FAQs
Unknown package
We found that geo-distance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.