diff --git a/ext/ArchGDALJLD2Ext.jl b/ext/ArchGDALJLD2Ext.jl index 0ddf2b75..4f88fd5b 100644 --- a/ext/ArchGDALJLD2Ext.jl +++ b/ext/ArchGDALJLD2Ext.jl @@ -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 \ No newline at end of file +end diff --git a/src/ogr/feature.jl b/src/ogr/feature.jl index 31f88b7a..5c7973c6 100644 --- a/src/ogr/feature.jl +++ b/src/ogr/feature.jl @@ -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) diff --git a/test/test_geometry.jl b/test/test_geometry.jl index 6561677e..a1460b1a 100644 --- a/test/test_geometry.jl +++ b/test/test_geometry.jl @@ -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)