Skip to content

Commit a3fa921

Browse files
authored
Unified checking whether two s are geographically equal. (evetion#30)
* Unified checking whether two s are geographically equal. * Fixed GeoStats to specific version. * Changed from GeoStats to KrigingEstimators (same GeoStats ecosystem though). * Also commit test that actually uses KrigingEstimators.
1 parent b586ec9 commit a3fa921

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

Project.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GeoArrays"
22
uuid = "2fb1d81b-e6a0-5fc5-82e6-8e06903437ab"
33
authors = ["Maarten Pronk <git@evetion.nl>"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
@@ -14,13 +14,15 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1414
ArchGDAL = "^0.3.0"
1515
CoordinateTransformations = "0.5"
1616
GeoStatsBase = "0.5, 0.6, 0.7"
17+
KrigingEstimators = "=0.3.3"
1718
RecipesBase = "0.7, 0.8"
1819
StaticArrays = "0.12"
1920
julia = "1"
2021

2122
[extras]
2223
GeoStats = "dcc97b0b-8ce5-5539-9008-bb190f959ef6"
24+
KrigingEstimators = "d293930c-a38c-56c5-8ebb-12008647b47a"
2325
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2426

2527
[targets]
26-
test = ["Test", "GeoStats"]
28+
test = ["Test", "KrigingEstimators"]

src/operations.jl

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1+
"""Check whether two `GeoArrays`s `a` and `b` are
2+
geographically equal, although not necessarily in content."""
3+
function equals(a::GeoArray, b::GeoArray)
4+
size(a) == size(b) && a.f == b.f && a.crs == b.crs
5+
end
6+
17
function Base.:-(a::GeoArray, b::GeoArray)
2-
size(a) == size(b) || throw(DimensionMismatch("The sizes of a and b do not match."))
3-
a.f == b.f || error("The affine information does not match")
4-
a.crs == b.crs || error("The crs information does not match")
8+
equals(a, b) || throw(DimensionMismatch("Can't operate on non-geographic-equal `GeoArray`s"))
59
GeoArray(a.A .- b.A, a.f, a.crs)
610
end
711

812
function Base.:+(a::GeoArray, b::GeoArray)
9-
size(a) == size(b) || throw(DimensionMismatch("The sizes of a and b do not match."))
10-
a.f == b.f || error("The affine information does not match")
11-
a.crs == b.crs || error("The crs information does not match")
13+
equals(a, b) || throw(DimensionMismatch("Can't operate on non-geographic-equal `GeoArray`s"))
1214
GeoArray(a.A .+ b.A, a.f, a.crs)
1315
end
1416

1517
function Base.:*(a::GeoArray, b::GeoArray)
16-
size(a) == size(b) || throw(DimensionMismatch("The sizes of a and b do not match."))
17-
a.f == b.f || error("The affine information does not match")
18-
a.crs == b.crs || error("The crs information does not match")
18+
equals(a, b) || throw(DimensionMismatch("Can't operate on non-geographic-equal `GeoArray`s"))
1919
GeoArray(a.A .* b.A, a.f, a.crs)
2020
end
2121

2222
function Base.:/(a::GeoArray, b::GeoArray)
23-
size(a) == size(b) || throw(DimensionMismatch("The sizes of a and b do not match."))
24-
a.f == b.f || error("The affine information does not match")
25-
a.crs == b.crs || error("The crs information does not match")
23+
equals(a, b) || throw(DimensionMismatch("Can't operate on non-geographic-equal `GeoArray`s"))
2624
GeoArray(a.A ./ b.A, a.f, a.crs)
2725
end

test/test_interpolate.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using GeoStats
1+
using KrigingEstimators
22
using StaticArrays
33

44
@testset "Interpolating rasters" begin

test/test_operations.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ using CoordinateTransformations
1313
@testset "affine error tests" begin
1414
c = GeoArray(rand(5, 5, 1), AffineMap([1.0 0.0; 0.0 -1.0], [375000.03, 380000.03]),"")
1515
d = GeoArray(rand(5, 5, 1), AffineMap([1.0 0.0; 0.0 1.0], [0.0, 0.0]),"")
16-
@test_throws ErrorException c - d
17-
@test_throws ErrorException c + d
18-
@test_throws ErrorException c * d
19-
@test_throws ErrorException c / d
16+
@test_throws DimensionMismatch c - d
17+
@test_throws DimensionMismatch c + d
18+
@test_throws DimensionMismatch c * d
19+
@test_throws DimensionMismatch c / d
2020
end
2121

2222
@testset "crs error test" begin
2323
e = GeoArray(rand(5, 5, 1), AffineMap([1.0 0.0; 0.0 -1.0], [375000.03, 380000.03]),"")
2424
f = GeoArray(rand(5, 5, 1), AffineMap([1.0 0.0; 0.0 -1.0], [375000.03, 380000.03]),"PROJCS[\"NAD27 / UTM zone 11N\",GEOGCS[\"NAD27\",DATUM[\"North_American_Datum_1927\",SPHEROID[\"Clarke 1866\",6378206.4,294.9786982138982,AUTHORITY[\"EPSG\",\"7008\"]],AUTHORITY[\"EPSG\",\"6267\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4267\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-117],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"26711\"]]")
25-
@test_throws ErrorException e - f
26-
@test_throws ErrorException e + f
27-
@test_throws ErrorException e * f
28-
@test_throws ErrorException e / f
25+
@test_throws DimensionMismatch e - f
26+
@test_throws DimensionMismatch e + f
27+
@test_throws DimensionMismatch e * f
28+
@test_throws DimensionMismatch e / f
2929
end
3030

3131
@testset "operations" begin

0 commit comments

Comments
 (0)