Skip to content

Commit

Permalink
Merge branch 'names' into RandomGen
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-techkid committed May 17, 2024
2 parents a67a015 + 6f13257 commit 7d5539c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion SpotifyGPX/DupeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private List<IGrouping<Coordinate, SongPoint>> GroupDuplicates()
{
// Create list of grouped duplicate coordinate values from final points list
return Pairs
.Where(pair => pair.Origin.Type == TrackType.Gps) // Filter out non-GPX journey dupes
.Where(pair => pair.Origin.Type == TrackType.Gps) // Filter out non-GPS journey dupes
.GroupBy(p => p.Point.Location) // Group them by matching locations
.Where(group => group.Count() >= MinimumMatchingCoords) // Filter out groups not having enough matching coords
.ToList(); // Send the resulting dupes to a list
Expand Down
4 changes: 2 additions & 2 deletions SpotifyGPX/GpsTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace SpotifyGPX;
/// </summary>
/// <param name="index">The index of this track (in a series of tracks)</param>
/// <param name="name">The friendly name of this track.</param>
/// <param name="type">The type of this track (GPX, Gap, or Combined).</param>
/// <param name="type">The type of this track (GPS, Gap, or Combined).</param>
/// <param name="points">A list of the points comprising this track.</param>
public GpsTrack(int? index, string? name, TrackType type, List<IGpsPoint> points)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
}

/// <summary>
/// Converts this GPXTrack object to a string.
/// Converts this <see cref="GpsTrack"/> object to a string.
/// </summary>
/// <returns>A string, containing the name, number of points, start and end times, and type of the track.</returns>
public override string ToString() // Display format for this track
Expand Down
6 changes: 3 additions & 3 deletions SpotifyGPX/Input/Gpx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Gpx(string path) : base(path)
private List<GpsTrack> ParseTracks()
{
return Document.Descendants(InputNs + Track)
.Select((trk, index) => new GpsTrack( // For each track and its index, create a new GPXTrack
.Select((trk, index) => new GpsTrack( // For each track and its index, create a new GpsTrack
index,
trk.Element(InputNs + "name")?.Value,
TrackType.Gps,
Expand All @@ -34,9 +34,9 @@ private List<GpsTrack> ParseTracks()
double.Parse(trkpt.Attribute("lon")?.Value ?? throw new Exception($"GPX 'lon' cannot be null, check your GPX"))
),
Time = DateTimeOffset.ParseExact(trkpt.Element(InputNs + "time")?.Value ?? throw new Exception($"GPX 'time' cannot be null, check your GPX"), TimeFormat, null, TimeStyle)
}).ToList() // Send all points to List<GPXPoint>
}).ToList() // Send all points to list
))
.ToList(); // Send all tracks to List<GPXTrack>
.ToList(); // Send all tracks to list
}

