Code Monkey home page Code Monkey logo

geo_units's Introduction

Geo Units

Distance unit functionality (conversions etc.) for Geo libraries. See specs for details.

This gem is used by the geo_point and geo_calc gems and perhaps by others. The aim is that it will contain most of the basic
distance unit functionality required by typical Geo projects.

Usage

in Gemfile:

gem 'geo_units'

Then run the bundler!

$ bundle

Status update (Sept 21, 2011)

GeoUnits is currently undergoing a major refactoring effort in order to group functionality in a more granular fashion, to allow for greater flexibility.
Also, the new GeoUnits will not specifically target use for geo calculations for Earth, but also other globes/worlds, such as in a fantasy setting, planets, suns etc.
Please help in this effort :)

The master branch has now been updated in order to allow specification of the order:
Set the `GeoUnit.default_coords_order` to fit your usage scenario.

`GeoUnit.default_coords_order = :lng_lat`

`GeoUnit.default_coords_order = :lat_lng`

All specs pass again and the dependencies have been updated :)

GeoUnits API

GeoUnits.key(:foot) # will convert any kind of unit into one of (:feet, :meters, :kms, :miles, :radians)
=> :feet
GeoUnits.kms_to :meters, 5 # convert number of one distance unit to another unit
=> 5000  

Core extensions API

2.radians_to(:kms)
=> 222.34  
@2.miles_to(:kms)
=> 3.21

Dms Converter

module GeoUnits::DmsConverter

  • parse_dms(string)
  • to_dms(deg, format = :dms, dp = nil)

Numeric conversions

module GeoUnits::NumericExt

This module is included on the Fixnum and Float classes

  • to_lat
  • to_lng
  • to_dms
  • to_lat_dms
  • to_lon_dms
  • to_rad
  • to_deg
  • normalize_lng
  • normalize_lat
  • normalize_deg(shift)

Using specific GeoUnits modules

The main GeoUnits module consist of various sub-modules that can be used on a case basis.
Including the GeoUnits module will include and extend the base class with all these sub-modules.

class MyGeoThingy
include GeoUnits::Maps # various maps, mapping unit to some distance etc.
extend GeoUnits::Constants # useful geo constants

end

Contributing to geo_units

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright © 2011 Kristian Mandrup. See LICENSE.txt for
further details.

geo_units's People

Contributors

kristianmandrup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

rubyninjas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.