[Positioning] Add Stock::in_which_area_is()
This commit is contained in:
parent
9f5305b496
commit
a951717433
|
@ -1,6 +1,7 @@
|
|||
#include "stock.hh"
|
||||
#include "configuration.hh"
|
||||
#include "posexcept.hh"
|
||||
#include "area.hh"
|
||||
|
||||
using namespace std ;
|
||||
using std::tr1::unordered_map ;
|
||||
|
@ -80,6 +81,26 @@ const Building& Stock::get_building(const string &name)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @returns A pointer to the first Area in which \em point was found.
|
||||
* @returns NULL if \em point does not belong to any Area.
|
||||
*/
|
||||
const Area* Stock::in_which_area_is(const Point3D point)
|
||||
{
|
||||
for (unordered_map<string, Building>::const_iterator
|
||||
b = buildings.begin() ; b != buildings.end() ; ++b)
|
||||
{
|
||||
const unordered_map<string, Area*> &areas = b->second.get_areas() ;
|
||||
for (unordered_map<string, Area*>::const_iterator
|
||||
a = areas.begin() ; a != areas.end() ; ++a)
|
||||
if (a->second->contains_point(point))
|
||||
return a->second ;
|
||||
}
|
||||
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* *** Waypoint operations *** */
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
static const Building& get_building(const std::string &name) ;
|
||||
/// Searches for a Building and creates it if it does not exist
|
||||
static const Building& find_create_building(const std::string &name) ;
|
||||
/// Searches the Area in which \em point is
|
||||
static const Area* in_which_area_is(const Point3D point) ;
|
||||
//@}
|
||||
|
||||
/** @name Waypoint operations */
|
||||
|
|
Loading…
Reference in New Issue