Skip to content

Commit

Permalink
2024.44.1
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-techkid committed May 11, 2024
1 parent 62885e8 commit 9a2d355
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
8 changes: 7 additions & 1 deletion SpotifyGPX/Input/GeoJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class GeoJson : GpsInputBase, IDisposable
{
private JsonDocument Document { get; }
protected override ParseTracksDelegate ParseTracksMethod => ParseTracks;
protected override FilterTracksDelegate FilterTracksMethod => FilterTracks;

public GeoJson(string path) : base(path)
{
Expand Down Expand Up @@ -69,7 +70,12 @@ private List<GpsTrack> ParseTracks()
.ToList()
.AddRange(featureCollection.Features);

return featureCollection.Features.Select((feature, index) => new GpsTrack(null, null, TrackType.GPX, featureCollection.Features)).ToList();
return featureCollection.Features.Select((feature, index) => new GpsTrack(null, null, TrackType.Gps, featureCollection.Features)).ToList();
}

private List<GpsTrack> FilterTracks()
{
return AllTracks.Where(track => track.OfType<GeoJsonPoint>().All(point => filter(point))).ToList();
}

public override int SourcePointCount => 1;
Expand Down
20 changes: 13 additions & 7 deletions SpotifyGPX/Input/GpsInputBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ protected GpsInputBase(string path) : base(path)
/// </summary>
/// <returns>A list of <see cref="GpsTrack"/> objects, each <see cref="GpsTrack"/> representing a series of GPS points (<see cref="IGpsPoint"/>).</returns>
protected delegate List<GpsTrack> ParseTracksDelegate();

/// <summary>
/// A delegate providing access to all tracks within this GPS input file class, filtered according to file-specific criteria.
/// </summary>
/// <returns>A list of <see cref="GpsTrack"/> objects, each <see cref="GpsTrack"/> representing a series of GPS points (<see cref="IGpsPoint"/>).</returns>
protected delegate List<GpsTrack> FilterTracksDelegate();
protected abstract ParseTracksDelegate ParseTracksMethod { get; }

/// <summary>
/// Provides access to the tracks within this GPS input file, filtered according to file-specific criteria.
/// </summary>
protected abstract FilterTracksDelegate FilterTracksMethod { get; }
protected List<GpsTrack> AllTracks => ParseTracksMethod();
public List<GpsTrack> GetAllTracks() => AllTracks;
public List<GpsTrack> GetFilteredTracks() => FilterTracksMethod();


/// <summary>
/// Provides access to all tracks within this GPS input file.
/// </summary>
Expand All @@ -34,9 +39,10 @@ protected GpsInputBase(string path) : base(path)
/// <summary>
/// Access all tracks in this GPS data file.
/// </summary>
protected virtual List<GpsTrack> Tracks => ParseTracksMethod();
protected virtual List<GpsTrack> AllTracks => ParseTracksMethod();

public override List<GpsTrack> GetAllTracks() => Tracks;
public override List<GpsTrack> GetAllTracks() => AllTracks;
public List<GpsTrack> GetFilteredTracks() => FilterTracksMethod();
public abstract int SourceTrackCount { get; }
public int ParsedTrackCount => AllTracks.Count;
public abstract int SourcePointCount { get; }
Expand Down
3 changes: 1 addition & 2 deletions SpotifyGPX/Input/PairInputBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ public virtual List<ISongEntry> GetFilteredSongs(List<GpsTrack> gpsTracks)
protected delegate List<GpsTrack> FilterTracksDelegate();
protected abstract FilterTracksDelegate FilterTracksMethod { get; }
protected List<GpsTrack> AllTracks => AllPairs.GroupBy(pair => pair.Origin).Select(type => new GpsTrack(type.Key.Index, type.Key.Name, type.Key.Type, type.Select(pair => pair.Point).ToList())).ToList();
public List<GpsTrack> GetAllTracks() => AllTracks;
public override List<GpsTrack> GetAllTracks() => AllTracks;
public List<GpsTrack> GetFilteredTracks() => FilterTracksMethod();
public override List<GpsTrack> GetAllTracks() => AllPairs.GroupBy(pair => pair.Origin).Select(type => new GpsTrack(type.Key.Index, type.Key.Name, type.Key.Type, type.Select(pair => pair.Point).ToList())).ToList();
public abstract int SourcePointCount { get; }
public int ParsedPointCount => AllPairs.Select(pair => pair.Point).Count();
public abstract int SourceTrackCount { get; }
Expand Down
2 changes: 1 addition & 1 deletion SpotifyGPX/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public partial class Csv

public partial class GeoJson
{
private static JsonSerializerOptions JsonOptions => Options.JsonOptions;
private static readonly Func<GeoJsonPoint, bool> filter = point => true; // No filtering
}

public partial class Gpx
Expand Down

0 comments on commit 9a2d355

Please sign in to comment.