mercredi 24 juin 2015

how To enable the R*Tree module in c#

I am writ in c# and use spatialite library

my code is:

        string database = "Boston.sqlite";
        using (DbConnection connection = new SQLiteConnection("Data Source=" + database))
        {
            connection.Open(); 
            using (DbCommand command = connection.CreateCommand())
            {
                //1. Load the libspatialite library extension 
                command.CommandText = "SELECT load_extension('mod_spatialite.dll');";
                command.ExecuteScalar();


                Console.WriteLine("Insert max distance");
                double maxDistance = Double.Parse(Console.ReadLine()) / 3600;
                Console.WriteLine("Insert min distance");
                double minDistance = Double.Parse(Console.ReadLine()) / 3600;

                command.CommandText = string.Format("SELECT a.ROWID, a.geometry, b.geometry , Distance(a.geometry, b.geometry),a.name ,b.name FROM points AS a, points AS b WHERE "
                                      + "a.ROWID > b.ROWID and Distance(a.geometry, b.geometry) < {0} AND Distance(a.geometry, b.geometry) > {1} and "
                                      + "b.ROWID IN (SELECT ROWID FROM idx_points_geometry "
                                      + "WHERE pkid MATCH RTreeIntersects ("
                                      + "MbrMinX(a.geometry),"
                                      + "MbrMinY(a.geometry),"
                                      + "MbrMaxX(a.geometry),"
                                      + "MbrMaxY(a.geometry))) order by  a.ROWID;", maxDistance, minDistance);
                command.ExecuteScalar(); 

            }
        }

And this exception throw

no such function: RTreeIntersects

I read on this site http://ift.tt/16ppui1 what to do but I do not know how to do it in C # Can someone help me and write a step by step what I need to do to make it work

Thx

Aucun commentaire:

Enregistrer un commentaire