| 666 | } |
| 667 | |
| 668 | void GridMap::convertToDefaultStartIndex() { |
| 669 | if (isDefaultStartIndex()) return; |
| 670 | |
| 671 | std::vector<BufferRegion> bufferRegions; |
| 672 | if (!getBufferRegionsForSubmap(bufferRegions, startIndex_, size_, size_, startIndex_)) { |
| 673 | throw std::out_of_range("Cannot access submap of this size."); |
| 674 | } |
| 675 | |
| 676 | for (auto& data : data_) { |
| 677 | auto tempData(data.second); |
| 678 | for (const auto& bufferRegion : bufferRegions) { |
| 679 | Index index = bufferRegion.getStartIndex(); |
| 680 | Size size = bufferRegion.getSize(); |
| 681 | |
| 682 | if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::TopLeft) { |
| 683 | tempData.topLeftCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1)); |
| 684 | } else if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::TopRight) { |
| 685 | tempData.topRightCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1)); |
| 686 | } else if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::BottomLeft) { |
| 687 | tempData.bottomLeftCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1)); |
| 688 | } else if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::BottomRight) { |
| 689 | tempData.bottomRightCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1)); |
| 690 | } |
| 691 | } |
| 692 | data.second = tempData; |
| 693 | } |
| 694 | |
| 695 | startIndex_.setZero(); |
| 696 | } |
| 697 | |
| 698 | Position GridMap::getClosestPositionInMap(const Position& position) const { |
| 699 | if (getSize().x() < 1u || getSize().y() < 1u) { |
no test coverage detected