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.
338 339 340 341 |
# File 'app/models/georeference/geo_locate.rb', line 338 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.
335 336 337 |
# File 'app/models/georeference/geo_locate.rb', line 335 def result @result end |
Instance Method Details
#call_api(host, request) ⇒ HTTP object (protected)
365 366 367 |
# File 'app/models/georeference/geo_locate.rb', line 365 def call_api(host, request) Net::HTTP.get(host, request.request_string) end |
#coordinates ⇒ String
Returns coordinates from the response set.
344 345 346 |
# File 'app/models/georeference/geo_locate.rb', line 344 def coordinates @result['resultSet']['features'][0]['geometry']['coordinates'] end |
#uncertainty_polygon ⇒ String
Returns uncertainty_polygon from the response set.
355 356 357 358 |
# File 'app/models/georeference/geo_locate.rb', line 355 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.
349 350 351 352 |
# File 'app/models/georeference/geo_locate.rb', line 349 def uncertainty_radius retval = @result['resultSet']['features'][0]['properties']['uncertaintyRadiusMeters'] (retval == 'Unavailable') ? 3 : retval end |