Giter VIP home page Giter VIP logo

Comments (6)

brandonreavis avatar brandonreavis commented on August 10, 2024

Yeah agreed. I was just talking to @brianreavis about that the other day. I was debating whether or not to fix this issue because all solutions seem messy.

It requires a null pointer check every time a destroyable object (dataset, band, ogrfeature, ogrdatasource, etc) is unwrapped. This happens in all of the object's wrapped methods and every time it is used in a method argument. I ended up going with this solution even though it's kinda nasty.

https://github.com/naturalatlas/node-gdal/blob/master/src/gdal_common.hpp#L385-L386

from node-gdal.

brandonreavis avatar brandonreavis commented on August 10, 2024

Whoops. That doesn't fix the whole problem. If you destroy a Dataset, all of the RasterBand pointers still are non-null, but are bogus. I'll hopefully get around to fixing this tomorrow.

Similar problem with OGR and datasources/layers:
https://github.com/naturalatlas/node-ogr/issues/2

from node-gdal.

sgillies avatar sgillies commented on August 10, 2024

In Rasterio, I did away with GDAL Band objects and replaced them with more featureful Numpy arrays. This also did away with dangling pointers. Would it be useful and possible to do this for Node? Maybe using https://www.npmjs.org/package/ndarray?

from node-gdal.

brandonreavis avatar brandonreavis commented on August 10, 2024

I don't have experience with ndarray, but it looks useful and promising. I don't think we would want to replace gdal bands with it in the binding though. If we did, we would have to read the whole raster into memory, which could be slower than desired. Also, then you would lose the ability to access overviews.

I think allowing people to easily copy a band into a ndarray would be the better option.

The OGR datasource/layer dangling pointer problem is something we can't fix by copying data, so we'll have to come up with some solution. I haven't had the time to give it much thought yet.

One option is that we could maintain a list of child Layer objects for each Datasource object so that when a datasource is destroyed we can set all the pointers to the OGRLayers to null.

from node-gdal.

springmeyer avatar springmeyer commented on August 10, 2024

Nice to see that the immediate ds.close() issue is solved:

> ds.close()
undefined
> ds.getRasterXSize()
Error: Dataset object has already been destroyed
    at repl:1:5
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.EventEmitter.emit (events.js:98:17)
    at emitKey (readline.js:1095:12)

from node-gdal.

brandonreavis avatar brandonreavis commented on August 10, 2024

Now have bands properly being disposed when datasets are closed: (cf57534, 95ed8f3)

> band.getXSize()
984
> ds.close()
undefined
> band.getXSize()
Error: RasterBand object has already been destroyed
    at repl:1:7
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.EventEmitter.emit (events.js:98:17)
    at emitKey (readline.js:1095:12)

from node-gdal.

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.