Class: Geocoder::Result::PcMiler

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/pc_miler.rb

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #latitude, #longitude, #province, #province_code

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

Instance Method Details

#address(format = :unused) ⇒ Object

sample response: https://singlesearch.alk.com/na/api/search?authToken=&include=Meta&query=Feasterville

{
"Err": 0,
"ErrString": "OK",
"QueryConfidence": 1,
"TimeInMilliseconds": 93,
"GridDataVersion": "GRD_ALK.NA.2023.01.18.29.1.1",
"CommitID": "pcmws-22.08.11.0-1778-g586da49bd1b: 05/30/2023 20:14",
"Locations": [
  {
    "Address": {
      "StreetAddress": "",
      "LocalArea": "",
      "City": "Feasterville",
      "State": "PA",
      "StateName": "Pennsylvania",
      "Zip": "19053",
      "County": "Bucks",
      "Country": "US",
      "CountryFullName": "United States",
      "SPLC": null
    },
    "Coords": {
      "Lat": "40.150025",
      "Lon": "-75.002511"
    },
    "StreetCoords": {
      "Lat": "40.150098",
      "Lon": "-75.002827"
    },
    "Region": 4,
    "POITypeID": 0,
    "PersistentPOIID": -1,
    "SiteID": -1,
    "ResultType": 4,
    "ShortString": "Feasterville",
    "GridID": 37172748,
    "LinkID": 188,
    "Percent": 6291,
    "TimeZone": "GMT-4:00 EDT"
  }
]
}


51
52
53
54
55
56
# File 'lib/geocoder/results/pc_miler.rb', line 51

def address(format=:unused)
  [street, city, state, postal_code, country]
  .map { |i| i == '' ? nil : i }
  .compact
  .join(', ')
end

#cityObject



67
68
69
# File 'lib/geocoder/results/pc_miler.rb', line 67

def city
  address_data["City"]
end

#coordinatesObject



58
59
60
61
# File 'lib/geocoder/results/pc_miler.rb', line 58

def coordinates
  coords = data["Coords"] || {}
  [coords["Lat"].to_f, coords["Lon"].to_f]
end

#countryObject



83
84
85
# File 'lib/geocoder/results/pc_miler.rb', line 83

def country
  address_data["CountryFullName"]
end

#country_codeObject



87
88
89
# File 'lib/geocoder/results/pc_miler.rb', line 87

def country_code
  address_data["Country"]
end

#postal_codeObject



79
80
81
# File 'lib/geocoder/results/pc_miler.rb', line 79

def postal_code
  address_data["Zip"]
end

#stateObject



71
72
73
# File 'lib/geocoder/results/pc_miler.rb', line 71

def state
  address_data["StateName"]
end

#state_codeObject



75
76
77
# File 'lib/geocoder/results/pc_miler.rb', line 75

def state_code
  address_data["State"]
end

#streetObject



63
64
65
# File 'lib/geocoder/results/pc_miler.rb', line 63

def street
  address_data["StreetAddress"]
end