Skip to content

Commit

Permalink
Added an option to disable the search for places without coordinates …
Browse files Browse the repository at this point in the history
…in geocoders (general maps)
  • Loading branch information
Serg-Norseman committed Oct 31, 2024
1 parent 1d1d34a commit b55fc70
Show file tree
Hide file tree
Showing 32 changed files with 284 additions and 171 deletions.
2 changes: 2 additions & 0 deletions locales/Afrikaans.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Belarusian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Chinese Simplified.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Dutch.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/English.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Hungarian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Icelandic.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Japanese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Kazakh (Cyrillic).lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Portuguese.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Serbian (Latin).lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/Spanish.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/czech.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/french.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/german.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
1 change: 1 addition & 0 deletions locales/help_enu/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>Change log</h1>

<p>
<b>??.??.2024 [v2.32.0 &amp; v3.8.0]</b><ul>
<li>Added an option to disable the search for places without coordinates in geocoders (general maps).
<li>Added the feature to display on maps all subordinate locations and persons of the selected hierarchy of locations.
<li>Added mode for displaying parents' ages in tree diagrams.
<li>Added an option to simplify the form of woman single surnames in extended mode (output without brackets if there are no other surnames).
Expand Down
1 change: 1 addition & 0 deletions locales/help_rus/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>История версий</h1>

<p>
<b>??.??.2024 [v2.32.0 &amp; v3.8.0]</b><ul>
<li>Добавлена опция выключения поиска мест без координат в геокодерах (общие карты).
<li>Добавлена возможность выводить на карты все подчиненные места и персоны выбранной иерархии мест.
<li>Добавлен режим отображения возрастов родителей в диаграммах деревьев.
<li>Добавлена опция упрощения формы единственных фамилий женщин в расширенном режиме (вывод без скобок, если других фамилий нет).
Expand Down
2 changes: 2 additions & 0 deletions locales/italian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/polish.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
2 changes: 2 additions & 0 deletions locales/russian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Простая форма единственных фамилий
999=Карта мест
1000=Карта персон
1001=Поиск в геокодерах мест без координат (карты)
1002=Места и Карты
2 changes: 2 additions & 0 deletions locales/ukrainian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,5 @@
998=Simple form of single surnames
999=Map of places
1000=Map of persons
1001=Search in geocoders for places without coordinates (maps)
1002=Locations and Maps
55 changes: 31 additions & 24 deletions projects/GKCore/GKCore/Controllers/MapsViewerWinController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using GKCore.Design.Views;
using GKCore.Interfaces;
using GKCore.Maps;
using GKCore.Options;

