Small ruby library for working with GPS coordinates.
You can install the package from rubygems or github using Bundler or create your own package from the source code.
Edit you Gemfile and add the following line:
gem 'gpsutils'Then run:
$ bundle installEdit you Gemfile and add the following line:
gem 'gpsutils', :git => 'https://github.com/megamoose/gpsutils.git'Then run:
$ bundle installClone the repository from github:
$ git clone https://github.com/megamoose/gpsutils.git gpsutils
$ cd gpsutilsBuild the gem-file:
$ gem build gpsutils.gemspecInstall the gem-file:
$ gem install gpsutils-*.gemDetermine whether or not a given location (point) is within an area (bounding box):
# Follow instructions in the installation section.
require 'gpsutils'
# Latitude, Longitude.
location = GpsUtils::Point.new(-22.955776, -43.536438)
# North-West corner.
nw = GpsUtils::Point.new(-22.746120, -43.795060)
# South-East corner.
se = GpsUtils::Point.new(-23.076347, -43.101608)
# North-West point, South-East point.
area = GpsUtils::BoundingBox.new(nw, se)
area.cover? locationSort positions (Points) by distance to location (Point):
# Follow instructions in the installation section.
require 'gpsutils'
# Latitude, Longitude.
location = GpsUtils::Point.new(-22.955776, -43.536438)
positions = []
positions.push(GpsUtils::Point.new(-23.560112, -46.642043))
positions.push(GpsUtils::Point.new(-12.994417, -38.508040))
positions.sort_by! do |position|
location.distance(position)
endThis code is free to use under the terms of the MIT license.