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

Parameters:

  • request (JSON object)


284
285
286
287
# File 'app/models/georeference/geo_locate.rb', line 284

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



281
282
283
# File 'app/models/georeference/geo_locate.rb', line 281

def result
  @result
end

Instance Method Details

- (HTTP object) call_api(host, request) (protected)

Parameters:

  • host (String, String)

    domain name, request string.

Returns:

  • (HTTP object)


310
311
312
# File 'app/models/georeference/geo_locate.rb', line 310

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.



290
291
292
# File 'app/models/georeference/geo_locate.rb', line 290

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.



301
302
303
304
# File 'app/models/georeference/geo_locate.rb', line 301

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.



295
296
297
298
# File 'app/models/georeference/geo_locate.rb', line 295

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