Class: GPSTools

Inherits:
Object
  • Object
show all
Defined in:
lib/gps_tools.rb

Defined Under Namespace

Classes: Distance, Geometry

Class Method Summary collapse

Class Method Details

.distance(coord1, coord2, unit = "mile") ⇒ Object

Returns the distance in miles (unit = “mile”), kilometers (unit = “km”), or nautical miles (unit = “nm”) between two gps coordinates, coord1 and coord2



5
6
7
8
9
# File 'lib/gps_tools.rb', line 5

def self.distance(coord1, coord2, unit = "mile")
    distance_tool = Distance.new(unit)
    distance = distance_tool.get_distance(coord1[0], coord1[1], coord2[0], coord2[1])
    return distance
end

.filter_by_polygon(polygon, coords) ⇒ Object

Returns a new array containing all coordinates within the given polygon



21
22
23
24
# File 'lib/gps_tools.rb', line 21

def self.filter_by_polygon(polygon, coords)
    geometry = Geometry.new()
    return geometry.filter_by_polygon(polygon, coords)
end

.filter_by_radius(radius, center, coords) ⇒ Object

Returns a new array containing all coordinates within the given radius



36
37
38
39
# File 'lib/gps_tools.rb', line 36

def self.filter_by_radius(radius, center, coords)
    geometry = Geometery.new()
    return geometry.filter_by_radius(radius, center, coords)
end

.in_polygon?(polygon, coord) ⇒ Boolean

Returns a boolean that identifies if a given gps coordinate, coord, is within a given polygon (array of [lat, lng])

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/gps_tools.rb', line 14

def self.in_polygon?(polygon, coord)
    geometry = Geometry.new()
    return geometry.in_polygon?(polygon, coord)
end

.in_radius?(radius, center, coord) ⇒ Boolean

Returns a boolean that identifies if a given gps coordinate, coord, is within a given radius of a center point, center

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/gps_tools.rb', line 29

def self.in_radius?(radius, center, coord)
    geometry = Geometry.new()
    return geometry.in_radius?(radius, center, coord)
end