Ruby Geocoder and/or OpenStreetMap 存在很大的错误

Large inaccuracies with Ruby Geocoder and/or OpenStreetMap

我在 rails 中使用地理编码器 gem 获取地址的纬度和经度,然后在 OpenStreetMap 中显示它们。

当我搜索我的旧地址时:

>> results = Geocoder.search("1000 Mount Curve Ave E, Altadena, CA 91001")

我得到:

>> results.first.coordinates
=> [34.1976645, -118.1278219]

Mount Curve Address Discrepancy

那些坐标可能相差一千英尺。 (见图片。)从 Google 地图得到的准确坐标是 [34.200503,-118.1310407].

我试过另一个地址,但距离更远,也许一英里。 (1346 E Woodbury Rd,帕萨迪纳,CA 91104)

我已经尝试了另一个地址,它非常准确。 (922 E Brockton Ave, Redlands, CA 92374)

有谁知道可能导致这些不准确的原因以及如何始终如一地获得准确的结果?

由于 OSM/Nominatim 的不准确 and/or 限制,我切换到 Google 地图服务。在我的控制器顶部,我添加了:

require 'google_maps_service'

在我的控制器的显示例程中,我最终得到了这个,它产生了准确的结果:

source = Property.find(params[:id])
@property = PropertyDecorator.new(source)
gmaps = GoogleMapsService::Client.new(key: '[removed, put in your own key here]')
results = gmaps.geocode("#{@property.address1} #{@property.address2}")
if results[0] == nil
  @lat = 0 
  @lng = 0 
else
  @lat = results[0][:geometry][:location][:lat]
  @lng = results[0][:geometry][:location][:lng]
end