Skip to content

Commit

Permalink
show points of interest from https://edastro.com/poi/json/all
Browse files Browse the repository at this point in the history
  • Loading branch information
mhwlng committed May 14, 2022
1 parent e2f77ee commit c805cc6
Show file tree
Hide file tree
Showing 12 changed files with 642 additions and 203 deletions.
2 changes: 2 additions & 0 deletions Elite/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ protected override void OnStartup(StartupEventArgs evtArgs)
splashScreen.Dispatcher.Invoke(() => splashScreen.ProgressText.Text = "Loading POI Items...");
Poi.FullPoiList = Poi.GetAllPois(); //?.GroupBy(x => x.System.Trim().ToLower()).ToDictionary(x => x.Key, x => x.ToList());

Poi.FullPoiList = Poi.GetGECPois(@"Data\poigec.json", Poi.FullPoiList);

RefreshJson(splashScreen);

splashScreen.Dispatcher.Invoke(() => splashScreen.ProgressText.Text = "Loading History...");
Expand Down
2 changes: 1 addition & 1 deletion Elite/CnbSystems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static List<CnbSystemData> GetNearestCnbSystems(List<double> starPos)
systemItem.Distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
});

return FullCnbSystemsList.Where(x => x.Distance >= 0).OrderBy(x => x.Distance).Take(5).ToList();
return FullCnbSystemsList.Where(x => x.Distance >= 0).OrderBy(x => x.Distance).Take(10).ToList();
}

return new List<CnbSystemData>();
Expand Down
2 changes: 1 addition & 1 deletion Elite/Elite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.8\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
Expand Down
78 changes: 77 additions & 1 deletion Elite/POI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,46 @@
using CsvHelper.Configuration;
using CsvHelper.Configuration.Attributes;
using CsvHelper.TypeConversion;
using EDEngineer.Models;
using Newtonsoft.Json;

namespace Elite
{
public class PoiGECItem
{
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("galMapSearch")]
public string GalMapSearch { get; set; }
[JsonProperty("galMapUrl")]
public string GalMapUrl { get; set; }
[JsonProperty("coordinates")]
public float[] Coordinates { get; set; }
[JsonProperty("summary")]
public string Summary { get; set; }
[JsonProperty("descriptionMardown")]
public string DescriptionMardown { get; set; }
[JsonProperty("descriptionHtml")]
public string DescriptionHtml { get; set; }
[JsonProperty("solDistance")]
public float SolDistance { get; set; }
[JsonProperty("id64")]
public long Id64 { get; set; }
[JsonProperty("rating")]
public string Rating { get; set; }
[JsonProperty("curation")]
public string Curation { get; set; }
[JsonProperty("poiUrl")]
public string PoiUrl { get; set; }
[JsonProperty("mainImage")]
public string MainImage { get; set; }

}

public class PoiItem
{
[Name("Location Name")] public string LocationName { get; set; }
Expand Down Expand Up @@ -208,6 +245,45 @@ public static List<PoiItem> GetAllPois()

}

public static List<PoiItem> GetGECPois(string path, List<PoiItem> fullPoiList)
{
try
{
//fullPoiList = new List<PoiItem>();

path = Path.Combine(App.ExePath, path);

if (File.Exists(path))
{
var poiList = JsonConvert.DeserializeObject<List<PoiGECItem>>(File.ReadAllText(path));

foreach (var poi in poiList)
{
fullPoiList.Add(new PoiItem()
{
LocationName = poi.Name,
GalacticX = poi.Coordinates[0],
GalacticY = poi.Coordinates[1],
GalacticZ = poi.Coordinates[2],
System = poi.GalMapSearch,
Category = poi.Type,
DistanceToSol = poi.SolDistance,
Notable = poi.Summary
//Notes=poi.summary
});
}

}
}
catch (Exception ex)
{
App.Log.Error(ex);
}

return fullPoiList;
}


public static List<PoiItem> GetNearestPois(List<double> starPos)
{
if (FullPoiList?.Any() == true && starPos?.Count == 3)
Expand All @@ -229,7 +305,7 @@ public static List<PoiItem> GetNearestPois(List<double> starPos)
poiItem.Distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
});

return FullPoiList.Where(x => x.Distance >= 0).OrderBy(x => x.Distance).Take(5).ToList();
return FullPoiList.Where(x => x.Distance >= 0).OrderBy(x => x.Distance).Take(10).ToList();
}

return new List<PoiItem>();
Expand Down
4 changes: 2 additions & 2 deletions Elite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.4.0")]
[assembly: AssemblyFileVersion("1.9.4.0")]
[assembly: AssemblyVersion("1.9.5.0")]
[assembly: AssemblyFileVersion("1.9.5.0")]

[assembly: log4net.Config.XmlConfigurator(Watch = true)]
2 changes: 1 addition & 1 deletion Elite/Station.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public static List<StationData> GetNearestStations(List<double> starPos, List<St
stationItem.Distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
});

return stationData.Where(x => x.Distance >= 0).OrderBy(x => x.Distance).Take(5).ToList();
return stationData.Where(x => x.Distance >= 0).OrderBy(x => x.Distance).Take(10).ToList();
}

return new List<StationData>();
Expand Down
70 changes: 35 additions & 35 deletions Elite/app.config
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="joystickSettings" type="System.Configuration.NameValueSectionHandler"/>
<section name="panelSettings" type="System.Configuration.NameValueSectionHandler"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
<section name="razorEngine" type="RazorEngine.Configuration.RazorEngineConfigurationSection, RazorEngine" requirePermission="false"/>
<section name="joystickSettings" type="System.Configuration.NameValueSectionHandler" />
<section name="panelSettings" type="System.Configuration.NameValueSectionHandler" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
<section name="razorEngine" type="RazorEngine.Configuration.RazorEngineConfigurationSection, RazorEngine" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Elite.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
<section name="Elite.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings configSource="appsettings.config"/>
<joystickSettings configSource="joysticksettings.config"/>
<panelSettings configSource="panelsettings.config"/>
<appSettings configSource="appsettings.config" />
<joystickSettings configSource="joysticksettings.config" />
<panelSettings configSource="panelsettings.config" />
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="log.txt"/>
<immediateFlush value="true"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="20"/>
<maximumFileSize value="1MB"/>
<staticLogFileName value="true"/>
<file value="log.txt" />
<immediateFlush value="true" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="20" />
<maximumFileSize value="1MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5p %d %M - %m%n"/>
<conversionPattern value="%-5p %d %M - %m%n" />
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="RollingLogFileAppender"/>
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0"/>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Win32.Registry" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
<assemblyIdentity name="Microsoft.Win32.Registry" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1"/>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>


<razorEngine>
<namespaces>
<add namespace="Elite"/>
<add namespace="Elite" />
</namespaces>
</razorEngine>


<userSettings>
<Elite.Properties.Settings>
<setting name="Top" serializeAs="String">
<value/>
<value />
</setting>
<setting name="Left" serializeAs="String">
<value/>
<value />
</setting>
<setting name="Visible" serializeAs="String">
<value>False</value>
</setting>
</Elite.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup></configuration>
2 changes: 1 addition & 1 deletion Elite/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="HtmlRenderer.WinForms" version="1.5.0.6" targetFramework="net472" />
<package id="ini-parser" version="2.5.2" targetFramework="net472" />
<package id="log4net" version="2.0.14" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.8" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="net472" />
<package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net472" />
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net472" />
Expand Down
1 change: 1 addition & 0 deletions ImportData/ImportData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Compile Include="StationEDDB.cs" />
<Compile Include="StationEDSM.cs" />
<Compile Include="StationData.cs" />
<Compile Include="SystemSpansh.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
Loading

0 comments on commit c805cc6

Please sign in to comment.