modularize: edit (split, assign_note)
This commit is contained in:
parent
881d542a30
commit
29b78dd27b
3 changed files with 37 additions and 2 deletions
|
@ -4,5 +4,6 @@ using Dates
|
||||||
|
|
||||||
include("typedef.jl")
|
include("typedef.jl")
|
||||||
include("parser.jl")
|
include("parser.jl")
|
||||||
|
include("edit.jl")
|
||||||
|
|
||||||
end # end module CoordVisualize
|
end # module CoordVisualize
|
||||||
|
|
26
src/edit.jl
Normal file
26
src/edit.jl
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
"""
|
||||||
|
split_log(log::CoordLog, at::Unsigned, notes_1::AbstractString, notes_2::AbstractString)::Vector{CoordLog}
|
||||||
|
|
||||||
|
Split `log` at `at`, i.e. to `1:at` and `at:end` then assign `notes_1` and `notes_2` to notes for each other.
|
||||||
|
"""
|
||||||
|
function split_log(log::CoordLog, at::Unsigned, notes_1::AbstractString, notes_2::AbstractString)::Vector{CoordLog}
|
||||||
|
@assert at < size(log.coords)[1] "Split index must be less than original log length($(size(log.coords)[1]))"
|
||||||
|
[
|
||||||
|
CoordLog(log.coords[1:at, :], log.logdate, notes_1),
|
||||||
|
CoordLog(log.coords[at:end, :], log.logdate, notes_2),
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
function split_log(log::CoordLog, at::Integer, notes_1::AbstractString, notes_2::AbstractString)::Vector{CoordLog}
|
||||||
|
split_log(log, UInt(at), notes_1, notes_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
assign_note!(log::CoordLog, new_note::AbstractString)
|
||||||
|
|
||||||
|
Replace `note` in `log` with `new_note`.
|
||||||
|
"""
|
||||||
|
function assign_note!(log::CoordLog, new_note::AbstractString)
|
||||||
|
log.note = new_note
|
||||||
|
end
|
|
@ -1,7 +1,15 @@
|
||||||
using Dates
|
using Dates
|
||||||
struct CoordLog{T <: AbstractFloat}
|
mutable struct CoordLog{T <: AbstractFloat}
|
||||||
coords::Matrix{T}
|
coords::Matrix{T}
|
||||||
logdate::DateTime
|
logdate::DateTime
|
||||||
note::String
|
note::String
|
||||||
end
|
end
|
||||||
|
|
||||||
|
"""
|
||||||
|
n_coords(log::CoordLog)::Integer
|
||||||
|
|
||||||
|
Get number of coordinates in `log`.
|
||||||
|
"""
|
||||||
|
function n_coords(log::CoordLog)::Integer
|
||||||
|
size(log.coords)[1]
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue