Korrekturen:
1. "leere" Next/Lastport (statt ZZUKN) crashfrei tolerieren
2. Locode DB auch mit name_wo_diacritics durchsuchen, damit Fuglafjordur statt Fuglafjørdur gefunden werden kann
This commit is contained in:
Daniel Schick 2016-11-06 10:50:59 +00:00
parent 625a9f262e
commit edd48e8c0b
5 changed files with 39 additions and 31 deletions

Binary file not shown.

View File

@ -41,7 +41,7 @@ namespace bsmd.ExcelReadService
public static string LocodeFromCity(string city, string country)
{
string result = null;
string query = string.Format("SELECT city_code FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE countries.code = '{0}' AND locodes.port='t' AND locodes.name like '{1}'",
string query = string.Format("SELECT city_code FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE countries.code = '{0}' AND locodes.port='t' AND (locodes.name like '{1}' OR locodes.name_wo_diacritics like '{1}')",
country, city);
SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader();
@ -67,7 +67,7 @@ namespace bsmd.ExcelReadService
if ((countryCode != null) && (lcLookup != null))
results.Add(lcLookup);
}
string query = string.Format("SELECT city_code, countries.code FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.port='t' AND locodes.name like '{0}'", city);
string query = string.Format("SELECT city_code, countries.code FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.port='t' AND (locodes.name like '{0}' OR locodes.name_wo_diacritics like '{0}')", city);
SQLiteCommand cmd = new SQLiteCommand(query, _con);
IDataReader reader = cmd.ExecuteReader();
while (reader.Read())

View File

@ -380,38 +380,46 @@ namespace bsmd.ExcelReadService
}
string lastPort = reader.ReadText("NOA_NOD.LastPort").Trim();
string lastPort = reader.ReadText("NOA_NOD.LastPort");
if (!lastPort.IsNullOrEmpty()) lastPort = lastPort.Trim();
if (LocodeDB.PortNameFromLocode(lastPort) != null)
if (lastPort != null)
{
noa_nod.LastPort = lastPort;
}
else
{
List<string> lastPorts = LocodeDB.AllLocodesForCityName(lastPort);
if (lastPorts.Count == 1)
noa_nod.LastPort = lastPorts[0];
else
_log.WarnFormat("{0} results in {1} possible LOCODES", lastPort, lastPorts.Count);
}
string nextPort = reader.ReadText("NOA_NOD.NextPort").Trim();
if (LocodeDB.PortNameFromLocode(nextPort) != null)
{
noa_nod.NextPort = nextPort;
}
else
{
List<string> nextPorts = LocodeDB.AllLocodesForCityName(nextPort);
if (nextPorts.Count == 1)
noa_nod.NextPort = nextPorts[0];
if (LocodeDB.PortNameFromLocode(lastPort) != null)
{
noa_nod.LastPort = lastPort;
}
else
{
if (nextPort.Equals("ZZUKN", StringComparison.OrdinalIgnoreCase))
noa_nod.NextPort = nextPort;
List<string> lastPorts = LocodeDB.AllLocodesForCityName(lastPort);
if (lastPorts.Count == 1)
noa_nod.LastPort = lastPorts[0];
else
_log.WarnFormat("{0} results in {1} possible LOCODES", nextPort, nextPorts.Count);
_log.WarnFormat("{0} results in {1} possible LOCODES", lastPort, lastPorts.Count);
}
}
string nextPort = reader.ReadText("NOA_NOD.NextPort");
if (!nextPort.IsNullOrEmpty()) nextPort = nextPort.Trim();
if (nextPort != null)
{
if (LocodeDB.PortNameFromLocode(nextPort) != null)
{
noa_nod.NextPort = nextPort;
}
else
{
List<string> nextPorts = LocodeDB.AllLocodesForCityName(nextPort);
if (nextPorts.Count == 1)
noa_nod.NextPort = nextPorts[0];
else
{
if (nextPort.Equals("ZZUKN", StringComparison.OrdinalIgnoreCase))
noa_nod.NextPort = nextPort;
else
_log.WarnFormat("{0} results in {1} possible LOCODES", nextPort, nextPorts.Count);
}
}
}

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("3.2.21")]
[assembly: AssemblyInformationalVersion("3.2.22")]
[assembly: AssemblyCopyright("Copyright © 2014-2016 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")]

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("3.2.21.*")]
[assembly: AssemblyVersion("3.2.22.*")]