Skip to content

Commit 24b6a72

Browse files
authored
Merge pull request #85 from GenericMappingTools/fix-veggy-indices-regression
Fix regression in code dealing with vegetation indices calculations.
2 parents 4912e3e + bcf5d15 commit 24b6a72

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
version:
2727
- '1' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
2828
#- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
29-
#- 'nightly'
29+
- '~1.10.0-0'
30+
- 'nightly'
3031
os:
3132
- ubuntu-latest
3233
#- ubuntu-20.04
@@ -53,15 +54,15 @@ jobs:
5354
access_token: ${{ github.token }}
5455

5556
- name: Checkout
56-
uses: actions/checkout@v2
57+
uses: actions/checkout@v4
5758
if: matrix.run_in_pr == true || github.event_name != 'pull_request'
5859

59-
- uses: actions/checkout@v2
60-
- uses: julia-actions/setup-julia@v1
60+
- uses: actions/checkout@v4
61+
- uses: julia-actions/setup-julia@v2
6162
with:
6263
version: ${{ matrix.version }}
6364
arch: ${{ matrix.arch }}
64-
- uses: actions/cache@v1
65+
- uses: actions/cache@v4
6566
env:
6667
cache-name: cache-artifacts
6768
with:
@@ -74,7 +75,7 @@ jobs:
7475
- uses: julia-actions/julia-buildpkg@v1
7576
- uses: julia-actions/julia-runtest@v1
7677
- uses: julia-actions/julia-processcoverage@v1
77-
- uses: codecov/codecov-action@v1
78+
- uses: codecov/codecov-action@v5
7879
with:
7980
file: lcov.info
8081

@@ -83,8 +84,8 @@ jobs:
8384
runs-on: ubuntu-latest
8485
#runs-on: ubuntu-18.04
8586
steps:
86-
- uses: actions/checkout@v2
87-
- uses: julia-actions/setup-julia@v1
87+
- uses: actions/checkout@v4
88+
- uses: julia-actions/setup-julia@v2
8889
with:
8990
version: '1'
9091
- run: |

src/spectral_indices.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,10 +535,15 @@ function sp_indices(cube::Union{GMT.GMTimage{UInt16, 3}, AbstractArray{<:Abstrac
535535
o = sp_indices(@view(cube[:,:,bands[1]]), @view(cube[:,:,bands[2]]), @view(cube[:,:,bands[3]]); index=index, kw...)
536536
end
537537
if (mask || classes !== nothing)
538-
O = mat2img(o, cube)
539-
O.layout, O.range[5], O.range[6] = "BRPa", 0, (mask) ? 255 : length(classes)
538+
if (isa(o, Matrix{<:Integer}))
539+
# Don't know if this case still happens. It was for old code. Now, for masks, 'o' is already a GMTimage
540+
O = mat2img(o, cube)
541+
O.layout, O.range[5], O.range[6] = "BRPa", 0, (mask) ? 255 : length(classes)
542+
else
543+
O = o
544+
end
540545
else
541-
O = mat2grid(o, cube)
546+
O = isa(o, GMT.GMTgrid) ? o : mat2grid(o, cube)
542547
end
543548
O.names = [index * " index"]
544549
(save_name != "") && gmtwrite(save_name, O)
@@ -781,13 +786,14 @@ function sp_indices(bnd1, bnd2, bnd3=nothing; index::String="", kwargs...)
781786
end
782787
end
783788

784-
if (isa(bnd1, GMT.GMTimage) || isa(bnd1, GMT.GMTgrid))
789+
if (isa(bnd1, GMT.GMTimage) || isa(bnd1, GMT.GMTgrid) || isa(parent(bnd1), GMTimage)) # Last one is when slice is a SubArray{...
785790
if (ismask || classes !== nothing)
786-
I = mat2img(mask, proj4=bnd1.proj4, wkt=bnd1.wkt, x=bnd1.x, y=bnd1.y, epsg=bnd1.epsg, layout="BRPa")
791+
I = mat2img(mask, isa(bnd1, GMT.GMTimage) ? bnd1 : parent(bnd1))
792+
I.layout="BRPa"
787793
I.range[5], I.range[6] = 0, (ismask) ? 255 : length(classes)
788794
return I
789795
else
790-
return mat2grid(img, bnd1)
796+
return mat2grid(img, isa(bnd1, GMT.GItype) ? bnd1 : parent(bnd1))
791797
end
792798
else
793799
return img

0 commit comments

Comments
 (0)