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
@!attribute [r] address @return [String] the street address
@!attribute [rw] zip @return [String] the ZIP code
Public Class Methods
# File lib/miami_dade_geo/address.rb, line 90 def initialize(feature) @feature = feature end
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
# File lib/miami_dade_geo/address.rb, line 38 def self.new_from_feature(feature) new feature end
Public Instance Methods
@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
@return [Float] the latitude of the address
# File lib/miami_dade_geo/address.rb, line 69 def lat coordinate.lat end
@return [Float] the longitude of the address
# File lib/miami_dade_geo/address.rb, line 74 def long coordinate.long end
@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
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
@return [Float] the x-coordinate of the address
# File lib/miami_dade_geo/address.rb, line 49 def x coordinate.x end
@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
# File lib/miami_dade_geo/address.rb, line 100 def addr_xy_client AddrXyClient.instance end
# 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