MCPcopy Create free account
hub / github.com/Kitware/VTK / insertIntoHierarchy

Function insertIntoHierarchy

ThirdParty/libproj/vtklibproj/src/grids.cpp:1127–1180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1125
1126template <class GridType, class GenericGridType>
1127static void
1128insertIntoHierarchy(PJ_CONTEXT *ctx, std::unique_ptr<GridType> &&grid,
1129 const std::string &gridName, const std::string &parentName,
1130 std::vector<std::unique_ptr<GenericGridType>> &topGrids,
1131 std::map<std::string, GridType *> &mapGrids) {
1132 const auto &extent = grid->extentAndRes();
1133
1134 // If we have one or both of grid_name and parent_grid_name, try to use
1135 // the names to recreate the hierarchy
1136 if (!gridName.empty()) {
1137 if (mapGrids.find(gridName) != mapGrids.end()) {
1138 pj_log(ctx, PJ_LOG_DEBUG, "Several grids called %s found!",
1139 gridName.c_str());
1140 }
1141 mapGrids[gridName] = grid.get();
1142 }
1143
1144 if (!parentName.empty()) {
1145 auto iter = mapGrids.find(parentName);
1146 if (iter == mapGrids.end()) {
1147 pj_log(ctx, PJ_LOG_DEBUG,
1148 "Grid %s refers to non-existing parent %s. "
1149 "Using bounding-box method.",
1150 gridName.c_str(), parentName.c_str());
1151 } else {
1152 if (iter->second->extentAndRes().contains(extent)) {
1153 iter->second->m_children.emplace_back(std::move(grid));
1154 return;
1155 } else {
1156 pj_log(ctx, PJ_LOG_DEBUG,
1157 "Grid %s refers to parent %s, but its extent is "
1158 "not included in it. Using bounding-box method.",
1159 gridName.c_str(), parentName.c_str());
1160 }
1161 }
1162 } else if (!gridName.empty()) {
1163 topGrids.emplace_back(std::move(grid));
1164 return;
1165 }
1166
1167 // Fallback to analyzing spatial extents
1168 for (const auto &candidateParent : topGrids) {
1169 const auto &candidateParentExtent = candidateParent->extentAndRes();
1170 if (candidateParentExtent.contains(extent)) {
1171 static_cast<GridType *>(candidateParent.get())
1172 ->insertGrid(ctx, std::move(grid));
1173 return;
1174 } else if (candidateParentExtent.intersects(extent)) {
1175 pj_log(ctx, PJ_LOG_DEBUG, "Partially intersecting grids found!");
1176 }
1177 }
1178
1179 topGrids.emplace_back(std::move(grid));
1180}
1181
1182#ifdef TIFF_ENABLED
1183// ---------------------------------------------------------------------------

Callers 1

openMethod · 0.85

Calls 10

pj_logFunction · 0.85
insertGridMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
getMethod · 0.45
containsMethod · 0.45
emplace_backMethod · 0.45
intersectsMethod · 0.45

Tested by

no test coverage detected