Project

gpsutils

0.0
No commit activity in last 3 years
No release in over 3 years
Small ruby library for working with GPS coordinates.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.12
~> 10.0
~> 3.0
 Project Readme

GpsUtils

Build Status Code Climate Test Coverage

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 install

Using Bundler with github

Edit you Gemfile and add the following line:

gem 'gpsutils', :git => 'https://github.com/megamoose/gpsutils.git'

Then run:

$ bundle install

Using locally build gem-file

Clone the repository from github:

$ git clone https://github.com/megamoose/gpsutils.git gpsutils
$ cd gpsutils

Build the gem-file:

$ gem build gpsutils.gemspec

Install the gem-file:

$ gem install gpsutils-*.gem

Usage

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? location

Sort 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)
end

License

This code is free to use under the terms of the MIT license.