Giter VIP home page Giter VIP logo

osgb's Introduction

OSGB

This is a library that converts between British (and Irish) grid references and latitude and longitude co-ordinates. It is theoretically accurate to about 1m, but realistically you can expect precision of about 10m. Good for google map and GPS use, not recommended for surveying nuclear power plants. I don't suppose people often use grid references for that.

Installation

In Rails 3, add this to your Gemfile and run bundle install.

gem "osgb"

In Rails 2, add this to your environment.rb file.

config.gem "osgb"

Alternatively, you can install it as a plugin.

rails plugin install git://github.com/spanner/osgb.git

Status

Early days: activerecord interface hasn't settled down, some refactoring likely, bugs entirely possible. The basic algorithms are ancient and sound, though.

Usage

You don't need to make any explicit reference to the gem. It adds conversion and utility methods to the String class:

"SD28687846".is_gridref?                # -> true
"SD28687846".to_latlng                  # -> [54.196915, -3.094684]
"SD28687846".to_wgs84                   # -> [54.196915, -3.094684]
"SD28687846".to_osgb36                  # -> [54.196763, -3.093320]
"1.056789, 55.98978607".is_latlng?      # -> true

There is a Point class that's quite useful for geodetic calculations, and we provides some (tentative) help for your ActiveRecord classes:

class Checkpoint < ActiveRecord::Base
  has_gridref :lat => 'lat', 
              :lng => 'lng', 
              :gridref => 'gridref',
              :validation => false,
              :converstion => true

The :lat, :lng and :gridref keys should pass in the names of the relevant columns if they don't match these defaults.

Geodesy

By default we place our lat/long points on the WGS84 datum, since that's most relevant for online use. You can specify :osgb36 to keep them local:

"SD28687846".to_latlng(:osgb36)

which involves a bit less processing since that's the datum used by the grid. If you want to use some other datum you will need to define a Helmert transformation from OSGB36 to that ellipsoid.

Bugs and features

Github issues please, or for little things an email or github message is fine.

Author & Copyright

Copyright 2008-2011 Will at spanner.org.

Released under the same terms as Ruby

osgb's People

Contributors

will-r avatar

Watchers

will avatar James Cloos avatar

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.