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

createfeature on feature definition doesn't write out any data? #66

Open
cchderrick opened this issue Oct 18, 2018 · 3 comments
Open

createfeature on feature definition doesn't write out any data? #66

cchderrick opened this issue Oct 18, 2018 · 3 comments
Milestone

Comments

@cchderrick
Copy link
Contributor

I was following the test/test_gdal_tutorials.jl script, the tutorial lead to shapefiles without any data.

AG.create("$pointshapefile.shp", "ESRI Shapefile") do dataset
            ...
            featuredefn = AG.getlayerdefn(layer)
            @test AG.getname(featuredefn) == "point_out"
            AG.createfeature(featuredefn) do feature # This doesn't write any data out
            #AG.createfeature(layer) do feature # I ended with this, which works
                AG.setfield!(feature, AG.getfieldindex(feature, "Name"), "myname")
            ...
end

It doesn't error out because it is defined in context.jl line 52. So I am not sure if this is a bug or user error.

References:

function createfeature(f::Function, featuredefn::FeatureDefn)
feature = unsafe_createfeature(featuredefn); reference(featuredefn)
# the additional reference & dereference here is to deal with the case
# where you start by (1) creating a featuredefn (0 references)
# before (2) using it to create a feature here.
# if we do not artificially increase the reference, then destroy(feature)
# will release the featuredefn, when we're going to handle it ourselves
# later. Therefore we dereference (rather than release) the featuredefn.
try f(feature) finally destroy(feature); dereference(featuredefn) end
end

featuredefn = AG.getlayerdefn(layer)
@test AG.getname(featuredefn) == "point_out"
AG.createfeature(featuredefn) do feature
AG.setfield!(feature, AG.getfieldindex(feature, "Name"), "myname")
AG.setgeomdirectly!(feature, AG.unsafe_createpoint(100.123, 0.123))
end
end

@visr
Copy link
Collaborator

visr commented Oct 18, 2018

Yeah I believe it should be called on layers. See also JuliaGeo/GDAL.jl#59. We should probably add the feature count test here as well.

@yeesian
Copy link
Owner

yeesian commented Oct 18, 2018

  1. yeah it should have been called on the layer in that test. Hence the bug label
  2. More generally, I can see how it will be confusing to users, and we should add documentation to distinguish between creating "floating" features, versus features that are "owned" by layers.

@yeesian
Copy link
Owner

yeesian commented Nov 19, 2018

Test bug has been fixed in #67

@yeesian yeesian removed the bug label Nov 19, 2018
@yeesian yeesian added this to the v1.0 milestone May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants