MCPcopy Create free account
hub / github.com/ANYbotics/grid_map / addDataFrom

Method addDataFrom

grid_map_core/src/GridMap.cpp:519–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519bool GridMap::addDataFrom(const GridMap& other, bool extendMap, bool overwriteData, bool copyAllLayers, std::vector<std::string> layers) {
520 // Set the layers to copy.
521 if (copyAllLayers) layers = other.getLayers();
522
523 // Resize map.
524 if (extendMap) extendToInclude(other);
525
526 // Check if all layers to copy exist and add missing layers.
527 for (const auto& layer : layers) {
528 if (std::find(layers_.begin(), layers_.end(), layer) == layers_.end()) {
529 add(layer);
530 }
531 }
532 // Copy data.
533 for (GridMapIterator iterator(*this); !iterator.isPastEnd(); ++iterator) {
534 if (isValid(*iterator) && !overwriteData) continue;
535 Position position;
536 getPosition(*iterator, position);
537 Index index;
538 if (!other.isInside(position)) continue;
539 other.getIndex(position, index);
540 for (const auto& layer : layers) {
541 if (!other.isValid(index, layer)) continue;
542 at(layer, *iterator) = other.at(layer, index);
543 }
544 }
545
546 return true;
547}
548
549bool GridMap::extendToInclude(const GridMap& other) {
550 // Get dimension of maps.

Callers 1

TESTFunction · 0.80

Calls 6

endMethod · 0.80
getIndexMethod · 0.80
isValidMethod · 0.80
atMethod · 0.80
isPastEndMethod · 0.45
isInsideMethod · 0.45

Tested by 1

TESTFunction · 0.64