Comments (13)
Fixed in 8eee520. The write method must return 1 if the write was succesful. The closure in FFI.pm now returns 1 also in the case the user side class does not return anything (as in the test).
from geo-gdal-ffi.
I can reproduce locally using GDAL 3.8.0RC1.
The error message is only associated with the geojson OGR driver in the GDAL code base.
https://github.com/search?q=repo%3AOSGeo%2Fgdal+%22Cannot+write+feature%22&type=code
Disabling the preceding test block gets the test to pass.
Line 34 in 18bfef5
Moving the failing test block so it is run first also gets the tests to pass.
The above suggests that something is not being cleaned up in the first test block starting at L34. I'm not sure what.
@ajolma - any ideas?
from geo-gdal-ffi.
Possibly something is awry with the default callback after an override has been cleared.
Geo-GDAL-FFI/lib/Geo/GDAL/FFI.pm
Lines 1718 to 1731 in 18bfef5
from geo-gdal-ffi.
Possibly something is awry with the default callback after an override has been cleared.
That looks like a red herring as the callback is not called in the second block with the geotiff creation.
from geo-gdal-ffi.
I could reproduce it in a docker with clone of gdal 3.8.0. However, I don't understand why it fails. I asked Even - apparently the mail did not go to gdal-dev but to him only - and he has no recollection of anything done in that area. I'm wondering why there is not VSIStdoutUnsetRedirection to undo the effect of the previous test but the undo seems to be a bit strange.
from geo-gdal-ffi.
The error is somehow caused by the first test, which copies a memory layer to geojson stdout redirected to a variable. The test is ok as the geojson is ok in the variable but for some reason there's an error generated and left in the error stack. That error then is mistaken as an error in the geotiff creation. I can't yet even find where the error is generated in gdal and why.
from geo-gdal-ffi.
The reason for why I did not find where the error came from in GDAL was that I was looking at wrong branch in GDAL tree, not the master.
from geo-gdal-ffi.
Confirmed fixed with the changes from 8eee520.
from geo-gdal-ffi.
Confirmed fixed with the changes from 8eee520.
Unfortunately not. libgeo-gdal-ffi-perl (0.1-3) contains a patch with those changes, but the rebuild with GDAL 3.8.0 on the Debian buildds still fails (which it did not do when I tested it on my system):
Cannot write feature at /<<PKGBUILDDIR>>/blib/lib/Geo/GDAL/FFI/Driver.pm line 49.
Geo::GDAL::FFI::Driver::Create(Geo::GDAL::FFI::Driver=SCALAR(0x562aed4103d8), "/vsimem/test.tiff", 10) called at t/vsistdout.t line 63
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 2 just after 1.
t/vsistdout.t ..
https://buildd.debian.org/status/package.php?p=libgeo-gdal-ffi-perl
from geo-gdal-ffi.
This is a leftover error from the JSON write.
Ideally the source of the error would be fixed, but clearing the @Geo::GDAL::FFI::errors
array at the end of the test block gets the test to pass.
The question is whether any errors should be cleared automatically when the VSI writer is closed. Perhaps the contents should be written to STDOUT while clearing.
from geo-gdal-ffi.
This looks like a broader problem with CopyLayer or maybe the GDAL JSON conversion process.
I updated the test to create three features in the source layer. However, the resulting JSON string only contains the first one.
Calling FlushCache on the data set has no effect.
diff --git a/t/vsistdout.t b/t/vsistdout.t
index 02be848..038ecbc 100644
--- a/t/vsistdout.t
+++ b/t/vsistdout.t
@@ -33,21 +33,32 @@ use JSON;
# test vsistdout redirection
if(1){
# create a small layer and copy it to vsistdout with redirection
- my $layer = GetDriver('Memory')->Create->CreateLayer({GeometryType => 'None'});
+ my $ds = GetDriver('Memory')->Create;
+ my $layer = $ds->CreateLayer({GeometryType => 'None'});
$layer->CreateField(value => 'Integer');
$layer->CreateGeomField(geom => 'Point');
+for my $i (5..7) {
my $feature = Geo::GDAL::FFI::Feature->new($layer->GetDefn);
$feature->SetField(value => 12);
- $feature->SetGeomField(geom => [WKT => 'POINT(1 1)']);
+ $feature->SetGeomField(geom => [WKT => "POINT(1 $i)"]);
$layer->CreateFeature($feature);
-
+}
+ $ds->FlushCache;
+diag 1;
+diag @Geo::GDAL::FFI::errors;
+diag "F count: " . $layer->GetFeatureCount;
my $output = Output->new;
my $gdal = Geo::GDAL::FFI->get_instance;
$gdal->SetWriter($output);
GetDriver('GeoJSON')->Create('/vsistdout')->CopyLayer($layer);
$gdal->CloseWriter;
+diag 2;
+diag @Geo::GDAL::FFI::errors;
my $ret = $output->output;
+diag 3;
+diag $ret;
+diag @Geo::GDAL::FFI::errors;
ok($ret eq
'{"type": "FeatureCollection",'.
'"features": '.
@@ -56,8 +67,10 @@ if(1){
'"coordinates": [ 1.0, 1.0 ] } }]}end',
"Redirect vsistdout to write/close methods of a class.");
+@Geo::GDAL::FFI::errors = ();
}
+
# test Translate
if(1){
my $ds = GetDriver('GTiff')->Create('/vsimem/test.tiff', 10);
from geo-gdal-ffi.
Found it.
The write method of the override class needs to return 1 on success, not any true value.
This is checked for by the GDAL JSON driver:
https://github.com/OSGeo/gdal/blob/edf1ee72fccc8cb91519218a2c4e021ecd31d0f4/ogr/ogrsf_frmts/geojson/ogrgeojsonwritelayer.cpp#L338-L342
I'll work up a PR.
from geo-gdal-ffi.
For reference, the GDAL commit that changed the return behaviour is OSGeo/gdal@b25706e
from geo-gdal-ffi.
Related Issues (20)
- CreateLayer fails if SpatialReference arg exists but is invalid (undef or blank) HOT 3
- Test failure with GDAL 3.01 and Proj 6.2 HOT 1
- FFI::Platypus::Declare is now a separate distribution, needs to be added to Makefile.PL HOT 1
- Can't locate FFI/Platypus/Declare.pm in @INC HOT 2
- Drive by comment: consider ignore_not_found HOT 1
- Add recent OGRGeometry functions HOT 6
- ubuntu 20.04 unable to install using cpan or cpanm HOT 10
- How to do coordinate transformations in Geo::GDAL::FFI HOT 2
- Is the data dir check needed for GDAL >= 2.3.1? HOT 1
- Should Geo::GDAL::FFI::Band inherit from Geo::GDAL::FFI::Object? HOT 1
- Tests fail on FreeBSD as NITF is not found HOT 17
- warning received during loading $FFI::Platypus 'used only once' HOT 1
- Type of the function argument(s) incorrect for GDALInvGeoTransform and GDALApplyGeoTransform HOT 3
- Typo in Geometry.pm
- Thread safety issue. HOT 23
- Add Geo::GDAL::FFI::Layer::GetFeatureCount method
- Tests: use Test::TempDir::Tiny
- test failures in t/00.t
- Release version 0.11 to CPAN HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geo-gdal-ffi.