Skip to content

Commit

Permalink
Implement pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Keller253 committed Feb 13, 2024
1 parent f8959cb commit 12dfa73
Show file tree
Hide file tree
Showing 16 changed files with 681 additions and 504 deletions.
13 changes: 8 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ insert_final_newline = false
[*.{cs,vb}]

# Organize usings
dotnet_separate_import_directive_groups = true
dotnet_separate_import_directive_groups = false:suggestion
dotnet_sort_system_directives_first = true
file_header_template = unset

Expand Down Expand Up @@ -84,9 +84,9 @@ dotnet_remove_unnecessary_suppression_exclusions = none
[*.cs]

# var preferences
csharp_style_var_elsewhere = true:silent
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion

# Expression-bodied members
csharp_style_expression_bodied_accessors = true:silent
Expand Down Expand Up @@ -128,7 +128,10 @@ csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent

# 'using' directive preferences
csharp_using_directive_placement = outside_namespace:silent
csharp_using_directive_placement = outside_namespace:suggestion

# Namespace preferences
csharp_style_namespace_declarations=file_scoped:suggestion

#### C# Formatting Rules ####

Expand Down
66 changes: 36 additions & 30 deletions src/CyclingApp/Models/Activity.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
namespace CyclingApp.Models
namespace CyclingApp.Models;

/// <summary>
/// A cycling activity.
/// </summary>
public class Activity
{
public class Activity
{
public Guid Id { get; }
/// <summary>
/// Unique identifier of the activity.
/// </summary>
public Guid Id { get; }

/// <summary>
/// Creation time of the acitivity.
/// </summary>
public DateTime CreationTime { get; }
/// <summary>
/// Creation time of the activity.
/// </summary>
public DateTime CreationTime { get; }

/// <summary>
/// Duration of the acitivity.
/// </summary>
public TimeSpan Duration { get; }
/// <summary>
/// Duration of the activity.
/// </summary>
public TimeSpan Duration { get; }

/// <summary>
/// Route of the activity.
/// </summary>
public ReadOnlyRoute Route { get; }
/// <summary>
/// Route of the activity.
/// </summary>
public ReadOnlyRoute Route { get; }

/// <summary>
/// Average speed during the activity in kilometers per hour.
/// </summary>
public double AvgSpeed { get; }
/// <summary>
/// Average speed during the activity in kilometers per hour.
/// </summary>
public double AvgSpeed { get; }

/// <summary>
/// Initializes a new instance of <see cref="Activity"/> class.
/// </summary>
public Activity(Guid id, DateTime creationTime, TimeSpan duration, ReadOnlyRoute route)
{
Id = id;
CreationTime = creationTime;
Duration = duration;
Route = route;
}
/// <summary>
/// Initializes a new instance of <see cref="Activity"/> class.
/// </summary>
public Activity(Guid id, DateTime creationTime, TimeSpan duration, ReadOnlyRoute route)
{
Id = id;
CreationTime = creationTime;
Duration = duration;
Route = route;
AvgSpeed = route.CalculateAvgSpeed(Duration);
}
}
131 changes: 65 additions & 66 deletions src/CyclingApp/Models/GeoLocation.cs
Original file line number Diff line number Diff line change
@@ -1,79 +1,78 @@
namespace CyclingApp.Models
namespace CyclingApp.Models;

/// <summary>
/// Position and altitude on earth.
/// </summary>
public class GeoLocation
{
/// <summary>
/// Position and altitude on earth.
/// Longitude in decimal degrees.
/// </summary>
public class GeoLocation
{
/// <summary>
/// Longitude in decimal degrees.
/// </summary>
public double Longitude { get; }
public double Longitude { get; }

/// <summary>
/// Latitude in decimal degrees.
/// </summary>
public double Latitude { get; }
/// <summary>
/// Latitude in decimal degrees.
/// </summary>
public double Latitude { get; }

/// <summary>
/// Accuracy of the <see cref="Latitude"/> and <see cref="Longitude"/> properties, expressed in meters.
/// </summary>
public double Accuracy { get; }
/// <summary>
/// Accuracy of the <see cref="Latitude"/> and <see cref="Longitude"/> properties, expressed in meters.
/// </summary>
public double Accuracy { get; }

/// <summary>
/// Altitude in meters, relative to nominal sea level.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the location source cannot provide the data.
/// </value>
public double? Altitude { get; }
/// <summary>
/// Altitude in meters, relative to nominal sea level.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the location source cannot provide the data.
/// </value>
public double? Altitude { get; }

/// <summary>
/// Accuracy of the altitude expressed in meters.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the original data source cannot provide the data.
/// </value>
public double? AltitudeAccuracy { get; }
/// <summary>
/// Accuracy of the altitude expressed in meters.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the original data source cannot provide the data.
/// </value>
public double? AltitudeAccuracy { get; }

/// <summary>
/// Direction towards which the device is facing. This value, specified in degrees, indicates how far off from
/// heading true north the device is. 0 degrees represents true north, and the direction is determined clockwise
/// (which means that east is 90 degrees and west is 270 degrees). If speed is 0, <see cref="Heading"/> is
/// <see cref="double.NaN"/>.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the original data source cannot provide the data.
/// </value>
public double? Heading { get; }
/// <summary>
/// Direction towards which the device is facing. This value, specified in degrees, indicates how far off from
/// heading true north the device is. 0 degrees represents true north, and the direction is determined clockwise
/// (which means that east is 90 degrees and west is 270 degrees). If speed is 0, <see cref="Heading"/> is
/// <see cref="double.NaN"/>.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the original data source cannot provide the data.
/// </value>
public double? Heading { get; }

/// <summary>
/// Velocity of the device in meters per second.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the original data source cannot provide the data.
/// </value>
public double? Speed { get; }
/// <summary>
/// Velocity of the device in meters per second.
/// </summary>
/// <value>
/// Can be <see langword="null"/> if the original data source cannot provide the data.
/// </value>
public double? Speed { get; }

/// <summary>
/// Time at which the location was retrieved.
/// </summary>
public DateTime Timestamp { get; }
/// <summary>
/// Time at which the location was retrieved.
/// </summary>
public DateTime Timestamp { get; }

/// <summary>
/// Initializes a new instance of <see cref="GeoLocation"/> class.
/// </summary>
public GeoLocation(DateTime timestamp, double longitude, double latitude, double accuracy,
double? altitude, double? altitudeAccuracy, double? heading, double? speed)
{
Timestamp = timestamp;
Longitude = longitude;
Latitude = latitude;
Accuracy = accuracy;
Altitude = altitude;
AltitudeAccuracy = altitudeAccuracy;
Heading = heading;
Speed = speed;
}
/// <summary>
/// Initializes a new instance of <see cref="GeoLocation"/> class.
/// </summary>
public GeoLocation(DateTime timestamp, double longitude, double latitude, double accuracy,
double? altitude, double? altitudeAccuracy, double? heading, double? speed)
{
Timestamp = timestamp;
Longitude = longitude;
Latitude = latitude;
Accuracy = accuracy;
Altitude = altitude;
AltitudeAccuracy = altitudeAccuracy;
Heading = heading;
Speed = speed;
}
}
17 changes: 8 additions & 9 deletions src/CyclingApp/Models/ReadOnlyRoute.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace CyclingApp.Models
{
/// <summary>
/// A read-only route.
/// </summary>
/// <param name="waypoints">The waypoints of the route.</param>
public class ReadOnlyRoute(IList<GeoLocation> waypoints) : RouteBase(waypoints)
{ }
}
namespace CyclingApp.Models;

/// <summary>
/// A read-only route.
/// </summary>
/// <param name="waypoints">The waypoints of the route.</param>
public class ReadOnlyRoute(IList<GeoLocation> waypoints) : RouteBase(waypoints)
{ }
37 changes: 18 additions & 19 deletions src/CyclingApp/Models/Route.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
namespace CyclingApp.Models
namespace CyclingApp.Models;

/// <summary>
/// An editable route.
/// </summary>
public class Route() : RouteBase([])
{
/// <summary>
/// An editable route.
/// Add a waypoint to the route.
/// </summary>
public class Route() : RouteBase([])
/// <param name="waypoint">The waypoint to add.</param>
public new void AddWaypoint(GeoLocation waypoint)
{
/// <summary>
/// Add a waypoint to the route.
/// </summary>
/// <param name="waypoint">The waypoint to add.</param>
public new void AddWaypoint(GeoLocation waypoint)
{
base.AddWaypoint(waypoint);
}
base.AddWaypoint(waypoint);
}

/// <summary>
/// Remove waypoint from the route.
/// </summary>
/// <param name="waypoint">The waypoint to remove.</param>
public new void RemoveWaypoint(GeoLocation waypoint)
{
base.RemoveWaypoint(waypoint);
}
/// <summary>
/// Remove waypoint from the route.
/// </summary>
/// <param name="waypoint">The waypoint to remove.</param>
public new void RemoveWaypoint(GeoLocation waypoint)
{
base.RemoveWaypoint(waypoint);
}
}
Loading

0 comments on commit 12dfa73

Please sign in to comment.