Reads the geographic bus locations (longitude and latitude coordinates in degrees) from a CSV file and adds them to the NDD. Returns the resulting NDD, in which each bus has a "bus_lat" and "bus_lon" entry. The columns containg the longitude and latitude coordinates in the CSV file should be called "SubLongitude" and "SubLatitude", respectively.
=#
function addlocs!(
network_data::Dict{String,<:Any},
csvfile::String
)
pos=Dict{String,Any}(
"baseMVA"=>100.0,
"bus"=>Dict{String,Any}(),
"per_unit"=>true
)
BusData::DataFrame=CSV.File(csvfile)|>DataFrame!
N=size(BusData,1)# number of buses
sizehint!(pos["bus"],N)
forbusineachrow(BusData)
pos["bus"][string(bus[:Number])]=Dict(
"bus_lon"=>bus[:SubLongitude],
"bus_lat"=>bus[:SubLatitude]
)
end
update_data!(network_data,pos)# add positions to network_data
returnnetwork_data
end
#=
Returns a dictionary containing geographic bus locations that are included in the NDD. The dicitonary structure is bus-index => (lon, lat). If getlims=true, the minmimum and maximum longitude and latitude coordinates are returned as well. Can be useful for plotting the grid.
=#
function getlocs(network_data::Dict{String,<:Any};getlims=false)
pos=Dict(
parse(Int64,i)=>(b["bus_lon"],b["bus_lat"])
for(i,b)innetwork_data["bus"]
)
### Check whether to return lon- and lat-limits or not