route_query_nodes_database.cc 1.11 KB
Newer Older
Jean-Benoist Leger's avatar
Jean-Benoist Leger committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#include "nodes_db.h"
#include <iostream>

int main(int argc, char** argv)
{
    if(argc<2)
    {
        fprintf(stderr,"Usage: %s routes_db_path\nPut node id on stdin\n",argv[0]);
        abort();
    }

    // nodes_db (read)
    char zfilename[RV_ZCHAR_LENGTH];
    snprintf(zfilename,RV_ZCHAR_LENGTH,"%s/%s",argv[1],RV_NODES_DB_RELATIVE_PATH);
    nodes_db_t nodes_db(zfilename);

    while(!std::cin.eof())
    {
        nid_t nid;
        std::cin >> nid;
        if(std::cin.eof())
            break;

        node_info_t ni;
        
        nodes_db.get_node(nid,&ni);
        printf("Node (%lu):\n",nid);
        printf("    -> lon: %f\n", ni.fixed->lon);
        printf("    -> lat: %f\n", ni.fixed->lat);
        printf("    -> ele: %f\n", ni.fixed->elevation);
        printf("    -> neighbors: %u\n", ni.fixed->neighbors_number);

        for(unsigned int i=0; i<ni.fixed->neighbors_number; i++)
        {
            printf("        -> f:%lu t:%lu wk:%i\n",
                    ni.neighbors[i].from,
                    ni.neighbors[i].to,
                    ni.neighbors[i].way_kind);
        }
    }

    return(0);
}