node-spatialite icon indicating copy to clipboard operation
node-spatialite copied to clipboard

InitSpatialMetaData()

Open diplonics opened this issue 11 years ago • 2 comments

Hi, While I'm not new to spatial data and using PostGIS etc. I am new to node and this package. I'm trying to run this query: var query = "SELECT AsGeoJSON(ST_Transform(GeomFromText('LINESTRING(" + lineString + ")',4326), 3857), 6, 3) AS tbbox;";

but the ST_Transform is failing with the message: { [Error: SQLITE_ERROR: no such table: spatial_ref_sys] errno: 1, code: 'SQLITE_ ERROR' }

How to I enable/create the spatial_ref_table, is there something I missed during the installation?

Thanks in advance.

diplonics avatar Nov 12 '14 13:11 diplonics

Can you paste a complete code snippet that reproduces it? It might be related to the setup code....

zhm avatar Nov 12 '14 14:11 zhm

No probs, here's the code but don't think anything fancy is being done here.


var sqlite = require('spatialite'); var db = new sqlite.Database(':memory:'); var query = "SELECT AsGeoJSON(ST_Transform(GeomFromText('LINESTRING(" + lineString + ")',4326), 3857), 6, 3) AS tbbox;"; db.spatialite(function(error){ db.each(query, function(error, row){ if(error){ console.log(error); } console.log(util.inspect(row, false, null)); //Other logic code to happen here based on the SQL transform result }); }); db.close();


For your info and might help. Removing the ST_Transform method and all runs fine. The platform I'm developing on is Windows 7 so followed your VS build instructions. This code will be deployed on a linux server but I don't have access to this to test this issue yet.

Thanks again.

diplonics avatar Nov 12 '14 14:11 diplonics