class MiamiDadeGeo::Address

A street address in Miami-Dade County. Lazily makes up to two SOAP requests: one to get the X and Y coordinates, and one to convert them to standard latitude and longitude.

Can raise an [InvalidAddressError] when lazily making the initial SOAP request if the given address does not exist.

@raise [InvalidAddressError]

Attributes

address[R]

@!attribute [r] address @return [String] the street address

feature[R]
zip[RW]

@!attribute [rw] zip @return [String] the ZIP code

Public Class Methods

new(feature) click to toggle source
# File lib/miami_dade_geo/address.rb, line 90
def initialize(feature)
  @feature = feature
end
new_from_address(address) click to toggle source

Construct the address object @param address [String] the street address

# File lib/miami_dade_geo/address.rb, line 32
def self.new_from_address(address)
  xy = AddrXyClient.instance.xy_for_address(address)

  Coordinate.new(xy).address
end
new_from_feature(feature) click to toggle source
# File lib/miami_dade_geo/address.rb, line 38
def self.new_from_feature(feature)
  new feature
end

Public Instance Methods

coordinate() click to toggle source

@return [Coordinate] a coordinate object representing where this address even is

# File lib/miami_dade_geo/address.rb, line 44
def coordinate
  @coordinate ||= Coordinate.new xy_addr
end
lat() click to toggle source

@return [Float] the latitude of the address

# File lib/miami_dade_geo/address.rb, line 69
def lat
  coordinate.lat
end
long() click to toggle source

@return [Float] the longitude of the address

# File lib/miami_dade_geo/address.rb, line 74
def long
  coordinate.long
end
munic_code() click to toggle source

@return [Integer] the municipality code of the address

# File lib/miami_dade_geo/address.rb, line 64
def munic_code
  @munic_code ||= xy_addr[:munic_code].to_i
end
municipality() click to toggle source

Constructs and returns a {Municipality} object. Makes one SOAP request. @return [Municipality]

# File lib/miami_dade_geo/address.rb, line 80
def municipality
  @municipality ||= Municipality.new_with_code(munic_code)
end
x() click to toggle source

@return [Float] the x-coordinate of the address

# File lib/miami_dade_geo/address.rb, line 49
def x
  coordinate.x
end
y() click to toggle source

@return [Float] the y-coordinate of the address

# File lib/miami_dade_geo/address.rb, line 54
def y
  coordinate.y
end

Private Instance Methods

addr_xy_client() click to toggle source
# File lib/miami_dade_geo/address.rb, line 100
def addr_xy_client
  AddrXyClient.instance
end
xy_addr() click to toggle source
# File lib/miami_dade_geo/address.rb, line 94
def xy_addr
  return @xy_addr if defined? @xy_addr

  @xy_addr = addr_xy_client.xy_for_address(address)
end