Class: BlacklightMaps::Geometry::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/blacklight/maps/geometry.rb

Overview

This class contains Point objects and methods for working with them

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(points) ⇒ Point

points is an array corresponding to the longitude and latitude values

long, lat


44
45
46
47
# File 'lib/blacklight/maps/geometry.rb', line 44

def initialize(points)
  @long = points[0].to_f
  @lat = points[1].to_f
end

Class Method Details

.from_lat_lon_string(points) ⇒ Object

Creates a new point from from a coordinate string “-50,100” (lat,long)



63
64
65
# File 'lib/blacklight/maps/geometry.rb', line 63

def self.from_lat_lon_string(points)
  new(points.split(',').reverse)
end

Instance Method Details

#normalize_for_searchObject

returns a string that can be used as the value of solr_parameters normalizes any long values >180 or <-180



51
52
53
54
55
56
57
58
59
# File 'lib/blacklight/maps/geometry.rb', line 51

def normalize_for_search
  case
    when @long > 180
      @long -= 360
    when @long < -180
      @long += 360
  end
  [@long,@lat]
end