Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GeoPackage tests #117

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions test/gis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,31 @@
@test gtb.string == gtpoly.string

# GeoPackage
# note 1: GeoPackage does not preserve column order
# note 2: currently GeoIO does not save the CRS
# and the default CRS used by GDAL is not valid
# note: GeoPackage does not preserve column order
file = joinpath(savedir, "gis-points.gpkg")
GeoIO.save(file, gtpoint)
@test_throws ArgumentError GeoIO.load(file)
gtb = GeoIO.load(file)
@test Set(names(gtb)) == Set(names(gtpoly))
@test_broken gtb.geometry == gtpoly.geometry
@test gtb.float == gtpoly.float
@test gtb.int == gtpoly.int
@test gtb.string == gtpoly.string

file = joinpath(savedir, "gis-rings.gpkg")
GeoIO.save(file, gtring)
@test_throws ArgumentError GeoIO.load(file)
gtb = GeoIO.load(file)
@test Set(names(gtb)) == Set(names(gtpoly))
@test_broken gtb.geometry == gtpoly.geometry
@test gtb.float == gtpoly.float
@test gtb.int == gtpoly.int
@test gtb.string == gtpoly.string

file = joinpath(savedir, "gis-polys.gpkg")
GeoIO.save(file, gtpoly)
@test_throws ArgumentError GeoIO.load(file)
gtb = GeoIO.load(file)
@test Set(names(gtb)) == Set(names(gtpoly))
@test_broken gtb.geometry == gtpoly.geometry
@test gtb.float == gtpoly.float
@test gtb.int == gtpoly.int
@test gtb.string == gtpoly.string
end
24 changes: 19 additions & 5 deletions test/io/geopackage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,38 @@
end

@testset "save" begin
# note: currently GeoIO does not save the CRS
# and the default CRS used by GDAL is not valid
# note: GeoPackage does not preserve column order
file1 = joinpath(datadir, "points.gpkg")
file2 = joinpath(savedir, "points.gpkg")
gtb1 = GeoIO.load(file1)
GeoIO.save(file2, gtb1)
@test_throws ArgumentError GeoIO.load(file2)
gtb2 = GeoIO.load(file2)
@test Set(names(gtb2)) == Set(names(gtb1))
@test_broken gtb2.geometry == gtb1.geometry
@test gtb2.code == gtb1.code
@test gtb2.name == gtb1.name
@test gtb2.variable == gtb1.variable

file1 = joinpath(datadir, "lines.gpkg")
file2 = joinpath(savedir, "lines.gpkg")
gtb1 = GeoIO.load(file1)
GeoIO.save(file2, gtb1)
@test_throws ArgumentError GeoIO.load(file2)
gtb2 = GeoIO.load(file2)
@test Set(names(gtb2)) == Set(names(gtb1))
@test_broken gtb2.geometry == gtb1.geometry
@test gtb2.code == gtb1.code
@test gtb2.name == gtb1.name
@test gtb2.variable == gtb1.variable

file1 = joinpath(datadir, "polygons.gpkg")
file2 = joinpath(savedir, "polygons.gpkg")
gtb1 = GeoIO.load(file1)
GeoIO.save(file2, gtb1)
@test_throws ArgumentError GeoIO.load(file2)
gtb2 = GeoIO.load(file2)
@test Set(names(gtb2)) == Set(names(gtb1))
@test_broken gtb2.geometry == gtb1.geometry
@test gtb2.code == gtb1.code
@test gtb2.name == gtb1.name
@test gtb2.variable == gtb1.variable
end
end
Loading