Class: Georeference::GeoLocate::Response
- Inherits:
-
Object
- Object
- Georeference::GeoLocate::Response
- Defined in:
- app/models/georeference/geo_locate.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
- #call_api(host, request) ⇒ HTTP object protected
-
#coordinates ⇒ String
Coordinates from the response set.
-
#initialize(request) ⇒ Response
constructor
A new instance of Response.
-
#uncertainty_polygon ⇒ String
Uncertainty_polygon from the response set.
-
#uncertainty_radius ⇒ String
Uncertainty_radius from the response set.
Constructor Details
#initialize(request) ⇒ Response
Returns a new instance of Response.
316 317 318 319 |
# File 'app/models/georeference/geo_locate.rb', line 316 def initialize(request) @result = JSON.parse(call_api(Georeference::GeoLocate::API_HOST, request)) request.succeeded = true if @result['numResults'].to_i > 0 end |
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
313 314 315 |
# File 'app/models/georeference/geo_locate.rb', line 313 def result @result end |
Instance Method Details
#call_api(host, request) ⇒ HTTP object (protected)
343 344 345 |
# File 'app/models/georeference/geo_locate.rb', line 343 def call_api(host, request) Net::HTTP.get(host, request.request_string) end |
#coordinates ⇒ String
Returns coordinates from the response set.
322 323 324 |
# File 'app/models/georeference/geo_locate.rb', line 322 def coordinates @result['resultSet']['features'][0]['geometry']['coordinates'] end |
#uncertainty_polygon ⇒ String
Returns uncertainty_polygon from the response set.
333 334 335 336 |
# File 'app/models/georeference/geo_locate.rb', line 333 def uncertainty_polygon retval = @result['resultSet']['features'][0]['properties']['uncertaintyPolygon'] (retval == 'Unavailable') ? nil : retval['coordinates'][0] end |
#uncertainty_radius ⇒ String
Returns uncertainty_radius from the response set.
327 328 329 330 |
# File 'app/models/georeference/geo_locate.rb', line 327 def uncertainty_radius retval = @result['resultSet']['features'][0]['properties']['uncertaintyRadiusMeters'] (retval == 'Unavailable') ? 3 : retval end |