Comments (9)
Hi @constantinius and @rowanwins . You may have already thought of it, but I'd like to offer this hacky code as a potential workaround :-)
const fs = require("fs");
const GeoTIFF = require("geotiff/dist/geotiff.bundle.min.js");
const buffer = fs.readFileSync("/tmp/test.tif");
// convert Buffer to ArrayBuffer
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
GeoTIFF.fromArrayBuffer(arrayBuffer).then(tiff => {
console.log(tiff);
});
from geotiff.js.
That is actually a pretty good idea, thanks @DanielJDufour. This particular source might work for smaller files, but on the other hand, you could just copy the relevant source
, instantiate it and use the GeoTIFF.fromSource
function to create it.
from geotiff.js.
Hi @rowanwins
Thank you for reporting this issue.
It seems like this is a tough spot, and I'm not sure if there is a suitable workaround right now other than to use babel.
I was not aware of that but I learned in #50 that the import
/export
syntax is not yet supported in node, so using the source files in src/
will probably not work.
On the other hand, the bundling is configured for browser use only, so typical node modules (like fs
) are deliberately left empty, which results in the error you have seen.
The options I see are:
- make your own bundle, please look at the
webpack.config.js
and delete thenode
section, and then rebuild - Install the
babel-runtime
I would love to help out, but unfortunately, I'm completely bogged down in other projects, so I cannot work on a solution at the moment.
from geotiff.js.
Yeah no worries @constantinius
Probably the best thing I can think of would be reconfiguring the build process, perhaps creating one node-focused webpack config, and one browser-focused webpack config. I can potentially take a look into that at some stage so you may see a pull request although like you my time is limited :)
from geotiff.js.
Hi,
I personally don't like to have to import babel in my NodeJS projects ... 🤢 It would be nice if we could create a clean NodeJS build !
I'm not a regular user of babel, but I still don't understand why we need to import babel once the package is built ... I probably misunderstood the purpose of Babel here but, isn't it about polyfill and should not appear as a dependency when using the built version ?
Also, note that since NodeJS 13.2.0+ import / export are properly handled by NodeJS and --experimental-modules
is no longer required, adding "type": "module"
to package.json
should be enough to run .js
files as ES modules.
from geotiff.js.
If we have to keep babel for any raison, maybe it would be better to define it as a peerDependency in the package.json
.
from geotiff.js.
I believe that a lot has changed since I introduced babel back in the days. Both browser, node and tooling landscapes have significantly improved. I think a very scrutinizing look should be cast upon all the (dev-) dependencies, as I believe many are outdated.
Regarding babel in particular: I'm a bit surprised to hear that it is actually still part of the runtime libs. I think there was a PR/discussion once that introduced it, but I thought it was averted. Seems like I was wrong.
@PacoDu you seem to be familiar with node packages, so I would be glad for you insight how you package such a library without dropping support for versions of node still in use. Do you have experience with that?
from geotiff.js.
@constantinius I have some knowledge about node package but I always try to keep every thing up to date without thinking about backward compatibility. But I can take some time to take a look at geotiff.js package.json and build configuration, which versions of NodeJS do you want to support ? (NodeJS LTS is currently v12)
from geotiff.js.
That is very much appreciated, thank you very much!
I guess we should take v12 as our lower end.
from geotiff.js.
Related Issues (20)
- The exports `package.json` needs a new paint job HOT 3
- How do I use compression? HOT 3
- Typescript compilation error in BaseClient HOT 14
- Writing GeoTiffs HOT 3
- Reading files larger than 4gb? HOT 1
- image.readRasters() HOT 3
- Exceeds max_safe_integer. Precision may be lost. HOT 2
- Type error at build time HOT 1
- Abort signal should be extended to `getImage` when performing slice's fetch action
- Property 'headers' does not exist on type '{}'
- Pool workers lead to memory leak? HOT 3
- using geotiff.js with react-native HOT 6
- 请升级一下lerc依赖 HOT 2
- credentials option is ignored HOT 3
- idenify does not work on GeoTiff float (Digitales Höhenmodell Oberfläche NRW) HOT 2
- Generating a geotiff from an image and a list of ground control points.
- readRGB() does not always return an interleaved array HOT 2
- Support also CommonJS HOT 4
- BlockedSource: Duplicated HTTP range requests
- capturing world coordinates form the tiff imaegs using geotiff.js 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 geotiff.js.