bool DBThread::GetClosestRoutableNode(double lat, double lon, const osmscout::Vehicle& vehicle, double radius, osmscout::ObjectFileRef& object, size_t& nodeIndex) { QMutexLocker locker(&mutex); if (!AssureRouter(vehicle)) { return false; } object.Invalidate(); return router->GetClosestRoutableNode(lat, lon, vehicle, radius, object, nodeIndex); }
bool DBThread::GetClosestRoutableNode(const osmscout::ObjectFileRef& refObject, const osmscout::Vehicle& vehicle, double radius, osmscout::ObjectFileRef& object, size_t& nodeIndex) { QMutexLocker locker(&mutex); object.Invalidate(); if (refObject.GetType()==osmscout::refNode) { osmscout::NodeRef node; if (!database->GetNodeByOffset(refObject.GetFileOffset(), node)) { return false; } return router->GetClosestRoutableNode(node->GetLat(), node->GetLon(), vehicle, radius, object, nodeIndex); } else if (refObject.GetType()==osmscout::refArea) { osmscout::AreaRef area; if (!database->GetAreaByOffset(refObject.GetFileOffset(), area)) { return false; } double lat; double lon; area->GetCenter(lat,lon); return router->GetClosestRoutableNode(lat, lon, vehicle, radius, object, nodeIndex); } else if (refObject.GetType()==osmscout::refWay) { osmscout::WayRef way; if (!database->GetWayByOffset(refObject.GetFileOffset(), way)) { return false; } return router->GetClosestRoutableNode(way->nodes[0].GetLat(), way->nodes[0].GetLon(), vehicle, radius, object, nodeIndex); } else { return true; } }
bool DBThread::GetClosestRoutableNode(const osmscout::ObjectFileRef& refObject, const osmscout::Vehicle& vehicle, double radius, osmscout::ObjectFileRef& object, size_t& nodeIndex) { QMutexLocker locker(&mutex); if (!AssureRouter(vehicle)) { return false; } object.Invalidate(); if (refObject.GetType()==osmscout::refNode) { osmscout::NodeRef node; if (!database->GetNodeByOffset(refObject.GetFileOffset(), node)) { std::cout<<node->GetCoords().GetLat()<<std::endl; std::cout<<node->GetCoords().GetLon()<<std::endl; return false; } return router->GetClosestRoutableNode(node->GetCoords().GetLat(), node->GetCoords().GetLon(), vehicle, radius, object, nodeIndex); } else if (refObject.GetType()==osmscout::refArea) { osmscout::AreaRef area; if (!database->GetAreaByOffset(refObject.GetFileOffset(), area)) { return false; } osmscout::GeoCoord center; area->GetCenter(center); return router->GetClosestRoutableNode(center.GetLat(), center.GetLon(), vehicle, radius, object, nodeIndex); } else if (refObject.GetType()==osmscout::refWay) { osmscout::WayRef way; if (!database->GetWayByOffset(refObject.GetFileOffset(), way)) { return false; } return router->GetClosestRoutableNode(way->nodes[0].GetLat(), way->nodes[0].GetLon(), vehicle, radius, object, nodeIndex); } else { return true; } }