geopackage-js icon indicating copy to clipboard operation
geopackage-js copied to clipboard

Unable to execute the sample NodeJS code

Open mrkhan opened this issue 6 years ago • 7 comments

Hi,

I was trying to use the NodeJS Usage code mentioned in README.md but got an error

TypeError: Cannot read property 'open' of undefined at Object. (<My workspace>\app.js:10:18)

`var geopackage = require('@ngageoint/geopackage') , GeoPackageManager = geopackage.GeoPackageManager , GeoPackageConnection = geopackage.GeoPackageConnection , GeoPackageTileRetriever = geopackage.GeoPackageTileRetriever;

var filename = "./rivers.gpkg";

GeoPackageManager.open(filename, function(err, geoPackage) {`

it seems that GeoPackageManager is undefined. is there any prerequisite before using geopackage-js ?

Regards, M. Rizwan Khan

mrkhan avatar Nov 28 '17 06:11 mrkhan

Just an observation in index.js file in start of the file, its exporting other modules except the GeoPackageManager module

var proj4Defs = require('./lib/proj4Defs'); module.exports.proj4Defs = proj4Defs; module.exports.GeoPackageTileRetriever = GeoPackageTileRetriever; module.exports.GeoPackageConnection = GeoPackageConnection;

If I add module.exports.GeoPackageManager = GeoPackageManager; to it the sample code works fine. So is the readme file incorrect or the code?

Regards, M. Rizwan Khan

mrkhan avatar Nov 28 '17 12:11 mrkhan

The README has not been updated to the new version of the code. I will update it to be correct. When you require var geopackage = require('@ngageoint/geopackage') you can now open a GeoPackage by calling geopackage.open(filename, callback);

danielbarela avatar Nov 28 '17 13:11 danielbarela

If you want I can update it ?

mrkhan avatar Nov 29 '17 05:11 mrkhan

Feel free to update and make a pull request. Thank you for your help.

danielbarela avatar Nov 29 '17 05:11 danielbarela

How can we retrieve the content of geom, in other words how can we retrieve coordinates (long,lat) of a point using JavaScript from Geo-package?

waghmareatul8 avatar Feb 13 '18 12:02 waghmareatul8

@waghmareatul8 https://github.com/ngageoint/geopackage-js/blob/master/test/lib/testFeatureCreate.js#L232-L236

danielbarela avatar Feb 13 '18 20:02 danielbarela

Dear Sir,

Thanks for your email and reply pointing towards file and section. Im quite new into this, hope come up positively with your constant support.

Kind Regards

On 14 February 2018 at 01:51, Dan [email protected] wrote:

@waghmareatul8 https://github.com/waghmareatul8 https://github.com/ngageoint/geopackage-js/blob/master/ test/lib/testFeatureCreate.js#L232-L236

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ngageoint/geopackage-js/issues/98#issuecomment-365391916, or mute the thread https://github.com/notifications/unsubscribe-auth/AavgQjTyGD41fIZKfEHDlRN3sifiFa9Jks5tUe7CgaJpZM4Qsv7A .

--

Thanks with Regards

Atul W

waghmareatul8 avatar Feb 13 '18 22:02 waghmareatul8