namespace GKCore.Controllers
{
Expand All @@ -39,6 +40,7 @@ public sealed class MapsViewerWinController : FormController<IMapsViewerWin>
private readonly List<GeoPoint> fMapPoints;
private readonly List<GDMRecord> fSelectedPersons;
private readonly Dictionary<string, MapPlace> fPlaces;
private readonly bool fSearchPlacesWithoutCoords;

private ITVNode fBaseRoot;

Expand All @@ -52,6 +54,7 @@ public MapsViewerWinController(IMapsViewerWin view, List<GDMRecord> selectedPers
fMapPoints = new List<GeoPoint>();
fPlaces = new Dictionary<string, MapPlace>();
fSelectedPersons = selectedPersons;
fSearchPlacesWithoutCoords = GlobalOptions.Instance.SearchPlacesWithoutCoords;
}

public void ShowFixedPoints(IEnumerable<GeoPoint> points)
Expand Down Expand Up @@ -87,26 +90,21 @@ private void LoadPlacesInt(StringList personValues, IProgressController progress
GDMTree tree = fBase.Context.Tree;
progress.Begin(LangMan.LS(LSID.LoadingLocations), tree.RecordsCount);
try {
int num = tree.RecordsCount;
for (int i = 0; i < num; i++) {
GDMRecord rec = tree[i];
bool res = rec is GDMIndividualRecord && IsSelected(rec);
for (int i = 0, num = tree.RecordsCount; i < num; i++) {
GDMIndividualRecord iRec = tree[i] as GDMIndividualRecord;

if (res) {
GDMIndividualRecord ind = rec as GDMIndividualRecord;
if (iRec != null && IsSelected(iRec) && iRec.HasEvents) {
int pCnt = 0;

int num2 = ind.Events.Count;
for (int j = 0; j < num2; j++) {
GDMCustomEvent ev = ind.Events[j];
for (int j = 0, num2 = iRec.Events.Count; j < num2; j++) {
GDMCustomEvent ev = iRec.Events[j];
if (ev.HasPlace && !string.IsNullOrEmpty(ev.Place.StringValue)) {
AddPlace(ev.Place, ind, ev);
pCnt++;
pCnt += AddPlace(iRec, ev);
}
}

if (pCnt > 0) {
personValues.AddObject(GKUtils.GetNameString(ind, true, false) + " [" + pCnt.ToString() + "]", ind);
personValues.AddObject(GKUtils.GetNameString(iRec, true, false) + " [" + pCnt.ToString() + "]", iRec);
}
}

Expand Down Expand Up @@ -163,33 +161,42 @@ public void LoadPlaces()
fView.PersonsCombo.EndUpdate();
PlacesCache.Instance.Save();
} catch (Exception ex) {
Logger.WriteError("MapsViewerWin.PlacesLoad()", ex);
Logger.WriteError("MapsViewerWinController.LoadPlaces()", ex);
}
}

private void AddPlace(GDMPlace place, GDMRecord owner, GDMCustomEvent placeEvent)
private int AddPlace(GDMRecord owner, GDMCustomEvent placeEvent)
{
int result = 0;
try {
GDMPlace place = placeEvent.Place;
var locRec = fBase.Context.Tree.GetPtrValue<GDMLocationRecord>(place.Location);
string placeName = (locRec != null) ? locRec.LocationName : place.StringValue;

MapPlace mapPlace;
MapPlace mapPlace = null;
if (!fPlaces.TryGetValue(placeName, out mapPlace)) {
mapPlace = new MapPlace();
mapPlace.Name = placeName;
fPlaces.Add(placeName, mapPlace);
bool hasCoords = locRec != null && !locRec.Map.IsEmpty();

if (locRec == null) {
PlacesCache.Instance.GetPlacePoints(placeName, mapPlace.Points);
} else {
if (hasCoords || fSearchPlacesWithoutCoords) {
mapPlace = new MapPlace(placeName);
fPlaces.Add(placeName, mapPlace);
}

if (hasCoords) {
mapPlace.Points.Add(new GeoPoint(locRec.Map.Lati, locRec.Map.Long, placeName));
} else if (fSearchPlacesWithoutCoords) {
PlacesCache.Instance.GetPlacePoints(placeName, mapPlace.Points);
}
}

mapPlace.PlaceRefs.Add(new PlaceRef(owner, placeEvent));
if (mapPlace != null) {
mapPlace.PlaceRefs.Add(new PlaceRef(owner, placeEvent));
result = 1;
}
} catch (Exception ex) {
Logger.WriteError("MapsViewerWin.AddPlace()", ex);
Logger.WriteError("MapsViewerWinController.AddPlace()", ex);
}
return result;
}

public void SetCenter()
Expand Down Expand Up @@ -261,7 +268,7 @@ public async void SaveSnapshot()
fView.MapBrowser.SaveSnapshot(fileName);
}
} catch (Exception ex) {
Logger.WriteError("SaveSnapshot()", ex);
Logger.WriteError("MapsViewerWinController.SaveSnapshot()", ex);
AppHost.StdDialogs.ShowError("Image failed to save: " + ex.Message);
}
}
Expand Down
12 changes: 12 additions & 0 deletions projects/GKCore/GKCore/Controllers/OptionsDlgController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public OptionsDlgController(IOptionsDlg view) : base(view)
fView.EventTypesList.ListModel = new EventDefsListModel(fView, null, null);
}

public void ChangeTab()
{
AcceptLanguage();
SetLocale();
UpdateView();
}

private void FillGeoSearchCountries()
{
var combo = GetControl<IComboBox>("cmbGeoSearchCountry");
Expand Down Expand Up @@ -482,6 +489,7 @@ public void UpdateSpecials()

GetControl<ICheckBox>("chkReversePlacesOrder").Checked = fOptions.ReversePlaceEntitiesOrder;
GetControl<ICheckBox>("chkShowNumberOfSubstructures").Checked = fOptions.ShowNumberOfSubstructures;
GetControl<ICheckBox>("chkSearchPlacesWithoutCoords").Checked = fOptions.SearchPlacesWithoutCoords;
}

public void AcceptSpecials()
Expand All @@ -505,6 +513,7 @@ public void AcceptSpecials()

fOptions.ReversePlaceEntitiesOrder = GetControl<ICheckBox>("chkReversePlacesOrder").Checked;
fOptions.ShowNumberOfSubstructures = GetControl<ICheckBox>("chkShowNumberOfSubstructures").Checked;
fOptions.SearchPlacesWithoutCoords = GetControl<ICheckBox>("chkSearchPlacesWithoutCoords").Checked;
}

private void UpdateEventTypes()
Expand Down Expand Up @@ -1007,6 +1016,8 @@ public override void SetLocale()

GetControl<ITabPage>("pageNavigation").Text = LangMan.LS(LSID.Navigation);

GetControl<ITabPage>("pageGeo").Text = LangMan.LS(LSID.LocationsAndMaps);

// Pedigree
GetControl<ITabPage>("pagePedigree").Text = LangMan.LS(LSID.Pedigrees);

Expand Down Expand Up @@ -1047,6 +1058,7 @@ public override void SetLocale()
GetControl<ICheckBox>("chkELAbbreviatedNames").Text = LangMan.LS(LSID.EL_AbbreviatedNames);
GetControl<ICheckBox>("chkReversePlacesOrder").Text = LangMan.LS(LSID.ReversePlacesOrder);
GetControl<ICheckBox>("chkShowNumberOfSubstructures").Text = LangMan.LS(LSID.ShowNumberOfSubstructures);
GetControl<ICheckBox>("chkSearchPlacesWithoutCoords").Text = LangMan.LS(LSID.SearchPlacesWithoutCoords);

// event types
GetControl<ITabPage>("pageEventTypes").Text = LangMan.LS(LSID.EventTypes);
Expand Down
6 changes: 5 additions & 1 deletion projects/GKCore/GKCore/LangMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,8 +1075,10 @@ public enum LSID
/* 998 */ SimpleSingleSurnames,
/* 999 */ MapOfPlaces,
/* 1000 */ MapOfPersons,
/* 1001 */ SearchPlacesWithoutCoords,
/* 1002 */ LocationsAndMaps,

/* 000 */ Last = MapOfPersons
/* 000 */ Last = LocationsAndMaps
}


