diff --git a/GeoLib/GEOObjects.cpp b/GeoLib/GEOObjects.cpp index a3886ed57db8ac6d3bbd7ff129dffed618736177..dfc2b96aaaf67df2f3be877b278a5a03608a6585 100644 --- a/GeoLib/GEOObjects.cpp +++ b/GeoLib/GEOObjects.cpp @@ -409,25 +409,27 @@ bool GEOObjects::mergePoints(std::vector<std::string> const & geo_names, if (pnt_vec == nullptr) continue; const std::vector<GeoLib::Point*>* pnts(pnt_vec->getVector()); - if (pnts) { - std::size_t n_pnts(0); - // do not consider stations - if (!dynamic_cast<GeoLib::Station*>((*pnts)[0])) { - std::string tmp_name; - n_pnts = pnts->size(); - for (std::size_t k(0); k < n_pnts; ++k) { - merged_points->push_back(new GeoLib::Point(*(*pnts)[k])); - if (pnt_vec->getNameOfElementByID(k, tmp_name)) { - merged_pnt_names->insert( - std::make_pair(tmp_name, pnt_offsets[j] + k)); - } - } - } - if (n_geo_names - 1 > j) { - pnt_offsets[j + 1] = n_pnts + pnt_offsets[j]; + if (pnts == nullptr) { + return false; + } + + // do not consider stations + if (dynamic_cast<GeoLib::Station*>((*pnts)[0])) { + continue; + } + + std::string tmp_name; + std::size_t const n_pnts(pnts->size()); + for (std::size_t k(0); k < n_pnts; ++k) { + merged_points->push_back(new GeoLib::Point(*(*pnts)[k])); + if (pnt_vec->getNameOfElementByID(k, tmp_name)) { + merged_pnt_names->insert( + std::make_pair(tmp_name, pnt_offsets[j] + k)); } - } else - return false; //if no points for a given geometry are found, something is fundamentally wrong + } + if (n_geo_names - 1 > j) { + pnt_offsets[j + 1] = n_pnts + pnt_offsets[j]; + } } addPointVec (merged_points, merged_geo_name, merged_pnt_names, 1e-6);