GpsUtils
Small ruby library for working with GPS coordinates.
Contents
- Installation
- Using Bundler with rubygems
- Using Bundler with github
- Using locally build gem-file
- Usage
- License
Installation
You can install the package from rubygems or github using Bundler or create your own package from the source code.
Using Bundler with rubygems
Edit you Gemfile and add the following line:
gem 'gpsutils'Then run:
$ bundle installUsing Bundler with github
Edit you Gemfile and add the following line:
gem 'gpsutils', :git => 'https://github.com/megamoose/gpsutils.git'Then run:
$ bundle installUsing locally build gem-file
Clone 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-*.gemUsage
Determine 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)
endLicense
This code is free to use under the terms of the MIT license.