MCPcopy Create free account
hub / github.com/OSGeo/gdal / SetNode

Method SetNode

ogr/ogrspatialreference.cpp:2528–2591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2526 */
2527
2528OGRErr OGRSpatialReference::SetNode(const char *pszNodePath,
2529 const char *pszNewNodeValue)
2530
2531{
2532 TAKE_OPTIONAL_LOCK();
2533
2534 char **papszPathTokens =
2535 CSLTokenizeStringComplex(pszNodePath, "|", TRUE, FALSE);
2536
2537 if (CSLCount(papszPathTokens) < 1)
2538 {
2539 CSLDestroy(papszPathTokens);
2540 return OGRERR_FAILURE;
2541 }
2542
2543 if (GetRoot() == nullptr ||
2544 !EQUAL(papszPathTokens[0], GetRoot()->GetValue()))
2545 {
2546 if (EQUAL(papszPathTokens[0], "PROJCS") &&
2547 CSLCount(papszPathTokens) == 1)
2548 {
2549 CSLDestroy(papszPathTokens);
2550 return SetProjCS(pszNewNodeValue);
2551 }
2552 else
2553 {
2554 SetRoot(new OGR_SRSNode(papszPathTokens[0]));
2555 }
2556 }
2557
2558 OGR_SRSNode *poNode = GetRoot();
2559 for (int i = 1; papszPathTokens[i] != nullptr; i++)
2560 {
2561 int j = 0; // Used after for.
2562
2563 for (; j < poNode->GetChildCount(); j++)
2564 {
2565 if (EQUAL(poNode->GetChild(j)->GetValue(), papszPathTokens[i]))
2566 {
2567 poNode = poNode->GetChild(j);
2568 j = -1;
2569 break;
2570 }
2571 }
2572
2573 if (j != -1)
2574 {
2575 OGR_SRSNode *poNewNode = new OGR_SRSNode(papszPathTokens[i]);
2576 poNode->AddChild(poNewNode);
2577 poNode = poNewNode;
2578 }
2579 }
2580
2581 CSLDestroy(papszPathTokens);
2582
2583 if (pszNewNodeValue != nullptr)
2584 {
2585 if (poNode->GetChildCount() > 0)

Callers 8

gt_wkt_srs.cppFile · 0.80
SetCitationToSRSFunction · 0.80
LoadGeoreferencingMethod · 0.80
GetOGISDefnMethod · 0.80
LoadFromFileMethod · 0.80

Calls 10

CSLTokenizeStringComplexFunction · 0.85
CSLCountFunction · 0.85
absFunction · 0.85
OGRsnPrintDoubleFunction · 0.85
AddChildMethod · 0.80
GetRootFunction · 0.50
EQUALFunction · 0.50
GetValueMethod · 0.45
GetChildMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected