lundi 3 août 2015

Sqlite generate distance table from point information

I have a table that contains coordinates of several points.

| PointName | XCoor | YCoor |
+-----------+-------+-------+
|    P1     |  X1   |  Y1   |
+-----------+-------+-------+
|    P2     |  X2   |  Y2   |
+-----------+-------+-------+
....

I want to generate a table that includes distance between two points.

| Point1Name | Point2Name | Distance |
+------------+------------+----------+
|    P1      |    P2      |  ZZZZZ   |
+------------+------------+----------+
....

To be able to calcualte the distance between two points, I enabled dynamic extension loading and used extension-functions module for arithmetic calculations. However, I am not quite sure if it is possible to create the output table with any sort of SQL tricks?

I need this functionelity in a C++ program, so in the worst case I will try to do it in the C++ way rather than using an SQL statement. This ,however, will require me to use sqlite3_exec() and define my callback function, and most probably I will end up running another sqlite3_exec() within the first callback funstion to get the desired output.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire