using System;
using System.Collections.Generic;

namespace skyscraper5.Skyscraper.Gps
{
	public class AdditionalNmeaData
	{
		public AdditionalNmeaData()
		{

		}

		#region GPVTG

		public double? CourseMagnetic { get; set; }
		public double? CourseTrue { get; set; }
		public double? SpeedKnots { get; set; }
		public double? SpeedKph { get; set; }

		#endregion

		#region GPZDA

		public DateTimeOffset? FixDateTime { get; set; }

		#endregion

		#region GPGGA

		public string Quality { get; set; }
		public double? Altitude { get; set; }
		public string AltitudeUnits { get; set; }
		public int? DpgsStationId { get; set; }
		public TimeSpan? FixTime { get; set; }
		public double? GeoidalSeparation { get; set; }
		public string GeoidalSeparationUnits { get; set; }
		public double? Hdop { get; set; }
		public int? NumberOfSatellites { get; set; }
		public TimeSpan? TimeSinceLastDgpsUpdate { get; set; }

		#endregion

		#region GPGSA

		public string Fix { get; set; }
		public string Mode { get; set; }
		public double? Pdop { get; set; }
		public int[] SatelliteIDs { get; set; }
		public double? Vdop { get; set; }

		#endregion

		#region GPGLL

		public string ModeIndicator { get; set; }
		public bool? DataActive { get; set; }

		#endregion

		#region GPRMC

		public bool? Active { get; set; }
		public double? MagneticVariation { get; set; }

		#endregion

		#region GPGSV

		public char? GnssSignalId { get; set; }
		public int? SatellitesInView { get; set; }

		public void AddSatellite(int vehicleId, char vehicleGnssSignalId, double vehicleAzimuth,
			double vehicleElevation, int vehicleSignalToNoiseRatio, string system, string talkerId)
		{
			GpsSatellite satellite = new GpsSatellite(vehicleId, vehicleGnssSignalId, vehicleAzimuth, vehicleElevation,
				vehicleSignalToNoiseRatio, system, talkerId);
			if (satellites == null)
				satellites = new HashSet<GpsSatellite>();
			satellites.Add(satellite);
		}

		private HashSet<GpsSatellite> satellites;

		public IReadOnlyCollection<GpsSatellite> Satellites
		{
			get
			{
				if (satellites == null)
					return null;
				return satellites;
			}
		}
		#endregion

		#region GPGBS

		public double? LatitudeError { get; set; }
		public double? LongitudeError { get; set; }
		public double? AltitudeError { get; set; }
		public int? SatelliteId { get; set; }
		public double? MissedDetectionProbability { get; set; }
		public double? BiasEstimate { get; set; }
		public double? StandardDeviation { get; set; }
		#endregion
	}
}
