Socket
Book a DemoInstallSign in
Socket

geo-calculator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-calculator

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

GeoCalculator

GeoCalculator is an extraction of the calculation methods from the Ruby Geocoder gem. Its purpose is to allow the geocoding calculation methods for models that already have latitude and longitude (obtained from the browser or an iphone app) to use distance calculations to find nearby model instances. It was extracted for use in Heat.

Installation

Add this line to your application's Gemfile:

gem 'geo-calculator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install geo-calculator

Usage

Add the line include Geocoder::Store::ActiveRecord into your model like so:

# app/models/location.rb
class Location < ActiveRecord::Base
  include Geocoder::Store::ActiveRecord

  def self.geocoder_options
    {
      latitude: 'latitude',
      longitude: 'longitude',
      units: :mi
    }
  end
end

make sure that your model has a latitude and longitude column.

Make sure to define the geocoder_options method, and specify the names of your latitude / longitude columns plus the units you want to use.

This will give your model a bunch of calculation methods, like .near and .within_bounding_box. See them all here

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 13 Jan 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.