Esempio n. 1
0
void justine::robocar::Traffic::toGPS ( osmium::unsigned_object_id_type from,
                                        osmium::unsigned_object_id_type to,
                                        osmium::unsigned_object_id_type step, double *lo, double *la ) const
{

  shm_map_Type::iterator iter1=shm_map->find ( from );
  double lon1 {iter1->second.lon/10000000.0}, lat1 {iter1->second.lat/10000000.0};

  shm_map_Type::iterator iter2=shm_map->find ( alist ( from, to ) );
  double lon2 {iter2->second.lon/10000000.0}, lat2 {iter2->second.lat/10000000.0};

  osmium::unsigned_object_id_type maxstep = palist ( from, to );

  if ( maxstep == 0 )
    {
      maxstep = 1;
    }

  lat1 += step * ( ( lat2 - lat1 ) / maxstep );
  lon1 += step * ( ( lon2 - lon1 ) / maxstep );

  *lo = lon1;
  *la = lat1;

}
  /**
   * @brief This function create the BGL graph.
   * @return he pointer of the created BGL graph.
   *
   */
  NodeRefGraph* bgl_graph ( void )
  {

    NodeRefGraph* nr_graph = new NodeRefGraph();

    int count {0};

    for ( justine::robocar::shm_map_Type::iterator iter=shm_map->begin();
          iter!=shm_map->end(); ++iter )
      {

        osmium::unsigned_object_id_type u = iter->first;

        for ( justine::robocar::uint_vector::iterator noderefi = iter->second.m_alist.begin();
              noderefi!=iter->second.m_alist.end();
              ++noderefi )
          {

            NodeRefGraph::vertex_descriptor f;
            std::map<osmium::unsigned_object_id_type, NRGVertex>::iterator it = nr2v.find ( u );

            if ( it == nr2v.end() )
              {

                f = boost::add_vertex ( u, *nr_graph );
                nr2v[u] = f;

                ++count;

              }
            else
              {

                f = it->second;

              }

            NodeRefGraph::vertex_descriptor t;
            it = nr2v.find ( *noderefi );
            if ( it == nr2v.end() )
              {

                t = boost::add_vertex ( *noderefi, *nr_graph );
                nr2v[*noderefi] = t;

                ++count;

              }
            else
              {

                t = it->second;

              }

            int to = std::distance ( iter->second.m_alist.begin(), noderefi );

            boost::add_edge ( f, t, palist ( iter->first, to ), *nr_graph );

          }

      }

#ifdef DEBUG
    std::cout << "# vertices count: " << count << std::endl;;
    std::cout << "# BGF edges: " << boost::num_edges ( *nr_graph ) << std::endl;;
    std::cout << "# BGF vertices: " << boost::num_vertices ( *nr_graph ) << std::endl;;
#endif

    return nr_graph;
  }