Fix handling and output of points of interest
parent
b05b9dbd0b
commit
10e877e9ec
|
@ -56,7 +56,7 @@ function trainrun(train::Train, path::Path, settings=Settings()::Settings)
|
||||||
# settings.outputDetail == :verbose && println("The driving course for the shortest running time has been calculated.")
|
# settings.outputDetail == :verbose && println("The driving course for the shortest running time has been calculated.")
|
||||||
|
|
||||||
# accumulate data and create an output dictionary
|
# accumulate data and create an output dictionary
|
||||||
output = createOutput(settings, path, drivingCourse)
|
output = createOutput(settings, drivingCourse, movingSection[:pointsOfInterest])
|
||||||
|
|
||||||
return output
|
return output
|
||||||
end # function trainrun
|
end # function trainrun
|
||||||
|
|
|
@ -622,6 +622,19 @@ function createMovingSection(path::Path, v_trainLimit::Real, s_trainLength::Real
|
||||||
s_exit = path.sections[end][:s_end] # last position (in m)
|
s_exit = path.sections[end][:s_end] # last position (in m)
|
||||||
pathLength = s_exit - s_entry # total length (in m)
|
pathLength = s_exit - s_entry # total length (in m)
|
||||||
|
|
||||||
|
##TODO: use a tuple with naming
|
||||||
|
pointsOfInterest = Tuple[]
|
||||||
|
if !isempty(path.poi)
|
||||||
|
for POI in path.poi
|
||||||
|
s_poi = POI[:station]
|
||||||
|
if POI[:measure] == "rear"
|
||||||
|
s_poi += s_trainLength
|
||||||
|
end
|
||||||
|
push!(pointsOfInterest, (s_poi, POI[:label]) )
|
||||||
|
end
|
||||||
|
sort!(pointsOfInterest, by = x -> x[1])
|
||||||
|
end
|
||||||
|
|
||||||
CSs=Vector{Dict}()
|
CSs=Vector{Dict}()
|
||||||
s_csStart=s_entry
|
s_csStart=s_entry
|
||||||
csId=1
|
csId=1
|
||||||
|
@ -631,26 +644,26 @@ function createMovingSection(path::Path, v_trainLimit::Real, s_trainLength::Real
|
||||||
speedLimitIsDifferent = min(previousSection[:v_limit], v_trainLimit) != min(currentSection[:v_limit], v_trainLimit)
|
speedLimitIsDifferent = min(previousSection[:v_limit], v_trainLimit) != min(currentSection[:v_limit], v_trainLimit)
|
||||||
pathResistanceIsDifferent = previousSection[:f_Rp] != currentSection[:f_Rp]
|
pathResistanceIsDifferent = previousSection[:f_Rp] != currentSection[:f_Rp]
|
||||||
if speedLimitIsDifferent || pathResistanceIsDifferent
|
if speedLimitIsDifferent || pathResistanceIsDifferent
|
||||||
# 03/09 old: if min(previousSection[:v_limit], v_trainLimit) != min(currentSection[:v_limit], v_trainLimit) || previousSection[:f_Rp] != currentSection[:f_Rp]
|
push!(CSs, createCharacteristicSection(csId, s_csStart, previousSection, min(previousSection[:v_limit], v_trainLimit), s_trainLength, pointsOfInterest))
|
||||||
push!(CSs, createCharacteristicSection(csId, s_csStart, previousSection, min(previousSection[:v_limit], v_trainLimit), s_trainLength, path))
|
|
||||||
s_csStart = currentSection[:s_start]
|
s_csStart = currentSection[:s_start]
|
||||||
csId = csId+1
|
csId = csId+1
|
||||||
end #if
|
end #if
|
||||||
end #for
|
end #for
|
||||||
push!(CSs, createCharacteristicSection(csId, s_csStart, path.sections[end], min(path.sections[end][:v_limit], v_trainLimit), s_trainLength, path))
|
push!(CSs, createCharacteristicSection(csId, s_csStart, path.sections[end], min(path.sections[end][:v_limit], v_trainLimit), s_trainLength, pointsOfInterest))
|
||||||
|
|
||||||
movingSection= Dict(:id => 1, # identifier # if there is more than one moving section in a later version of this tool the id should not be constant anymore
|
movingSection= Dict(:id => 1, # identifier # if there is more than one moving section in a later version of this tool the id should not be constant anymore
|
||||||
:length => pathLength, # total length (in m)
|
:length => pathLength, # total length (in m)
|
||||||
:s_entry => s_entry, # first position (in m)
|
:s_entry => s_entry, # first position (in m)
|
||||||
:s_exit => s_exit, # last position (in m)
|
:s_exit => s_exit, # last position (in m)
|
||||||
:t => 0.0, # total running time (in s)
|
:t => 0.0, # total running time (in s)
|
||||||
:characteristicSections => CSs) # list of containing characteristic sections
|
:characteristicSections => CSs, # list of containing characteristic sections
|
||||||
|
:pointsOfInterest => pointsOfInterest) # list of containing points of interest
|
||||||
|
|
||||||
return movingSection
|
return movingSection
|
||||||
end #function createMovingSection
|
end #function createMovingSection
|
||||||
|
|
||||||
## create a characteristic section for a path section. A characteristic section is a part of the moving section. It contains behavior sections.
|
## create a characteristic section for a path section. A characteristic section is a part of the moving section. It contains behavior sections.
|
||||||
function createCharacteristicSection(id::Integer, s_entry::Real, section::Dict, v_limit::Real, s_trainLength::Real, path::Path)
|
function createCharacteristicSection(id::Integer, s_entry::Real, section::Dict, v_limit::Real, s_trainLength::Real, MS_poi::Vector{Tuple})
|
||||||
# Create and return a characteristic section dependent on the paths attributes
|
# Create and return a characteristic section dependent on the paths attributes
|
||||||
characteristicSection= Dict(:id => id, # identifier
|
characteristicSection= Dict(:id => id, # identifier
|
||||||
:s_entry => s_entry, # first position (in m)
|
:s_entry => s_entry, # first position (in m)
|
||||||
|
@ -670,22 +683,17 @@ function createCharacteristicSection(id::Integer, s_entry::Real, section::Dict,
|
||||||
|
|
||||||
##TODO: use a tuple with naming
|
##TODO: use a tuple with naming
|
||||||
pointsOfInterest = Tuple[]
|
pointsOfInterest = Tuple[]
|
||||||
# pointsOfInterest = Real[]
|
if !isempty(MS_poi)
|
||||||
if !isempty(path.poi)
|
for POI in MS_poi
|
||||||
for POI in path.poi
|
s_poi = POI[1]
|
||||||
s_poi = POI[:station]
|
if s_entry < s_poi && s_poi <= s_exit
|
||||||
if POI[:measure] == "rear"
|
push!(pointsOfInterest, (POI))
|
||||||
s_poi += s_trainLength
|
|
||||||
end
|
|
||||||
if s_entry < s_poi && s_poi < s_exit
|
|
||||||
push!(pointsOfInterest, (s_poi, POI[:label]) )
|
|
||||||
# push!(pointsOfInterest, s_poi )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
push!(pointsOfInterest, (s_exit,"")) # s_exit has to be the last POI so that there will always be a POI to campare the current position with
|
if isempty(pointsOfInterest) || pointsOfInterest[end][1] < s_exit
|
||||||
# push!(pointsOfInterest, s_exit) # s_exit has to be the last POI so that there will always be a POI to campare the current position with
|
push!(pointsOfInterest, (s_exit,"")) # s_exit has to be the last POI so that there will always be a POI to campare the current position with
|
||||||
|
end
|
||||||
merge!(characteristicSection, Dict(:pointsOfInterest => pointsOfInterest))
|
merge!(characteristicSection, Dict(:pointsOfInterest => pointsOfInterest))
|
||||||
|
|
||||||
return characteristicSection
|
return characteristicSection
|
||||||
|
|
|
@ -5,34 +5,26 @@
|
||||||
# __copyright__ = "2020-2022"
|
# __copyright__ = "2020-2022"
|
||||||
# __license__ = "ISC"
|
# __license__ = "ISC"
|
||||||
|
|
||||||
function createOutput(settings::Settings, path::Path, drivingCourse::Vector{Dict})
|
function createOutput(settings::Settings, drivingCourse::Vector{Dict}, pointsOfInterest::Vector{Tuple})
|
||||||
if settings.outputDetail == :running_time
|
if settings.outputDetail == :running_time
|
||||||
output::Vector{Dict} = [Dict(:t => drivingCourse[end][:t])]
|
output::Vector{Dict} = [Dict(:t => drivingCourse[end][:t])]
|
||||||
|
|
||||||
elseif settings.outputDetail == :points_of_interest && !isempty(path.poi)
|
elseif settings.outputDetail == :points_of_interest && !isempty(pointsOfInterest)
|
||||||
# add points of interest
|
|
||||||
|
|
||||||
# output = Dict[]
|
|
||||||
# POI = 1
|
|
||||||
# i = 1
|
|
||||||
# while POI <= length(path.poi) && i <= drivingCourse[end][:i]
|
|
||||||
# if path.poi[POI][:station] == drivingCourse[i][:s]
|
|
||||||
# push!(output, drivingCourse[i])
|
|
||||||
# POI = POI+1
|
|
||||||
# end
|
|
||||||
# i = i+1
|
|
||||||
# end
|
|
||||||
|
|
||||||
# get only the driving course's data points with POI labels
|
# get only the driving course's data points with POI labels
|
||||||
output = Dict[]
|
output = Dict[]
|
||||||
for point in drivingCourse
|
dataPoint = 1
|
||||||
if point[:label] != ""
|
for POI in 1:length(pointsOfInterest)
|
||||||
push!(output, point)
|
while dataPoint <= length(drivingCourse)
|
||||||
|
if pointsOfInterest[POI][1] == drivingCourse[dataPoint][:s]
|
||||||
|
push!(output, drivingCourse[dataPoint])
|
||||||
|
break
|
||||||
|
end
|
||||||
|
dataPoint += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else #if settings.outputDetail == :driving_course || (settings.outputDetail == :points_of_interest && !isempty(path.poi))
|
else #if settings.outputDetail == :driving_course || (settings.outputDetail == :points_of_interest && !isempty(path.poi))
|
||||||
output = drivingCourse
|
output = drivingCourse
|
||||||
end
|
end
|
||||||
|
|
||||||
if settings.outputFormat == :dataframe
|
if settings.outputFormat == :dataframe
|
||||||
|
|
Loading…
Reference in New Issue