如何覆盖地理编码器罗盘点?

How to override geocoders compass points?

我正在使用 rails 地理编码器 gem。我想覆盖

COMPASS_POINTS = %w[N NE E SE S SW W NW]

使用德国罗盘点:

COMPASS_POINTS = %w[N NO O SO S SW W NW]

但我不知道如何以及在哪里 (config/gecoder.rb?) 做到这一点?

如有任何帮助,我们将不胜感激!

根据documentation

 ##
    # Compass point names, listed clockwise starting at North.
    #
    # If you want bearings named using more, fewer, or different points
    # override Geocoder::Calculations.COMPASS_POINTS with your own array.
    #
    COMPASS_POINTS = %w[N NE E SE S SW W NW]

因此,创建一个初始化程序 config/initializers/geocoder_override.rb 并添加以下行:

Geocoder::Calculations::COMPASS_POINTS = %w[N NO O SO S SW W NW]