Skip to content

Commit

Permalink
Format .jl files (#450)
Browse files Browse the repository at this point in the history
Co-authored-by: yeesian <[email protected]>
  • Loading branch information
github-actions[bot] and yeesian authored Nov 15, 2024
1 parent 2680765 commit 8abed58
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
15 changes: 10 additions & 5 deletions ext/ArchGDALJLD2Ext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ struct ArchGDALSerializedGeometry
wkb::Vector{UInt8}
end

JLD2.writeas(::Type{<:AG.AbstractGeometry}) = ArchGDALSerializedGeometry

JLD2.writeas(::Type{<: AG.AbstractGeometry}) = ArchGDALSerializedGeometry

function JLD2.wconvert(::Type{<: ArchGDALSerializedGeometry}, x::AG.AbstractGeometry)
function JLD2.wconvert(
::Type{<:ArchGDALSerializedGeometry},
x::AG.AbstractGeometry,
)
return ArchGDALSerializedGeometry(AG.toWKB(x))
end

function JLD2.rconvert(::Type{<: AG.AbstractGeometry}, x::ArchGDALSerializedGeometry)
function JLD2.rconvert(
::Type{<:AG.AbstractGeometry},
x::ArchGDALSerializedGeometry,
)
return AG.fromWKB(x.wkb)
end

end
end
5 changes: 3 additions & 2 deletions src/ogr/feature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,12 @@ function getfield(feature::AbstractFeature, i::Integer)
_fieldtype = getfieldtype(getfielddefn(feature, i))
try
_fetchfield = _FETCHFIELD[_fieldtype]
if _fieldtype in (OFTIntegerList, OFTRealList, OFTStringList, OFTInteger64List)
if _fieldtype in
(OFTIntegerList, OFTRealList, OFTStringList, OFTInteger64List)
# copy to ensure that GDAL does not free / overwrite the memory.
# the docs for the field fetcher functions mention that the returned
# pointer is not valid for very long.
return Base.copy(_fetchfield(feature, i))
return Base.copy(_fetchfield(feature, i))
else
# for static types, we can just return the returned value.
return _fetchfield(feature, i)
Expand Down
12 changes: 7 additions & 5 deletions test/test_geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1032,11 +1032,13 @@ import JLD2

@testset "JLD2 serialization" begin
filepath = joinpath(tempdir(), "test_geometry.jld2")
geom = AG.fromWKT("MULTIPOLYGON (" *
"((0 4 8,4 4 8,4 0 8,0 0 8,0 4 8)," *
"(3 1 8,3 3 8,1 3 8,1 1 8,3 1 8))," *
"((10 4 8,14 4 8,14 0 8,10 0 8,10 4 8)," *
"(13 1 8,13 3 8,11 3 8,11 1 8,13 1 8)))")
geom = AG.fromWKT(
"MULTIPOLYGON (" *
"((0 4 8,4 4 8,4 0 8,0 0 8,0 4 8)," *
"(3 1 8,3 3 8,1 3 8,1 1 8,3 1 8))," *
"((10 4 8,14 4 8,14 0 8,10 0 8,10 4 8)," *
"(13 1 8,13 3 8,11 3 8,11 1 8,13 1 8)))",
)

JLD2.save_object(filepath, geom)
geom2 = JLD2.load_object(filepath)
Expand Down

0 comments on commit 8abed58

Please sign in to comment.