Skip to content

Commit e5bfa10

Browse files
committed
FIX: insertPointFrom() should not try to add xyz again
1 parent 5f04628 commit e5bfa10

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

libs/maps/include/mrpt/maps/CPointsMap.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ class CPointsMap :
590590
/** Get list of all uint16_t channel names */
591591
virtual std::vector<std::string_view> getPointFieldNames_uint16() const { return {}; }
592592

593+
/** Get list of all float channel names, except x,y,z */
594+
std::vector<std::string_view> getPointFieldNames_float_except_xyz() const;
595+
593596
/** Read the value of a float channel for a given point.
594597
* Returns 0 if field does not exist.
595598
* \exception std::exception on index out of bounds or if field exists but
@@ -809,7 +812,7 @@ class CPointsMap :
809812
insertPointFast(xs[i], ys[i], zs[i]);
810813

811814
// Optional fields: only if they already exist on both maps:
812-
for (const auto& f : this->getPointFieldNames_float())
815+
for (const auto& f : this->getPointFieldNames_float_except_xyz())
813816
{
814817
insertPointField_float(f, source.getPointField_float(i, f));
815818
}

libs/maps/src/maps/CPointsMap.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,20 @@ void CPointsMap::loadFromVelodyneScan(
20372037
}
20382038
}
20392039

2040+
std::vector<std::string_view> CPointsMap::getPointFieldNames_float_except_xyz() const
2041+
{
2042+
const auto all = getPointFieldNames_float();
2043+
std::vector<std::string_view> result;
2044+
result.reserve(all.size());
2045+
2046+
for (auto name : all)
2047+
{
2048+
if (name != "x" && name != "y" && name != "z") result.push_back(name);
2049+
}
2050+
2051+
return result;
2052+
}
2053+
20402054
// =========== API of the NearestNeighborsCapable virtual interface ======
20412055
// See docs in base class
20422056
void CPointsMap::nn_prepare_for_2d_queries() const

0 commit comments

Comments
 (0)