Giter VIP home page Giter VIP logo

Comments (8)

ajolma avatar ajolma commented on July 18, 2024

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.

ajolma avatar ajolma commented on July 18, 2024

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.

shawnlaffan avatar shawnlaffan commented on July 18, 2024

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.

shawnlaffan avatar shawnlaffan commented on July 18, 2024

And by "exposed" I mean through the usual perl channels like warning.

from geo-gdal-ffi.

ajolma avatar ajolma commented on July 18, 2024

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.

shawnlaffan avatar shawnlaffan commented on July 18, 2024

Something along those lines would be good, I think.

from geo-gdal-ffi.

ajolma avatar ajolma commented on July 18, 2024

Done in c7c177e.

from geo-gdal-ffi.

shawnlaffan avatar shawnlaffan commented on July 18, 2024

Thanks again.

from geo-gdal-ffi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.