bool SQLiteDatabaseConnection::saveNode(const RoutingNode &node)
{
    int rc;
    if(_saveNodeStatement == NULL)
    {
        rc = sqlite3_prepare_v2(_db, "INSERT INTO NODES VALUES(@ID, @LAT, @LON, @BUCKETID);", -1, &_saveNodeStatement, NULL);
        if (rc != SQLITE_OK)
        {	
            std::cerr << "Failed to create saveNodeStatement." << " Resultcode: " << rc << std::endl;
            return false;
        }
    }

    // Parameter an das Statement binden
    sqlite3_bind_int64(_saveNodeStatement, 1, node.getID());
    sqlite3_bind_double(_saveNodeStatement, 2, node.getLat());
    sqlite3_bind_double(_saveNodeStatement, 3, node.getLon());
    sqlite3_bind_int64(_saveNodeStatement, 4, spc->getBucketID(node.getLat(), node.getLon()));

    // Statement ausfuehren
    rc = sqlite3_step(_saveNodeStatement);
    
    if (rc != SQLITE_DONE)
    {	
        std::cerr << "Failed to execute saveNodeStatement." << " Resultcode: " << rc << std::endl;
        return false;
    }


    rc = sqlite3_reset(_saveNodeStatement);
    if(rc != SQLITE_OK)
    {
        std::cerr << "Failed to reset saveNodeStatement." << " Resultcode: " << rc << std::endl;
    }
    return true;
}
inline void
RouteProcessor::copySubroutesToOrigin(SubRouteList* subList,
                                      Head* origin,
                                      RoutingMap* routingMap)
{
   // Add all origins from subList
   if (subList->getNbrSubRoutes() == 0) {
      mc2dbg << "subList->getNbrSubRoutes(1) == 0" << endl;
   }

   for (uint32 i = 0; i < subList->getNbrSubRoutes(); i++) {
      RMSubRoute* sub = subList->getSubRoute(i);
      for (uint32 j = 0; j < sub->getNbrConnections(); j++) {
         
         uint32 mapID;
         uint32 nodeID;
         uint32 cost;
         uint32 estimatedCost;
         uint16 offset;
         int32 lat,lon;
         uint32 costASum;
         uint32 costBSum;
         uint32 costCSum;

         sub->getExternal(j, mapID, nodeID, cost, estimatedCost,
                          lat, lon, costASum, costBSum, costCSum);

         mc2dbg8 << "RP: copySubRoutesToOrigin: From packet costs "
                 << costASum << ','
                 << costBSum << ','
                 << costCSum << endl;

         
         if (routingMap->getMapID() == mapID) {
            RoutingNode* routingNode =
               routingMap->getNodeFromTrueNodeNumber(nodeID);
            if ( routingNode != NULL ) {
               // XXX Check this
               if (IS_NODE0(nodeID)) {
                  offset = 0;
               }
               else {
                  offset = 0; // Should always be zero
               }

               mc2dbg8 << "[RP] - new OrigDestNode with lat = "
                       << routingNode->getLat() << " and lon = "
                       << routingNode->getLong() << endl;
               mc2dbg8 << "[RP] - server thinks         lat = "
                       << lat << " and lon = " << lon << endl;

               
               
               OrigDestNode* node 
                  = routingMap->newOrigDestNode(routingNode->getIndex(),
                                                mapID,
                                                offset,
                                                routingNode->getLat(),
                                                routingNode->getLong(),
                                                cost,
                                                estimatedCost,
                                                costASum,
                                                costBSum,
                                                costCSum);
               node->setItemID(nodeID); 
               node->into(origin);
            } else {
               mc2log << error
                      << "RP: Strange node " << hex
                      << nodeID << dec << " not fould in map "
                      << mapID << endl;
            }
         }
      }
   }
} // copySubRoutesToOrigin