44 m_to(route->getEndNode()),
45 m_from(route->getStartNode()),
46 m_startCache(m_from.getLayer()->getCellCache()),
47 m_endCache(m_to.getLayer()->getCellCache()),
49 m_startZone(m_startCache->getCell(m_from.getLayerCoordinates())->getZone()),
50 m_endZone(m_endCache->getCell(m_to.getLayerCoordinates())->getZone()),
51 m_startCoordInt(m_startCache->convertCoordToInt(m_from.getLayerCoordinates())),
52 m_lastStartCoordInt(m_startCoordInt),
53 m_destCoordInt(m_endCache->convertCoordToInt(m_to.getLayerCoordinates())),
54 m_lastDestCoordInt(-1),
61 const std::vector<Cell*>& neighbors = endcell->
getNeighbors();
62 for (std::vector<Cell*>::const_iterator it = neighbors.begin();
63 it != neighbors.end(); ++it) {
64 Zone* tmpzone = (*it)->getZone();
84 const std::vector<Cell*>& neighbors = startCell->
getNeighbors();
85 for (std::vector<Cell*>::const_iterator it = neighbors.begin();
86 it != neighbors.end(); ++it) {
87 Zone* tmpzone = (*it)->getZone();
119 m_spt.resize(max_index, -1);
120 m_sf.resize(max_index, -1);
184 bool zLimited = maxZ != -1;
187 const std::vector<Cell*>& adjacents = nextCell->
getNeighbors();
188 if (adjacents.empty()) {
191 for (std::vector<Cell*>::const_iterator i = adjacents.begin(); i != adjacents.end(); ++i) {
198 int32_t adjacentInt = (*i)->getCellId();
199 if (
m_sf[adjacentInt] != -1 &&
m_spt[adjacentInt] != -1) {
202 if (zLimited &&
ABS(cellZ-(*i)->getLayerCoordinates().z) > maxZ) {
205 bool blocker = (*i)->getCellType() > blockerThreshold;
222 Location adjacentLoc((*i)->getLayer());
227 std::vector<ModelCoordinate>::iterator coord_it = coords.begin();
228 for (; coord_it != coords.end(); ++coord_it) {
240 bool sameAreas =
false;
242 std::list<std::string>::const_iterator area_it = areas.begin();
243 for (; area_it != areas.end(); ++area_it) {
262 }
else if (limitedArea) {
264 bool sameAreas =
false;
266 std::list<std::string>::const_iterator area_it = areas.begin();
267 for (; area_it != areas.end(); ++area_it) {
285 if (
m_sf[adjacentInt] == -1) {
289 }
else if (gCost <
m_gCosts[adjacentInt] &&
m_spt[adjacentInt] == -1) {
304 path.push_back(newnode);
305 while(current != end) {
306 if (
m_spt[current] < 0 ) {
312 current =
m_spt[current];
314 path.push_front(newnode);
331 path.push_back(newnode);
332 while(current != end) {
333 if (
m_spt[current] < 0 ) {
339 current =
m_spt[current];
341 path.push_front(newnode);
349 if (!cells.empty()) {
353 for (std::vector<Cell*>::iterator it = cells.begin(); it != cells.end(); ++it) {
372 Location loc2((*it)->getTransition()->m_layer);
375 double temp_distance = temp.getLayerDistanceTo(
m_from) + loc2.getLayerDistanceTo(
m_to);
377 if (current_distance > temp_distance) {
390 std::vector<Cell*> endTransCells;
392 std::vector<Cell*>::iterator tcell_it = tmpTransCells.begin();
393 for (; tcell_it != tmpTransCells.end(); ++tcell_it) {
394 Zone* zone = (*tcell_it)->getZone();
396 endTransCells.push_back(*tcell_it);
399 if (endTransCells.empty()) {
403 std::vector<Cell*> startTransCells;
405 tcell_it = tmpTransCells.begin();
406 for (; tcell_it != tmpTransCells.end(); ++tcell_it) {
407 Zone* zone = (*tcell_it)->getZone();
409 startTransCells.push_back(*tcell_it);
412 if (startTransCells.empty()) {
417 std::vector<Zone*> zones;
419 std::list<Layer*>::const_iterator lay_it = allLayers.begin();
420 for (; lay_it != allLayers.end(); ++lay_it) {
421 CellCache* cache = (*lay_it)->getCellCache();
423 const std::vector<Zone*>& tmp_zones = cache->
getZones();
424 zones.insert(zones.end(), tmp_zones.begin(), tmp_zones.end());
429 std::map<Zone*, int32_t> zoneDistanceMap;
430 std::map<int32_t, Zone*> distanceZoneMap;
431 for (std::vector<Zone*>::iterator zit = zones.begin(); zit != zones.end(); ++zit) {
434 zoneDistanceMap.insert(std::pair<Zone*, int32_t>(*zit, distance));
435 distanceZoneMap.insert(std::pair<int32_t, Zone*>(distance, *zit));
438 int32_t startZone = zoneDistanceMap.find(
m_startZone)->second;
440 int32_t targetZone = zoneDistanceMap.find(
m_endZone)->second;
446 int32_t max_index = zones.size();
448 std::vector<int32_t> spt(max_index, -1);
450 std::vector<int32_t> sf(max_index, -1);
452 std::vector<double> costs(max_index, 0.0);
455 if (sortedfrontier.
empty()) {
460 int32_t
next = topvalue.first;
463 if (targetZone == next) {
467 Zone* nextZone = distanceZoneMap.find(next)->second;
470 if (transCells.empty()) {
473 std::vector<Cell*>::iterator cell_it = transCells.begin();
474 for (; cell_it != transCells.end(); ++cell_it) {
482 int32_t nextInt = zoneDistanceMap.find(transCelle->
getZone())->second;
483 if (nextInt == next && nextInt != targetZone) {
487 double cost = costs[
next] +
static_cast<double>(
ABS(nextInt-startZone));
488 if (sf[nextInt] == -1) {
490 costs[nextInt] = cost;
492 }
else if (cost < costs[nextInt] && spt[nextInt] == -1) {
494 costs[nextInt] = cost;
502 int32_t current = targetZone;
503 int32_t end = startZone;
505 std::list<Zone*> betweenZones;
506 Zone* tempZone = distanceZoneMap.find(current)->second;
507 betweenZones.push_back(tempZone);
508 while(current != end) {
509 if (spt[current] < 0 ) {
512 current = spt[current];
513 tempZone = distanceZoneMap.find(current)->second;
514 betweenZones.push_front(tempZone);
518 for (std::list<Zone*>::iterator lit = betweenZones.begin(); lit != betweenZones.end(); ++lit) {
520 if (lit == betweenZones.end()) {
523 Zone* nextZone = *lit;
525 Zone* currentZone = *lit;
527 if (tempCells.empty()) {
531 Cell* transCell = NULL;
532 double nextCost = 0.0;
534 for (std::vector<Cell*>::iterator cit = tempCells.begin(); cit != tempCells.end(); ++cit) {
535 Cell* nextCell = *cit;
539 if (nextZone != transTargetCell->
getZone()) {
543 Location tmpLoc((*cit)->getLayer());
546 if (!transCell || locCost < nextCost) {
void createSearchFrontier(int32_t startInt, CellCache *cache)
Creates or resets the SearchFrontier.
int32_t getSearchStatus() const
A small function which returns the current status of the search.
CellCache * m_startCache
A pointer to the start CellCache.
virtual std::vector< ModelCoordinate > toMultiCoordinates(const ModelCoordinate &position, const std::vector< ModelCoordinate > &orig, bool reverse=false)=0
Returns point vector with coordinates for a multi object.
int32_t getAngleBetween(const Location &loc1, const Location &loc2)
Gets angle of vector defined by given locations.
void setLayerCoordinates(const ModelCoordinate &coordinates)
Sets "cell precise" layer coordinates to this location.
Layer * m_layer
target layer
void setSearchStatus(const SearchStatus status)
Sets the current status of the search.
int32_t getMaxIndex() const
Returns the number of cells on this CellCache.
std::list< Location > Path
A path is a list with locations. Each location holds the coordinate for one cell. ...
int32_t getZStepRange()
Returns z-step range from object.
bool empty(void) const
Determines whether the queue is currently empty.
Layer * getLayer() const
Gets the layer where this location is pointing to.
int32_t m_lastStartCoordInt
The last used start coordinate as an int32_t.
uint32_t next(octet_iterator &it, octet_iterator end)
Layer * getLayer()
Returns the current layer.
bool isCellInArea(const std::string &id, Cell *cell)
Returns true if cell is part of the area, otherwise false.
void setRouteStatus(RouteStatusInfo status)
Sets route status.
Layer * getLayer()
Returns layer.
void setLayer(Layer *layer)
Sets layer where this location is pointing to.
void calcPathStep()
Calculates path parts per layer.
A CellCache is an abstract depiction of one or a few layers and contains additional information...
bool m_specialCost
Indicates if the search should use special costs.
Location m_to
A location object representing where the search started.
CellCache * getCellCache()
Returns the CellCache of this layer.
const std::list< Layer * > & getLayers() const
Get the layers on this map.
MultiLayerSearch(Route *route, const int32_t sessionId)
Constructor.
int32_t m_destCoordInt
The destination coordinate as an int32_t.
~MultiLayerSearch()
Destructor.
void pushElement(const value_type &element)
Pushes a new element onto the queue.
std::vector< int32_t > m_sf
The search frontier.
void searchBetweenTargetsNeighbor()
Fetch targets from neighbor layers.
const std::vector< Zone * > & getZones()
Returns zones of this CellCache.
const std::list< std::string > getLimitedAreas()
CellCache * m_endCache
A pointer to the end CellCache.
double getAdjacentCost(const ModelCoordinate &adjacent, const ModelCoordinate &next)
Returns cost for movement between these two adjacent coordinates.
void setPath(const Path &path)
Sets the path for the route.
std::vector< int32_t > m_spt
The shortest path tree.
Simple class to hold the data for transistions.
virtual double getHeuristicCost(const ModelCoordinate &curpos, const ModelCoordinate &target)=0
Returns distance const from curpos to target point.
double getLayerDistanceTo(const Location &location) const
Gets layer distance to another location.
Cell * getCell(const ModelCoordinate &mc)
Returns cell on this coordinate.
bool isZoneProtected()
Returns whether the zone on this cell is protected.
std::vector< Cell * > m_ignoredBlockers
Blockers from a multi cell object which should be ignored.
CellTypeInfo getCellType()
Returns blocker type.
std::vector< Cell * > getTransitionCells(Layer *layer=NULL)
Returns transistion cells of this CellCache.
void searchBetweenTargetsMap()
Fetch targets from map.
bool m_ignoreDynamicBlockers
Indicates if dynamic blockers should be ignored.
const ModelCoordinate getLayerCoordinates() const
Returns the layer coordinates of this cell.
const value_type getPriorityElement(void) const
Retrieves the element with the highest priority.
const std::vector< Cell * > & getNeighbors()
Returns the layer coordinates of this cell.
Path m_path
Path to which all steps are added.
ExactModelCoordinate & getExactLayerCoordinatesRef()
Gets reference to exact layer coordinates.
A basic cell on a CellCache.
ModelCoordinate convertIntToCoord(const int32_t cell) const
Convertes unique identifier to coordinate.
std::iterator_traits< octet_iterator >::difference_type distance(octet_iterator first, octet_iterator last)
void clear(void)
Removes all elements from the priority queue.
int32_t convertCoordToInt(const ModelCoordinate &coord) const
Convertes coordinate to unique identifier.
Zone * getZone()
Returns zone.
std::vector< double > m_gCosts
A table to hold the costs.
CellGrid * getCellGrid() const
Get the Cellgrid.
void popElement(void)
Pops the element with the highest priority from the queue.
RoutePatherSearch using A*.
int32_t m_next
The next coordinate to check out.
const std::string & getCostId()
Returns cost identifier which is used for pathfinding.
void updateSearch()
Updates the search.
bool changeElementPriority(const index_type &index, const priority_type &newPriority)
Changes the priority of an element.
std::vector< ModelCoordinate > getOccupiedCells(int32_t rotation)
Returns relative coordinates for multi cell object based on rotation.
PriorityQueue< int32_t, double > m_sortedFrontier
Priority queue to hold nodes on the sf in order.
Location m_from
A location object representing where the search ended.
std::list< Cell * > m_betweenTargets
List of targets that need to be solved to reach the real target.
ModelCoordinate getLayerCoordinates() const
Gets cell precision layer coordinates set to this location.
bool m_multicell
Indicates if the route is for a multi cell object.
Map * getMap() const
Get the map this layer is contained in.
int32_t m_lastDestCoordInt
The last used destination coordinate as an int32_t.
TransitionInfo * getTransition()
Returns the transition.
A pq which stores index-value pairs for elements.
CellCache * m_currentCache
A pointer to the currently used CellCache.
Route * m_route
Pointer to route.
std::vector< Cell * > getTransitionCells(Layer *layer=NULL)
Returns transistion cells of this zone.
A Zone is an abstract depiction of a CellCache or of a part of it.
ModelCoordinate m_mc
target coordinates
void calcPath()
Calculates final path.
bool m_foundLast
Indicates if last between target could be achieved.