Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hazzik committed Jun 27, 2024
1 parent 8165934 commit 5e68e5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions projects/GKCore/GDModel/GDMLocationRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using GDModel.Providers.GEDCOM;
using GKCore.Calendar;
using GKCore.Options;
Expand Down Expand Up @@ -207,6 +208,8 @@ public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnu
}
}

topBuffer = topBuffer.OrderByDescending(x => x.Date).ToList();

// search of intersections of location names and intersections of top levels/names
var q = new Queue<GDMLocationName>(fNames);
while (q.Count>0) {
Expand All @@ -223,7 +226,7 @@ public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnu
if (!interDate.IsEmpty()) {
string newName = (atdEnum == ATDEnumeration.fLtS) ? topName + ", " + nVal : nVal + ", " + topName;
result.Add(new GDMLocationName(newName, interDate));
var differences = GDMCustomDate.GetDifference(topDate, locName.Date.Value);
var differences = GDMCustomDate.GetDifference(interDate, locName.Date.Value);
foreach (var difference in differences) {
if (!difference.IsEmpty()) {
q.Enqueue(new GDMLocationName(nVal, difference));
Expand All @@ -236,12 +239,17 @@ public GDMList<GDMLocationName> GetFullNames(GDMTree tree, ATDEnumeration atdEnu
}

if (!wasJoin) {
result.Add(new GDMLocationName(nVal, locName.Date.Value));
result.Add(locName);
}
}
}

return result;
var gdmLocationNames = new GDMList<GDMLocationName>();
foreach (var name in result.OrderBy(x => x.Date)) {
gdmLocationNames.Add(name);
}

return gdmLocationNames;
}

public string GetNameByDate(GDMCustomDate date, ATDEnumeration atdEnum, bool full = false)
Expand Down
2 changes: 1 addition & 1 deletion projects/GKTests/GDModel/GDMLocationRecordTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ public void Test_Carbuna2()
ussr.AddLocName("СССР", "FROM 30 DEC 1922 TO 26 DEC 1991");

var moldova = tree.CreateLocation();
moldova.AddLocName("Молдавская ССР", "FROM 2 AUG 1940 TO 27 AUG 1991");
moldova.AddLocName("Молдова", "FROM 28 AUG 1991");
moldova.AddLocName("Молдавская ССР", "FROM 2 AUG 1940 TO 27 AUG 1991");
moldova.AddLocLink(ussr, "FROM 2 AUG 1940 TO 27 AUG 1991");

var carbuna = tree.CreateLocation();
Expand Down

0 comments on commit 5e68e5a

Please sign in to comment.