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

copy all array like feature fields after unsafe_wrap #442

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Changes from 3 commits
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
14 changes: 11 additions & 3 deletions src/ogr/feature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,22 @@ null, it will return `missing`.
"""
function getfield(feature::AbstractFeature, i::Integer)
return if !isfieldset(feature, i)
nothing
return nothing
elseif isfieldnull(feature, i)
missing
return missing
else
_fieldtype = getfieldtype(getfielddefn(feature, i))
try
_fetchfield = _FETCHFIELD[_fieldtype]
_fetchfield(feature, i)
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 copy(_fetchfield(feature, i))
asinghvi17 marked this conversation as resolved.
Show resolved Hide resolved
else
# for static types, we can just return the returned value.
return _fetchfield(feature, i)
end
catch e
if e isa KeyError
error(
Expand Down
Loading