Skip to content

Commit

Permalink
Merge pull request #19 from netnspace/master
Browse files Browse the repository at this point in the history
Fix dateTime bug
  • Loading branch information
1manprojects authored Jan 10, 2020
2 parents 4161636 + 777d8fb commit 4867e92
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion OneSGP4_Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void Main(string[] args)
sgp4Propagator.runSgp4Cal(startTime, stopTime, 1 / 30.0); // 1/60 => caclulate sat points every 2 seconds
List<One_Sgp4.Sgp4Data> resultDataList = new List<Sgp4Data>();
//Return Results containing satellite Position x,y,z (ECI-Coordinates in Km) and Velocity x_d, y_d, z_d (ECI-Coordinates km/s)
resultDataList = sgp4Propagator.getRestults();
resultDataList = sgp4Propagator.getResults();

startTime = new EpochTime(DateTime.Now);
//Coordinate of an observer on Ground lat, long, height(in meters)
Expand Down
4 changes: 2 additions & 2 deletions One_Sgp4/SatFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static Point3d calcSphericalCoordinate(Coordinate coordinate,
r.y = satPosData.getY() - groundLocation.y;
r.z = satPosData.getZ() - groundLocation.z;

double r_lat = coordinate.getLatetude() * toRadians;
double r_lat = coordinate.getLatitude() * toRadians;

double sin_lat = Math.Sin(r_lat);
double cos_lat = Math.Cos(r_lat);
Expand Down Expand Up @@ -226,7 +226,7 @@ public static Sgp4Data getSatPositionAtTime(Tle satellite, EpochTime atTime, Sgp
{
Sgp4 sgp4Propagator = new Sgp4(satellite, wgs);
sgp4Propagator.runSgp4Cal(atTime, atTime, 1 / 60.0);
return sgp4Propagator.getRestults()[0];
return sgp4Propagator.getResults()[0];
}

//! Calculate Passes of a satellite for ceratin number of days from a starting time
Expand Down
14 changes: 7 additions & 7 deletions One_Sgp4/ground/Coordinate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Coordinate
public const double toDegrees = 180.0 / pi; //!< double constant conversion to degree
public const double toRadians = pi / 180.0; //!< double constant converstion to radians

private double latetude; //!< double Latetude in degree
private double latitude; //!< double Latetude in degree
private double longitude; //!< double longitude in degree
private double height; //!< double height in meters

Expand All @@ -43,10 +43,10 @@ public class Coordinate
\param double longitude
\param double hight default 0.0
*/
public Coordinate(double _latetude, double _longitude,
public Coordinate(double _latitude, double _longitude,
double _height = 0.0)
{
latetude = _latetude;
latitude = _latitude;
longitude = _longitude;
height = _height;
}
Expand All @@ -57,7 +57,7 @@ public Coordinate(double _latetude, double _longitude,
*/
public string toString()
{
string ret = "Lat: " + latetude +
string ret = "Lat: " + latitude +
" Long: " + longitude +
" Height: " + height;
return ret;
Expand All @@ -67,9 +67,9 @@ public string toString()
/*!
\return double Latetude
*/
public double getLatetude()
public double getLatitude()
{
return latetude;
return latitude;
}

//! Returns the Longitude
Expand Down Expand Up @@ -106,7 +106,7 @@ public Point3d toECI(double siderealTime, Sgp4.wgsConstant wgs = Sgp4.wgsConstan
a = WGS_84.radiusEarthKM;
}
double srt = siderealTime + (toRadians * longitude);
double lat_rad = toRadians * latetude;
double lat_rad = toRadians * latitude;
Point3d eciPos = new Point3d();
//oblate earth
double c = 1.0 / (Math.Sqrt(1.0 + f * (f - 2.0) *
Expand Down
2 changes: 1 addition & 1 deletion One_Sgp4/sgp/Sgp4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ private double modfunc(double x, double y)
return 0;
}

public List<Sgp4Data> getRestults()
public List<Sgp4Data> getResults()
{
return resultOrbitData;
}
Expand Down
2 changes: 1 addition & 1 deletion One_Sgp4/sgp/Sgp4Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public int getSatNumber()
/*!
\return double x, y, z;
*/
public Point3d getPositonData()
public Point3d getPositionData()
{
return pos;
}
Expand Down
3 changes: 2 additions & 1 deletion One_Sgp4/time/EpochTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ public DateTime toDateTime()
dayToDate(year, epoch);
DateTime date = new DateTime(year, month, day, hour, minutes, Convert.ToInt32(Math.Floor(seconds)));
date = date.AddMilliseconds((seconds - Math.Floor(seconds))*1000);
return date;
var newDate = DateTime.SpecifyKind(date, DateTimeKind.Utc);
return newDate;
}

//! Returns the Date and Time in JulianDate
Expand Down
4 changes: 2 additions & 2 deletions Test/SatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public void TestSatGroundPosition(int hh, int mm, int ss, int yyyy, int MM, int
Assert.Greater(ground.getHeight(), 0);
Assert.LessOrEqual(ground.getLongitude(), 180.0);
Assert.Greater(ground.getLongitude(), -180.0);
Assert.LessOrEqual(ground.getLatetude(), 90.0);
Assert.Greater(ground.getLatetude(), -90.0);
Assert.LessOrEqual(ground.getLatitude(), 90.0);
Assert.Greater(ground.getLatitude(), -90.0);

}

Expand Down

0 comments on commit 4867e92

Please sign in to comment.