route_db.cc 828 Bytes
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
#include "route_db.h"

route_db_t::route_db_t(const char* db_location)
{
    char zfilename[RV_ZCHAR_LENGTH];
    
    snprintf(zfilename,RV_ZCHAR_LENGTH,"%s/%s",db_location,RV_NODES_DB_RELATIVE_PATH);
    nodes_db = new nodes_db_t(zfilename);

    snprintf(zfilename,RV_ZCHAR_LENGTH,"%s/%s",db_location,RV_LOOKUP_DB_RELATIVE_PATH);
    lookup_db = new lookup_db_t(zfilename);
}

route_db_t::~route_db_t()
{
    delete nodes_db;
    delete lookup_db;
}

int route_db_t::lookup(
        std::list< std::pair<double,double> > & geos,
        std::list<nid_t> & nids)
{
    return(rv_lookup(*nodes_db, *lookup_db, geos, nids));
}

node_info_t* route_db_t::get_node(
        nid_t & nid)
{
    node_info_t* pni = & known_nodes[nid];

    if( ! pni->fixed)
    {
        nodes_db->get_node(nid, pni);
    }

    return(pni);
}