Skip to content

Commit

Permalink
add super basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Jan 10, 2025
1 parent 8d6f670 commit b614376
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/geometry_lookup.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NaturalEarth
using Test

using Rasters, DimensionalData
import Proj

@testset "construction" begin
# fetch land polygons from Natural Earth
land_polygons = NaturalEarth.naturalearth("admin_0_countries", 110).geometry
# create a DimVector from the land polygons
gl = GeometryLookup(land_polygons)
@test crs(gl) == EPSG(4326)
@test all(GO.equals, zip(val(gl), land_polygons))
end

@testset "reprojecting a GeometryLookup" begin
# fetch land polygons from Natural Earth
land_polygons = NaturalEarth.naturalearth("admin_0_countries", 110).geometry
# create a DimVector from the land polygons
dv = Raster(rand(Dim{:Geometry}(GeometryLookup(land_polygons))))
# reproject the full vector data cube (vector data vector, in this case :D)
target_crs = ProjString("+proj=wintri +type=crs")
reprojected_via_rasters = val(dims(reproject(target_crs, dv), Dim{:Geometry}))
reprojected_via_geometryops = GO.reproject(land_polygons; source_crs = EPSG(4326), target_crs = target_crs)
# test that the reprojected geometries are the same
@test all(splat(GO.equals), zip(
reprojected_via_rasters, # reproject the vdc, get the geometries from it
reprojected_via_geometryops # reproject the geometries directly
)
)
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ end
@time @safetestset "reproject" begin include("reproject.jl") end
@time @safetestset "warp" begin include("warp.jl") end
@time @safetestset "cellarea" begin include("cellarea.jl") end
@time @safetestset "geometrylookups" begin include("geometry_lookups.jl") end

# CommondataModel sources
@time @safetestset "commondatamodel" begin include("sources/commondatamodel.jl") end
Expand Down

0 comments on commit b614376

Please sign in to comment.