Class: Georeference::GeoLocate::Response

Inherits:
Object
  • Object
show all
Defined in:
app/models/georeference/geo_locate.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Response) initialize(request)

Returns a new instance of Response



240
241
242
243
# File 'app/models/georeference/geo_locate.rb', line 240

def initialize(request)
  @result           = JSON.parse(call_api(Georeference::GeoLocate::URI_HOST, request))
  request.succeeded = true if @result['numResults'].to_i == 1
end

Instance Attribute Details

- (Object) result

Returns the value of attribute result



238
239
240
# File 'app/models/georeference/geo_locate.rb', line 238

def result
  @result
end

Instance Method Details

- (Object) call_api(host, request) (protected)

Parameters:

  • host (String, String)

    domain name, request string.



265
266
267
# File 'app/models/georeference/geo_locate.rb', line 265

def call_api(host, request)
  Net::HTTP.get(host, request.request_string)
end

- (String) coordinates

Returns coordinates from the response set.

Returns:

  • (String)

    coordinates from the response set.



246
247
248
# File 'app/models/georeference/geo_locate.rb', line 246

def coordinates
  @result['resultSet']['features'][0]['geometry']['coordinates']
end

- (String) uncertainty_polygon

Returns uncertainty_polygon from the response set.

Returns:

  • (String)

    uncertainty_polygon from the response set.



257
258
259
260
# File 'app/models/georeference/geo_locate.rb', line 257

def uncertainty_polygon
  retval = @result['resultSet']['features'][0]['properties']['uncertaintyPolygon']
  (retval == 'Unavailable') ? nil : retval['coordinates'][0]
end

- (String) uncertainty_radius

Returns uncertainty_radius from the response set.

Returns:

  • (String)

    uncertainty_radius from the response set.



251
252
253
254
# File 'app/models/georeference/geo_locate.rb', line 251

def uncertainty_radius
  retval = @result['resultSet']['features'][0]['properties']['uncertaintyRadiusMeters']
  (retval == 'Unavailable') ? 3 : retval
end