private List<GpsTrack> FilterTracks()
Expand Down
4 changes: 2 additions & 2 deletions SpotifyGPX/Input/InputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<ISongEntry> GetFilteredSongs(List<GpsTrack> tracks)
/// <summary>
/// Gets all journey tracks from the given file.
/// </summary>
/// <returns>A list of GPXTracks, each representing a collection of positions comprising a journey's path.</returns>
/// <returns>A list of <see cref="GpsTrack"/> objects, each representing a collection of positions comprising a journey's path.</returns>
public List<GpsTrack> GetAllTracks()
{
return GpsInput.GetAllTracks();
Expand All @@ -96,7 +96,7 @@ public List<GpsTrack> GetAllTracks()
/// <summary>
/// Gets user-selected journey track(s) from the given file.
/// </summary>
/// <returns>A list of GPXTrack(s) based on user selection, each representing a collection of positions comprising a journey's path</returns>
/// <returns>A list of <see cref="GpsTrack"/> object(s) based on user selection, each representing a collection of positions comprising a journey's path</returns>
public List<GpsTrack> GetSelectedTracks()
{
return GpsInput.GetSelectedTracks();
Expand Down
2 changes: 1 addition & 1 deletion SpotifyGPX/Output/OutputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Save(Formats format, string name, bool transform)
{
List<OutFile> files = new();

bool supportsMulti = AllowsMultiTrack(format); // Determine whether the desired format can hold multiple GPX tracks worth of pairs
bool supportsMulti = AllowsMultiTrack(format); // Determine whether the desired format can hold multiple GPS tracks worth of pairs

if (supportsMulti)
{
Expand Down
22 changes: 11 additions & 11 deletions SpotifyGPX/PairingsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public partial class PairingsHandler : IEnumerable<SongPoint>
/// <summary>
/// Create a handler for pairing GPS information with Song information.
/// </summary>
/// <param name="s">A series of Spotify playback records, used to associate a song with a point.</param>
/// <param name="t">A list of GPXTrack objects, used to associate songs with a track and position on Earth.</param>
/// <param name="s">A series of <see cref="ISongEntry"/> objects, used to associate a song with a point.</param>
/// <param name="t">A list of <see cref="GpsTrack"/> objects, used to associate songs with a track and position on Earth.</param>
/// <param name="name">The name of this set of pairs.</param>
/// <param name="silent">If true, do not print each pairing to the console upon creation.</param>
/// <param name="predict">If true, create a DupeHandler for predicting duplicates in the resulting pair list.</param>
Expand Down Expand Up @@ -60,19 +60,19 @@ public PairingsHandler(List<SongPoint> pairs, string name)
/// Pair songs with points (positions on Earth), by finding the closest gap of time between each.
/// </summary>
/// <param name="silent">If true, do not print each pairing to the console upon creation.</param>
/// <param name="songs">A series of Spotify playback records, used to associate a song with a point.</param>
/// <param name="tracks">A list of GPXTrack objects, used to associate songs with a track and position on Earth.</param>
/// <returns>A list of Song-Point pairs, each song and its point (on Earth), in a list.</returns>
/// <param name="songs">A series of <see cref="ISongEntry"/> song playback records, used to associate a song with a point.</param>
/// <param name="tracks">A list of <see cref="GpsTrack"/> objects, used to associate songs with a track and position on Earth.</param>
/// <returns>A list of <see cref="SongPoint"/> pairs, each song and its point (on Earth), in a list.</returns>
private static List<SongPoint> PairPoints(bool silent, List<ISongEntry> songs, List<GpsTrack> tracks)
{
// Correlate Spotify entries with the nearest GPX points
// Correlate Spotify entries with the nearest GPS points

int index = 0; // Index of the pairing

return tracks // For each GPX track
return tracks // For each GPS track
.SelectMany(track => songs // Get the list of SpotifyEntries
.Where(spotifyEntry => spotifyEntry.WithinTimeFrame(track.Start, track.End)) // If the SpotifyEntry falls within the boundaries of the track
.Select(spotifyEntry => // Select the Spotify entry if it falls in range of the GPX track
.Where(songEntry => songEntry.WithinTimeFrame(track.Start, track.End)) // If the song entry falls within the boundaries of the track
.Select(spotifyEntry => // Select the song entry if it falls in range of the GPS track
{
IGpsPoint bestPoint = track.Points
.OrderBy(point => SongPoint.DisplacementCalculatorAbs(spotifyEntry.Time, point.Time))
Expand Down Expand Up @@ -100,7 +100,7 @@ private static List<SongPoint> PairPoints(bool silent, List<ISongEntry> songs, L
public void WriteCounts()
{
WriteCounts(pair => pair.Origin, "track", "tracks"); // Write # of pairs per track
WriteCounts(pair => pair.Origin.Type, "type", "types"); // Write # of pairs in each type of track (GPX, Gap, Combined)
WriteCounts(pair => pair.Origin.Type, "type", "types"); // Write # of pairs in each type of track (Gps, Gap, Combined)
//WriteCounts(pair => pair.Song.Spotify_Country, "country", "countries"); // Write # of pairs in each country
}

Expand All @@ -126,7 +126,7 @@ private void WriteCounts<T>(Func<SongPoint, T> groupingSelector, string nameSing
/// </summary>
public void WriteAverages()
{
WriteAverages(pair => pair.Origin.Type, "track type", "track types"); // Calculate Accuracies by track type (GPX, Gap, Combined)
WriteAverages(pair => pair.Origin.Type, "track type", "track types"); // Calculate Accuracies by track type (Gps, Gap, Combined)
WriteAverages(pair => pair.Origin, "track", "tracks"); // Calculate Accuracies by track
}

Expand Down
14 changes: 7 additions & 7 deletions SpotifyGPX/SongPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public readonly string Description
}

/// <summary>
/// Create a new SongPoint pairing.
/// Create a new <see cref="SongPoint"/> pairing.
/// </summary>
/// <param name="index">The index of this SongPoint (in a created list).</param>
/// <param name="song">The SpotifyEntry (containing song data) of this pair's song.</param>
/// <param name="point">The GPXPoint (containing geospatial data) of this pair's point.</param>
/// <param name="song">The ISongEntry (containing song data) of this pair's song.</param>
/// <param name="point">The IGpsPoint (containing geospatial data) of this pair's point.</param>
/// <param name="origin">The TrackInfo (track information) about the track from which this pair was created.</param>
public SongPoint(int index, ISongEntry song, IGpsPoint point, TrackInfo origin)
{
Expand All @@ -44,10 +44,10 @@ public SongPoint(int index, ISongEntry song, IGpsPoint point, TrackInfo origin)
}

/// <summary>
/// Creates a SongPoint pairing with a new Coordinate (lat/lon), based on an existing SongPoint pairing.
/// Creates a <see cref="SongPoint"/> pairing with a new Coordinate (lat/lon), based on an existing SongPoint pairing.
/// </summary>
/// <param name="oldPair">An existing SongPoint pairing.</param>
/// <param name="newCoord">The new coordinate for this SongPoint.</param>
/// <param name="oldPair">An existing <see cref="SongPoint"/> pairing.</param>
/// <param name="newCoord">The new <see cref="Coordinate"/> for this <see cref="SongPoint"/>.</param>
/// <param name="relIndex">The index of this prediction in a set of predictions.</param>
public SongPoint(SongPoint oldPair, Coordinate newCoord, int relIndex) // Used for prediction only
{
Expand Down Expand Up @@ -142,7 +142,7 @@ public SongPoint(int index, ISongEntry song, IGpsPoint point, TrackInfo origin)
/// <returns>A single line (to be printed to the console), representing this pairing.</returns>
public override string ToString()
{
// Set both the song and point times to the UTC offset provided by the original GPX point
// Set both the song and point times to the UTC offset provided by the original GPS point
string songTime = SongTime.ToString(Options.TimeOnly);
string pointTime = PointTime.ToString(Options.TimeOnly);

Expand Down
4 changes: 2 additions & 2 deletions SpotifyGPX/TrackInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace SpotifyGPX;
/// </summary>
/// <param name="index">The index of this track (in a series of tracks).</param>
/// <param name="name">The friendly name of this track.</param>
/// <param name="type">The type of this track (GPX, Gap, or Combined).</param>
/// <param name="type">The type of this track (Gps, Gap, or Combined).</param>
public TrackInfo(int? index, string? name, TrackType type)
{
Indexx = index;
Expand Down Expand Up @@ -45,7 +45,7 @@ public TrackInfo(int? index, string? name, TrackType type)
public readonly string Name => NodeName ?? $"T{Index}";

/// <summary>
/// The type of track represented (GPX, Gap, or Combined).
/// The type of track represented (Gps, Gap, or Combined).
/// </summary>
public TrackType Type { get; }

Expand Down

0 comments on commit 7d5539c

Please sign in to comment.