geotoad icon indicating copy to clipboard operation
geotoad copied to clipboard

Workaround for distance option issue starting from TUI

Open rona1707 opened this issue 4 months ago • 7 comments

Hello,

I got the following error by starting from TUI.

geotoad.rb:186:in 'GeoToad#getoptions': undefined method '=~' for an instance of Integer (NoMethodError)

So I'm not so familiar wih ruby, but at least I'm into software development. So I asked the AI:

This means Ruby is trying to use the =~ operator (used for regex matching) on an integer, but =~ only works on strings.

``

# distanceMax from command line can contain the unit
@distanceMax       = @option['distanceMax'].to_f
if @distanceMax == 0.0
  @distanceMax = 10
end
if @option['distanceMax'] =~ /(mi|km)/
  @useMetric     = ($1 == "km" || nil)
  # else leave usemetric unchanged
end

I'm not familiar with the type of distanceMax in the @options but it seems like some type error. The recommended solution was to convert the @option['distanceMax'] to a string, which worked for me.

# distanceMax from command line can contain the unit
@distanceMax       = @option['distanceMax'].to_f
if @distanceMax == 0.0
  @distanceMax = 10
end
if @option['distanceMax'].to_s =~ /(mi|km)/
  @useMetric     = ($1 == "km" || nil)
  # else leave usemetric unchanged
end

rona1707 avatar Aug 23 '25 09:08 rona1707