#7585 Multi Lateral Well Adjustments : Make sure lateral number is unique

This commit is contained in:
Magne Sjaastad committed 2021-04-19 11:16:36 +02:00
1 parent dd605f5445
commit a1d85f2ed8
1 file changed
+3 -12
@@ -174,27 +174,18 @@ QString RicNewWellPathLateralAtDepthFeature::updateNameOfParentAndFindNameOfSide
}
{
QString commonRoot = RiaTextStringTools::commonRoot( allNames );
QString trimmedCommonRoot = RiaTextStringTools::trimNonAlphaNumericCharacters( commonRoot );
// Remove side step prefix
trimmedCommonRoot.replace( " Y", "" );
QString commonRoot = RiaTextStringTools::commonRoot( allNames );
int maxYValue = 0;
for ( auto n : allNames )
{
auto suffix = n.replace( trimmedCommonRoot, "" );
auto suffix = n.replace( commonRoot, "" );
int candidate = suffix.toInt();
maxYValue = std::max( maxYValue, candidate );
}
if ( !trimmedCommonRoot.isEmpty() && trimmedCommonRoot.endsWith( "Y" ) )
{
trimmedCommonRoot = trimmedCommonRoot.left( trimmedCommonRoot.size() - 1 ).trimmed();
}
nameOfNewWell = QString( "%1 Y%2" ).arg( trimmedCommonRoot ).arg( maxYValue + 1 );
nameOfNewWell = QString( "%1%2" ).arg( commonRoot ).arg( maxYValue + 1 );
}
return nameOfNewWell;