Expand Down Expand Up @@ -2105,6 +2107,8 @@ public static class LangMan
/* 998 */ "Simple form of single surnames",
/* 999 */ "Map of places",
/* 1000 */ "Map of persons",
/* 1001 */ "Search in geocoders for places without coordinates (maps)",
/* 1002 */ "Locations and Maps",
};

private static readonly LangManager fLangMan = new LangManager();
Expand Down
5 changes: 3 additions & 2 deletions projects/GKCore/GKCore/Maps/PlacesLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2022 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -52,8 +52,9 @@ public class MapPlace
public readonly List<GeoPoint> Points;
public readonly List<PlaceRef> PlaceRefs;

public MapPlace()
public MapPlace(string name)
{
Name = name;
Points = new List<GeoPoint>();
PlaceRefs = new List<PlaceRef>();
}
Expand Down
10 changes: 10 additions & 0 deletions projects/GKCore/GKCore/Options/GlobalOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ public StringList ResidenceFilters

public bool SearchAndFilterByAllNames { get; set; }

/// <summary>
/// Maps.
/// </summary>
public bool SearchPlacesWithoutCoords { get; set; }

public bool ShortKinshipForm { get; set; }

public bool ShowDatesCalendar { get; set; }
Expand Down Expand Up @@ -423,6 +428,9 @@ public void ResetDefaults_Specials()
EL_AbbreviatedNames = true;

ShowNumberOfSubstructures = false;

// maps?
SearchPlacesWithoutCoords = false;
}

public void Assign(IOptions source)
Expand Down Expand Up @@ -844,6 +852,7 @@ public void LoadFromFile(IniFile ini)
ShowIndiNamesakes = ini.ReadBool("Common", "ShowIndiNamesakes", false);
ShowNumberOfSubstructures = ini.ReadBool("Common", "ShowNumberOfSubstructures", false);
MatchPatternMethod = (MatchPatternMethod)ini.ReadInteger("Common", "MatchPatternMethod", 0);
SearchPlacesWithoutCoords = ini.ReadBool("Common", "SearchPlacesWithoutCoords", false);

Theme = ini.ReadString("Common", "Theme", "");

Expand Down Expand Up @@ -997,6 +1006,7 @@ public void SaveToFile(IniFile ini)
ini.WriteBool("Common", "ShowIndiNamesakes", ShowIndiNamesakes);
ini.WriteBool("Common", "ShowNumberOfSubstructures", ShowNumberOfSubstructures);
ini.WriteInteger("Common", "MatchPatternMethod", (int)MatchPatternMethod);
ini.WriteBool("Common", "SearchPlacesWithoutCoords", SearchPlacesWithoutCoords);

ini.WriteString("Common", "Theme", Theme);

Expand Down
2 changes: 1 addition & 1 deletion projects/GKTests/GKCore/PlacesLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void Test_PlaceRef()
[Test]
public void Test_MapPlace()
{
var mapPlace = new MapPlace();
var mapPlace = new MapPlace(string.Empty);
Assert.IsNotNull(mapPlace);
Assert.IsNotNull(mapPlace.Points);
Assert.IsNotNull(mapPlace.PlaceRefs);
Expand Down
Loading

0 comments on commit b55fc70

Please sign in to comment.