Comments (8)
It is meant to be an internal method and called in methods when there was an error in a GDAL function (the function returns an error code or nothing when it was supposed to return something).
It attempts to create a unified (internal) API for spitting out a sensible error message. The message is composed from a) internal error stack that is filled by CPLErrorHandler which is installed and then called by GDAL for all errors - GDAL may call it many times before it returns from an API function, or b) textualized OGRError code, or c) "Unknown error" when the argument is not understood.
Call it without an argument or with a ref to hash which has key OGRError with OGR error code (integer 1..9) as the value.
from geo-gdal-ffi.
Maybe the two cases should be combined, i.e., maybe(?) OGR function returns an error code but it has also called the error handler before returning.
from geo-gdal-ffi.
Thanks.
The system might need a more generic error reporting system so the GDAL errors are exposed.
If I run code like this:
$geom->Intersection ($fish->GetGeomField);
then it dies with the exception:
Modification of a read-only value attempted at C:/berrybrew/5.28.0_64_PDL/perl/site/lib/Geo/GDAL/FFI/Geometry.pm line 262.
When I wrap it in an eval
my $intersection = eval {
$geom->Intersection ($fish->GetGeomField);
};
warn Geo::GDAL::FFI::error_msg() if $@;
I get the error:
GEOS support not enabled. at C:\shawn\git\biodiverse\etc\experiments\polygon_intersect.pl line 29.
Getting GEOS support to work is relatively straightforward (see https://github.com/shawnlaffan/perl-alien-geos), except on Windows due to makefile command lengths (but that's a different issue).
from geo-gdal-ffi.
And by "exposed" I mean through the usual perl channels like warning.
from geo-gdal-ffi.
I've done a minimal job in wrapping those methods. Also for example
$g->Intersection(undef);
dumps core since GDAL does not validate the pointer. (I think it should).
Perhaps something like this would be ok:
sub Intersection {
my ($self, $geom) = @_;
confess "Undefined geometry." unless $geom;
$self = Geo::GDAL::FFI::OGR_G_Intersection($$self, $$geom);
confess Geo::GDAL::FFI::error_msg() unless $self;
return bless \$self, 'Geo::GDAL::FFI::Geometry';
}
from geo-gdal-ffi.
Something along those lines would be good, I think.
from geo-gdal-ffi.
Done in c7c177e.
from geo-gdal-ffi.
Thanks again.
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
- Fails to build with GDAL 3.8.0 HOT 13
- 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.