diff --git a/projects/GKCore/GDModel/GDMLocationRecord.cs b/projects/GKCore/GDModel/GDMLocationRecord.cs
index 55acb64b2..701f84e2f 100644
--- a/projects/GKCore/GDModel/GDMLocationRecord.cs
+++ b/projects/GKCore/GDModel/GDMLocationRecord.cs
@@ -22,6 +22,7 @@
using System.Collections.Generic;
using GDModel.Providers.GEDCOM;
using GKCore.Calendar;
+using GKCore.Options;
using GKCore.Types;
namespace GDModel
@@ -99,6 +100,35 @@ public override void Assign(GDMTag source)
AssignList(otherLoc.fTopLevels, TopLevels);
}
+ ///
+ /// The MoveTo() merges records and their references, but does not change the text in the target.
+ ///
+ ///
+ public override void MoveTo(GDMRecord targetRecord)
+ {
+ GDMLocationRecord targetLoc = (targetRecord as GDMLocationRecord);
+ if (targetLoc == null)
+ throw new ArgumentException(@"Argument is null or wrong type", "targetRecord");
+
+ base.MoveTo(targetRecord);
+
+ if (targetLoc.Map.IsEmpty() && !fMap.IsEmpty()) {
+ targetLoc.Map.Assign(fMap);
+ }
+
+ while (fNames.Count > 0) {
+ GDMLocationName obj = fNames.Extract(0);
+ targetLoc.Names.Add(obj);
+ }
+ SortNames();
+
+ while (fTopLevels.Count > 0) {
+ GDMLocationLink obj = fTopLevels.Extract(0);
+ targetLoc.TopLevels.Add(obj);
+ }
+ SortTopLevels();
+ }
+
public override void Clear()
{
base.Clear();
@@ -133,16 +163,20 @@ public override void ReplaceXRefs(GDMXRefReplacer map)
public GDMList GetFullNames(GDMTree tree)
{
- var result = new GDMList();
+ GDMList result;
- if (fTopLevels.Count > 0) {
- var buffer = new List();
+ if (fTopLevels.Count == 0) {
+ result = fNames;
+ } else {
+ result = new GDMList();
+ var buffer = new List();
for (int j = 0; j < fTopLevels.Count; j++) {
var topLevel = fTopLevels[j];
var topLoc = tree.GetPtrValue(topLevel);
if (topLoc == null) continue;
+ bool wasJoin = false;
var topNames = topLoc.GetFullNames(tree);
for (int i = 0; i < topNames.Count; i++) {
var topName = topNames[i];
@@ -153,10 +187,19 @@ public GDMList GetFullNames(GDMTree tree)
newLocName.StringValue = topName.StringValue;
newLocName.Date.ParseString(interDate.StringValue);
buffer.Add(newLocName);
+ wasJoin = true;
}
}
+
+ if (!wasJoin && topNames.Count > 0) {
+ var newLocName = new GDMLocationName();
+ newLocName.StringValue = topNames[topNames.Count - 1].StringValue;
+ newLocName.Date.ParseString(topLevel.Date.StringValue);
+ buffer.Add(newLocName);
+ }
}
+ bool reverseOrder = GlobalOptions.Instance.ReversePlaceEntitiesOrder;
for (int j = 0; j < buffer.Count; j++) {
var topLocName = buffer[j];
var topName = topLocName.StringValue;
@@ -167,7 +210,7 @@ public GDMList GetFullNames(GDMTree tree)
var interDate = GDMCustomDate.GetIntersection(topDate, locName.Date.Value);
if (!interDate.IsEmpty()) {
- string newName = locName.StringValue + ", " + topName;
+ string newName = (!reverseOrder) ? topName + ", " + locName.StringValue : locName.StringValue + ", " + topName;
var newLocName = new GDMLocationName();
newLocName.StringValue = newName;
@@ -176,13 +219,6 @@ public GDMList GetFullNames(GDMTree tree)
}
}
}
- } else {
- for (int i = 0; i < fNames.Count; i++) {
- var locName = fNames[i];
- if (locName.Date.IsEmpty()) continue;
-
- result.Add(locName);
- }
}
return result;
diff --git a/projects/GKCore/GDModel/GDMTree.cs b/projects/GKCore/GDModel/GDMTree.cs
index 683e2475c..ed2cc6a50 100644
--- a/projects/GKCore/GDModel/GDMTree.cs
+++ b/projects/GKCore/GDModel/GDMTree.cs
@@ -697,17 +697,38 @@ public bool DeleteLocationRecord(GDMLocationRecord locRec)
int num = fRecords.Count;
for (int i = 0; i < num; i++) {
- var evsRec = fRecords[i] as GDMRecordWithEvents;
- if (evsRec == null || !evsRec.HasEvents) continue;
-
- for (int j = evsRec.Events.Count - 1; j >= 0; j--) {
- var evt = evsRec.Events[j];
- if (!evt.HasPlace) continue;
-
- GDMPointer evLocation = evt.Place.Location;
- if (evLocation.XRef == locRec.XRef) {
- evLocation.XRef = string.Empty;
- }
+ var rec = fRecords[i];
+
+ switch (rec.RecordType) {
+ case GDMRecordType.rtIndividual:
+ case GDMRecordType.rtFamily: {
+ var evsRec = rec as GDMRecordWithEvents;
+ if (evsRec == null || !evsRec.HasEvents) continue;
+
+ for (int j = evsRec.Events.Count - 1; j >= 0; j--) {
+ var evt = evsRec.Events[j];
+ if (!evt.HasPlace) continue;
+
+ GDMPointer evLocation = evt.Place.Location;
+ if (evLocation.XRef == locRec.XRef) {
+ evLocation.XRef = string.Empty;
+ }
+ }
+ }
+ break;
+
+ case GDMRecordType.rtLocation: {
+ var lRec = rec as GDMLocationRecord;
+ if (lRec == null) continue;
+
+ for (int j = lRec.TopLevels.Count - 1; j >= 0; j--) {
+ var topLev = lRec.TopLevels[j];
+ if (topLev.XRef == locRec.XRef) {
+ lRec.TopLevels.DeleteAt(j);
+ }
+ }
+ }
+ break;
}
}
diff --git a/projects/GKCore/GKCore/Charts/TreeChartModel.cs b/projects/GKCore/GKCore/Charts/TreeChartModel.cs
index 844bb4677..d491dba2e 100644
--- a/projects/GKCore/GKCore/Charts/TreeChartModel.cs
+++ b/projects/GKCore/GKCore/Charts/TreeChartModel.cs
@@ -266,6 +266,7 @@ public TreeChartModel()
fPreparedFamilies = new HashSet();
fPreparedIndividuals = new HashSet();
fScale = 1.0f;
+ fPicScale = 1.0f;
fBranchDistance = DEF_BRANCH_DISTANCE;
fLevelDistance = DEF_LEVEL_DISTANCE;
diff --git a/projects/GKCore/GKCore/GKUtils.cs b/projects/GKCore/GKCore/GKUtils.cs
index c2743bbc1..7dc703eca 100644
--- a/projects/GKCore/GKCore/GKUtils.cs
+++ b/projects/GKCore/GKCore/GKUtils.cs
@@ -3025,11 +3025,33 @@ public static void ShowLocationInfo(IBaseContext baseContext, GDMLocationRecord
summary.Add("");
}
+ GDMTree tree = baseContext.Tree;
+
+ if (locRec.TopLevels.Count > 0) {
+ summary.Add("");
+ summary.Add(LangMan.LS(LSID.TopLevelLinks) + ":");
+
+ for (int i = 0; i < locRec.TopLevels.Count; i++) {
+ var topLev = locRec.TopLevels[i];
+ var topLoc = tree.GetPtrValue(topLev);
+
+ string st = HyperLink(topLev.XRef, topLoc.GetNameByDate(topLev.Date.Value));
+ if (!string.IsNullOrEmpty(st)) {
+ summary.Add(" " + st);
+ }
+
+ st = topLev.Date.GetDisplayStringExt(glob.DefDateFormat, glob.ShowDatesSign, glob.ShowDatesCalendar);
+ if (!string.IsNullOrEmpty(st)) {
+ summary.Add(" " + st);
+ }
+
+ summary.Add("");
+ }
+ }
+
summary.Add(LangMan.LS(LSID.Latitude) + ": " + locRec.Map.Lati);
summary.Add(LangMan.LS(LSID.Longitude) + ": " + locRec.Map.Long);
- GDMTree tree = baseContext.Tree;
-
var fullNames = locRec.GetFullNames(tree);
if (fullNames.Count > 0) {
//linkList.Sort();
diff --git a/projects/GKTests/GDModel/GDMLocationRecordTests.cs b/projects/GKTests/GDModel/GDMLocationRecordTests.cs
index 1bde2b1cb..5f3810aee 100644
--- a/projects/GKTests/GDModel/GDMLocationRecordTests.cs
+++ b/projects/GKTests/GDModel/GDMLocationRecordTests.cs
@@ -24,6 +24,7 @@
using System.Linq;
using GDModel.Providers.GEDCOM;
using GKCore;
+using GKCore.Options;
using GKCore.Types;
using GKTests;
using NUnit.Framework;
@@ -190,6 +191,8 @@ public void Test_NamesByDate()
[Test]
public void Test_Hierarchy()
{
+ GlobalOptions.Instance.ReversePlaceEntitiesOrder = true;
+
var tree = new GDMTree();
// J2G Rus transfer: 26 JAN 1918 (Julian), 1 FEB -> 14 FEB 1918
@@ -381,6 +384,8 @@ public void Test_Hierarchy()
//var gedcomProvider = new GEDCOMProvider(tree);
//gedcomProvider.SaveToStreamExt(new FileStream("d:\\Russia.ged", FileMode.CreateNew), GEDCOMCharacterSet.csUTF8);
+
+ GlobalOptions.Instance.ReversePlaceEntitiesOrder = false;
}
[Test]
diff --git a/samples/RussiaLocations.ged b/samples/RussiaLocations.ged
index 2cb13ffaa..61c51cd66 100644
--- a/samples/RussiaLocations.ged
+++ b/samples/RussiaLocations.ged
@@ -1,6 +1,6 @@
0 HEAD
1 SOUR GEDKeeper
-2 VERS 45
+2 VERS 46
1 DEST GEDKeeper
1 CHAR UTF-8
1 GEDC
@@ -8,9 +8,9 @@
2 FORM LINEAGE-LINKED
1 FILE RussiaLocations.ged
2 _UID 1FED9A011B5AFA4AAED1C2C28CB076BFD434
-2 _REV 24
-1 DATE 06 FEB 2024
-2 TIME 20:58:12.9
+2 _REV 30
+1 DATE 14 MAR 2024
+2 TIME 14:29:17.1
0 @L1@ _LOC
1 _UID 259212A7C781634B851B7F4C19FE40CFF7BD
1 CHAN
@@ -264,9 +264,18 @@
0 @L16@ _LOC
1 _UID DF70190CB963D04D8174DE1DCB424307F4B4
1 CHAN
-2 DATE 06 FEB 2024
-3 TIME 00:18:37.1
+2 DATE 14 MAR 2024
+3 TIME 14:28:46.4
+1 NAME Архангелогородская губерния
+2 DATE FROM 18 DEC 1708 TO 24 JAN 1780
+1 NAME Архангельская область
+2 DATE FROM 25 JAN 1780 TO FEB 1784
+1 NAME Архангельское наместничество
+2 DATE FROM 26 MAR 1784 TO 11 DEC 1796
1 NAME Архангельская губерния
+2 DATE FROM 12 DEC 1796 TO 14 JAN 1929
+1 _LOC @L1@
+2 DATE FROM 1708
0 @L18@ _LOC
1 _UID E86CA4E9BA504B409993827382B325D0C14A
1 CHAN
@@ -333,9 +342,18 @@
0 @L27@ _LOC
1 _UID 48C2974CB8E17E488A4573677F35AD398FD1
1 CHAN
-2 DATE 06 FEB 2024
-3 TIME 00:21:07.2
+2 DATE 14 MAR 2024
+3 TIME 14:28:18
+1 NAME Вологодская провинция
+2 DATE FROM 1719 TO 24 JAN 1780
+1 NAME Вологодское наместничество
+2 DATE FROM 25 JAN 1780 TO 11 DEC 1796
1 NAME Вологодская губерния
+2 DATE FROM 12 DEC 1796 TO 14 JAN 1929
+1 _LOC @L16@
+2 DATE FROM 1719 TO 1775
+1 _LOC @L1@
+2 DATE FROM 1776
0 @L28@ _LOC
1 _UID 74E55FEBED50C64ABE3840D14D25BFD5FDB1
1 CHAN
@@ -783,4 +801,24 @@
2 DATE FROM 1775
1 _LOC @L1@
2 DATE FROM 05 SEP 1809 TO 1918
+0 @L94@ _LOC
+1 _UID 53F45B9DC0CA5C44A527B04DA686F7ED42F8
+1 CHAN
+2 DATE 14 MAR 2024
+3 TIME 13:55:50.6
+1 NAME Тотемский уезд
+2 DATE FROM 1708 TO 1928
+1 NAME Тотемский район
+2 DATE FROM 1929
+1 _LOC @L16@
+2 DATE FROM 1708 TO 1718
+1 _LOC @L27@
+2 DATE FROM 1719 TO SEP 1929
+0 @L95@ _LOC
+1 _UID FA8FC00526A4304D8CF40904B10D6CE7332B
+1 CHAN
+2 DATE 14 MAR 2024
+3 TIME 13:53:38.5
+1 NAME Северный край
+2 DATE FROM 01 OCT 1929 TO 05 DEC 1936
0 TRLR