QString GetObjectTypLabel(const osmscout::ObjectFileRef& object)
{
    if (object.GetType()==osmscout::RefType::refNode) {
      osmscout::NodeRef node;

      if (DBThread::GetInstance()->GetNodeByOffset(object.GetFileOffset(),
                                                   node)) {
        return QString::fromUtf8(node->GetType()->GetName().c_str());
      }
    }
    else if (object.GetType()==osmscout::RefType::refArea) {
      osmscout::AreaRef area;

      if (DBThread::GetInstance()->GetAreaByOffset(object.GetFileOffset(),
                                                   area)) {
        return QString::fromUtf8(area->GetType()->GetName().c_str());
      }
    }
    else if (object.GetType()==osmscout::RefType::refWay) {
      osmscout::WayRef way;

      if (DBThread::GetInstance()->GetWayByOffset(object.GetFileOffset(),
                                                  way)) {
        return QString::fromUtf8(way->GetType()->GetName().c_str());
      }
    }

    return "";
}
Esempio n. 2
0
  void ShowReference(const osmscout::ObjectFileRef& reference,
                     const osmscout::Magnification& magnification)
  {
    std::cout << "Showing " << reference.GetTypeName() << " at file offset "<< reference.GetFileOffset() << "..." << std::endl;

    if (reference.GetType()==osmscout::refNode) {
      osmscout::NodeRef node;

      if (database->GetNodeByOffset(reference.GetFileOffset(),node)) {
        lon=node->GetLon();
        lat=node->GetLat();
        this->magnification=magnification;

        RequestNewMap();
      }
    }
    else if (reference.GetType()==osmscout::refArea) {
      osmscout::AreaRef area;

      if (database->GetAreaByOffset(reference.GetFileOffset(),area)) {
        if (area->GetCenter(lat,lon)) {
          this->magnification=magnification;

          RequestNewMap();
        }
      }
    }
    else if (reference.GetType()==osmscout::refWay) {
      osmscout::WayRef way;

      if (database->GetWayByOffset(reference.GetFileOffset(),way)) {
        if (way->GetCenter(lat,lon)) {
          this->magnification=magnification;

          RequestNewMap();
        }
      }
    }
    else {
      assert(false);
    }
  }
Esempio n. 3
0
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;
  }
}
Esempio n. 4
0
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;
  }
}