Comments (6)
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.
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.
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.
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.
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.
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)
- polygon intersection with another geometry
- Can't open MVT for write
- gdal.Driver.create's parameter: data_type which need Integer(number) , however , Constants (GDT) : gdal.GDT_* provide string HOT 4
- Using node-gdal in electron HOT 4
- This its under other libs and can't even compile because node-pre-gyp ERROR
- DGN driver
- Node.js 14 HOT 3
- converting
- Node 16 binaries on older OS (glibc version) HOT 3
- npm install not working HOT 2
- Change the AREA_OR_POINT value
- Multi process Read Error HOT 1
- Memory Usage Overflow
- Problem with Node 17
- npm install gdal --save errors on M1 mac HOT 3
- What versions of nodejs are supported?
- Example of resolving GPS lat/long to elevation from a WGS84 TIFF HOT 15
- Get altitude/elevation from GPS coordinates HOT 1
- Add support for node 18
- Is there any release for arm64?
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 node-gdal.