108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/panomosity/runner.rb', line 108
def check_position_changes
logger.info 'checking position changes'
original_images = Image.parse(@input_file)
changed_images = Image.parse(@compare_file)
threshold = 0.10
images = original_images.zip(changed_images)
changes_x = images.select do |original, changed|
ratio_x = original.d / changed.d
changed_x = (1 - ratio_x.abs).abs
changed_x > threshold
end
changes_y = images.select do |original, changed|
ratio_y = original.e / changed.e
changed_y = (1 - ratio_y.abs).abs
changed_y > threshold
end
@lines = @input_file.each_line.map do |line|
variable = OptimisationVariable.parse_line(line)
next line unless variable
if variable.d && changes_x.find { |original, _| original.id.to_s == variable.d }
logger.debug "Removing #{variable.to_s}"
elsif variable.e && changes_y.find { |original, _| original.id.to_s == variable.e }
logger.debug "Removing #{variable.to_s}"
else
next line
end
end
save_file
end
|