From 79e3fa0e5e9e18e5d57c6b5c1901b90c0de68a24 Mon Sep 17 00:00:00 2001 From: ranjanan Date: Thu, 29 Dec 2022 01:12:41 -0500 Subject: [PATCH 1/2] add include pairs logic when polygons in point files --- src/raster/pairwise.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/raster/pairwise.jl b/src/raster/pairwise.jl index bfa22d04..a78b9c86 100644 --- a/src/raster/pairwise.jl +++ b/src/raster/pairwise.jl @@ -81,6 +81,7 @@ function _pt_file_polygons_path(rasterdata::RasterData{T,V}, # construct new graph # solve for two points # end + # Data gmap = rasterdata.cellmap @@ -88,6 +89,8 @@ function _pt_file_polygons_path(rasterdata::RasterData{T,V}, points_rc = rasterdata.points_rc avg_res = flags.avg_res four_neighbors = flags.four_neighbors + included_pairs = rasterdata.included_pairs + exclude_pairs = generate_exclude_pairs(points_rc, included_pairs) # Cumulative maps cum = initialize_cum_maps(gmap, flags.outputflags.write_max_cur_maps) @@ -105,6 +108,9 @@ function _pt_file_polygons_path(rasterdata::RasterData{T,V}, pt2 = pts[j] csinfo("Solving pair $k of $n", cfg["suppress_messages"] in TRUELIST) k += 1 + if (pt1,pt2) in exclude_pairs || (pt2, pt1) in exclude_pairs + continue + end graphdata = compute_graph_data_polygons(rasterdata, flags, pt1, pt2, cum, cfg) pairwise_resistance = single_ground_all_pairs(graphdata, flags, cfg, false) resistances[i,j] = resistances[j,i] = pairwise_resistance[2,3] From 45f842aa207ecd93e2f5a054d18b17fa9f8c843d Mon Sep 17 00:00:00 2001 From: ranjanan Date: Thu, 29 Dec 2022 12:37:50 -0500 Subject: [PATCH 2/2] Generate this with a check --- src/io.jl | 1 + src/raster/pairwise.jl | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/io.jl b/src/io.jl index 8e334607..c5bf4c2f 100644 --- a/src/io.jl +++ b/src/io.jl @@ -8,6 +8,7 @@ end function IncludeExcludePairs(V) IncludeExcludePairs(:undef, V[], Matrix{V}(undef,0,0)) end +Base.isempty(x::IncludeExcludePairs) = isempty(x.include_pairs) struct NetworkData{T,V} <: Data coords::Tuple{Vector{V},Vector{V},Vector{T}} diff --git a/src/raster/pairwise.jl b/src/raster/pairwise.jl index a78b9c86..f5dcdfff 100644 --- a/src/raster/pairwise.jl +++ b/src/raster/pairwise.jl @@ -90,7 +90,8 @@ function _pt_file_polygons_path(rasterdata::RasterData{T,V}, avg_res = flags.avg_res four_neighbors = flags.four_neighbors included_pairs = rasterdata.included_pairs - exclude_pairs = generate_exclude_pairs(points_rc, included_pairs) + exclude_pairs = isempty(included_pairs) ? Vector{Tuple{V,V}}() : + generate_exclude_pairs(points_rc, included_pairs) # Cumulative maps cum = initialize_cum_maps(gmap, flags.outputflags.write_max_cur_maps)