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



262
263
264
265
# File 'app/models/georeference/geo_locate.rb', line 262

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



260
261
262
# File 'app/models/georeference/geo_locate.rb', line 260

def result
  @result
end

Instance Method Details

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

Parameters:

  • host (String, String)

    domain name, request string.



287
288
289
# File 'app/models/georeference/geo_locate.rb', line 287

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.



268
269
270
# File 'app/models/georeference/geo_locate.rb', line 268

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.



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

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.



273
274
275
276
# File 'app/models/georeference/geo_locate.rb', line 273

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