Comments (5)
👍 Let's aim higher than the C API. Those Python bindings are especially grim when dealing with Polygons.
from node-gdal.
I'm really glad someone has time to work on this :)
If the goal is to add JS sugar to the API, one approach would be to put the sugar in a different layer of the bindings. As in, implement the bare metal in C++ and write the actual public API in JavaScript. I think it's best, in general, if only the absolute minimum is done in native code so it reduces the complexity of the native code and the JS sugar doesn't have to be written in C++. Or it could be done with a mixture of both exposed native objects and some JS code to do things like property accessors and small transforms.
Anyways, just my 2 cents, great work!
from node-gdal.
Hey Zac! First of all, thanks a ton for all the work you put into the OGR bindings. It saved a bunch of time not having to make the GDAL bindings from nothing. We will make sure to credit you in the main readme. Since I copied the node-ogr files into node-gdal repo, it unfortunately scrubbed you out as a contributor.
I like the idea of doing the tasteful sugar in JS whenever reasonable. Example:
module.exports.ogr.Feature.prototype.getFields = function() {
var i, n, values, field_name;
n = this.getFieldCount();
values = {};
for (i = 0; i < n; i++) {
field_name = this.getFieldDefn(i).getName();
values[field_name] = this.getField(i);
}
return values;
};
There will be cases where putting the sugar in C++ would be good if doing it JS would hurt performance too much. (The example above might be one)
I think the bindings should still feel like GDAL. We should add just enough sugar to make it intuitive for a JS programmer, but not add so much that it creates a nightmare when converting a GDAL/OGR script from python or C++ to JS.
from node-gdal.
Great thinking @brandonreavis. Great to see you here @zhm!
from node-gdal.
Alright the better constructors are now functional after these commits (dfd074e, 391348b)
Using distinct geometry subclasses (ie. Point, Polygon, ...) helps with a few things
- No need call
getGeometryType()
in every method binding. instanceof
operator can be used to check geometry types instead of callinggetGeometryType
and comparing it with thewkbGeomType
enum
I also moved the bound OGRGeometryFactory methods to be static Geometry methods in JS.
> pt = ogr.Geometry.createFromWkt("Point(10 20)")
{ z: 0, y: 20, x: 10 }
> pt instanceof ogr.LineString
false
> pt instanceof ogr.Point
true
> pt instanceof ogr.Geometry
true
> pt.x *= 10
100
> pt2 = new ogr.Point(pt.x*10, pt.y*10)
{ z: 0, y: 200, x: 1000 }
Still need to think about how to clean up the rest of the geometry types.
from node-gdal.
Related Issues (20)
- 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?
- failed npm install gdal 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 node-gdal.