class MiamiDadeGeo::Coordinate
Public Class Methods
new(opts)
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 6 def initialize(opts) if opts[:x] && opts[:y] initialize_from_xy opts elsif opts[:lat] && opts[:long] initialize_from_latlong opts else fail ArgumentError "Can't initialize without x & y or lat & long" end end
Public Instance Methods
address()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 59 def address return @address if defined? @address feature = get_closest_feature_client.find_feature(xy, 'GeoAddress') @address = Address.new_from_feature feature end
initialize_from_latlong(opts)
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 22 def initialize_from_latlong(opts) @lat = opts[:lat].to_f @long = opts[:long].to_f end
initialize_from_xy(opts)
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 17 def initialize_from_xy(opts) @x = opts[:x].to_f @y = opts[:y].to_f end
lat()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 39 def lat return @lat if @lat load_latlong_from_xy @lat end
latlong()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 55 def latlong { lat: lat, long: long } end
long()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 45 def long return @long if @long load_latlong_from_xy @long end
x()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 27 def x return @x if @x load_xy_from_latlong @x end
xy()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 51 def xy { x: x, y: y } end
y()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 33 def y return @y if @y load_xy_from_latlong @y end
Private Instance Methods
get_closest_feature_client()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 93 def get_closest_feature_client GetClosestFeatureClient.instance end
latlong_client()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 97 def latlong_client LatlongClient.instance.savon end
load_latlong_from_xy()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 80 def load_latlong_from_xy body = latlong_client. call(:get_lat_long_dec_from_xy, message: { 'X' => x.to_s, 'Y' => y.to_s} ). body resp = body[:get_lat_long_dec_from_xy_response] result = resp[:get_lat_long_dec_from_xy_result] @lat = result[:double][1].to_f @long = result[:double][0].to_f end
load_xy_from_latlong()
click to toggle source
# File lib/miami_dade_geo/coordinate.rb, line 67 def load_xy_from_latlong body = latlong_client. call(:get_x_yfrom_lat_long_dec, message: { 'LNG' => long.to_s, 'LAT' => lat.to_s}). body resp = body[:get_x_yfrom_lat_long_dec_response] result = resp[:get_x_yfrom_lat_long_dec_result] @x = result[:double][0].to_f @y = result[:double][1].to_f end