Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no such function: RTreeIntersects but other spatial functions work. #2

Closed
johnwebbcole opened this issue Apr 2, 2013 · 4 comments
Closed

Comments

@johnwebbcole
Copy link

Trying to run a simple query and I'm getting a error:

{ [Error: SQLITE_ERROR: no such function: RTreeIntersects] errno: 1, code: 'SQLITE_ERROR' }

If you remove the and PK_UID in ... portion of the query it runs fine.

What do I need to do to make the RTreeIntersects function available?
Here is my code:

/*global require console setTimeout */
'use strict';

var sqlite3 = require('spatialite').verbose();

var db = new sqlite3.Database("db.spatial4", sqlite3.OPEN_READONLY);

var sql = "select AsGeoJSON(CastToPolygon(Geometry)) geom from Demographics where ST_Within(GeomFromText('POINT(-85.188561 35.038023)', 4326), Geometry) and PK_UID in (select pkid from idx_Demographics_Geometry where pkid MATCH RTreeIntersects(-85.188561,35.038023,-85.188561,35.038023));";
var query;

db.spatialite(function() {
    //query = db.prepare(sql);
    db.all("select spatialite_version();", function(err, rows) {
        console.log(err, rows);
    });
    db.all(sql, function(err, rows) {
        console.log(err, rows);
    });
});

I'm running node v0.10.1 on win7 with node_modules:

└─┬ spatialite@0.0.2
└── sqlite3@2.1.7

@zhm
Copy link
Owner

zhm commented Apr 2, 2013

Thanks for submitting this. It looks like RTreeIntersects requires spatialite to be compiled with 'geocallbacks' enabled. I will look into enabling this when I get a chance. RTreeIntersects and RTreeDistWithin look like they won't work yet.

@zhm
Copy link
Owner

zhm commented Apr 2, 2013

OK, I push version 0.0.3 which enables those functions. It should work now if you re-build the module. Thanks!

@johnwebbcole
Copy link
Author

I've tried to install 0.0.3, but he build fails. I opened a ticket with the error.

@zhm
Copy link
Owner

zhm commented Apr 10, 2013

While looking into this issue, I found this thread where Sandro (SpatiaLite maintainer) says the following:

SQLite introduced the sqlite3_rtree_geometry_callback() API about
one or two years ago; so if you are using some very old libsqlite3
this symbol will not be defined.

Please note: SpatiaLite discourages using the Geometry Callback
based interface, and will be disabled by default in any new
version.
so the suggested solution when building splite is to always define:

DISABLE_GEOMETRY_CALLBACKS

bye Sandro 

The problem is that the sqlite extension API (sqlite3ext.h) doesn't expose the symbol required for RTreeIntersects. So a sqlite extension loaded dynamically (i.e. not compiled with sqlite3) doesn't actually have this symbol available. Since node-spatialite depends on node-sqlite3 and uses the dynamic loading feature, I don't think it's possible to get support for the 2 RTree functions. Is there another way to accomplish the task without using RTreeIntersects?

Maybe this might help?

https://groups.google.com/forum/#!msg/spatialite-users/JbeB5XsVq5E/lwQWGNAoQ6gJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants