Skip to content

Commit

Permalink
Added comments to new GeoCoding Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
racerxdl committed Apr 30, 2017
1 parent dafa7ae commit ac962f9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
21 changes: 21 additions & 0 deletions XRIT/Geo/GeoConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;

namespace OpenSatelliteProject.Geo {
/// <summary>
/// Class to convert Pixels to LatLon or the inverse using LRIT Geolocation Parameters
/// </summary>
public class GeoConverter {
private int coff;
private int loff;
Expand Down Expand Up @@ -48,6 +51,14 @@ public float MinLongitude {
}
}

/// <summary>
/// Initializes a new instance of the <see cref="OpenSatelliteProject.Geo.GeoConverter"/> class.
/// </summary>
/// <param name="satelliteLongitude">Satellite longitude.</param>
/// <param name="coff">Column Offset</param>
/// <param name="loff">Line Offset</param>
/// <param name="cfac">Column Scaling Factor</param>
/// <param name="lfac">Line Scaling Factor</param>
public GeoConverter(float satelliteLongitude, int coff, int loff, float cfac, float lfac) {
this.satelliteLongitude = satelliteLongitude;
this.coff = coff;
Expand All @@ -56,10 +67,20 @@ public GeoConverter(float satelliteLongitude, int coff, int loff, float cfac, fl
this.lfac = lfac;
}

/// <summary>
/// Converts Latitude/Longitude to Pixel X/Y
/// </summary>
/// <param name="lat">Latitude in Degrees</param>
/// <param name="lon">Longitude in Degrees</param>
public Tuple<int, int> latlon2xy(float lat, float lon) {
return GeoTools.lonlat2xy(satelliteLongitude, GeoTools.deg2rad(lon), GeoTools.deg2rad(lat), coff, cfac, loff, lfac);
}

/// <summary>
/// Converts Pixel X/Y to Latitude/Longitude
/// </summary>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
public Tuple<float, float> xy2latlon(int x, int y) {
var radCoord = GeoTools.xy2lonlat(satelliteLongitude, x, y, coff, cfac, loff, lfac);
return new Tuple<float, float>(GeoTools.rad2deg(radCoord.Item1), GeoTools.rad2deg(radCoord.Item2));
Expand Down
20 changes: 20 additions & 0 deletions XRIT/Geo/GeoTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public static float rad2deg(float rad) {
return (float) (rad * 180 / Math.PI);
}

/// <summary>
/// Converts Latitude/Longitude to Pixel X/Y on image
/// </summary>
/// <param name="satLongitude">Satellite Longitude</param>
/// <param name="lon">Longitude in Radians</param>
/// <param name="lat">Latitude in Radians</param>
/// <param name="coff">Column Offset</param>
/// <param name="cfac">Column Scaling Factor</param>
/// <param name="loff">Line Offset</param>
/// <param name="lfac">Line Scaling Factor</param>
public static Tuple<int, int> lonlat2xy(float satLongitude, float lon, float lat, int coff, float cfac, int loff, float lfac) {
var sub_lon = deg2rad(satLongitude);
var rep = (radiusPoles * radiusPoles) / (radiusEquator * radiusEquator);
Expand All @@ -50,6 +60,16 @@ public static Tuple<int, int> lonlat2xy(float satLongitude, float lon, float lat
return new Tuple<int, int>(c, l);
}

/// <summary>
/// Converts Pixel X/Y to Latitude / Longitude
/// </summary>
/// <param name="satelliteLon">Satellite Longitude</param>
/// <param name="c">Column (X)</param>
/// <param name="l">Line (Y)</param>
/// <param name="coff">Column Offset</param>
/// <param name="cfac">Column Scaling Factor</param>
/// <param name="loff">Line Offset</param>
/// <param name="lfac">Line Scaling Factor</param>
public static Tuple<float, float> xy2lonlat(float satelliteLon, int c, int l, int coff, float cfac, int loff, float lfac) {
var q2 = (radiusEquator * radiusEquator) / (radiusPoles * radiusPoles);
var d2 = vehicleDistance * vehicleDistance - radiusEquator * radiusEquator;
Expand Down
12 changes: 12 additions & 0 deletions XRIT/Geo/MapDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
using System.Drawing;

namespace OpenSatelliteProject.Geo {
/// <summary>
/// Map Drawer Class
/// You can get ShapeFiles from: http://www.naturalearthdata.com
/// Just load the .shp file
/// </summary>
public class MapDrawer {
private Shapefile shapeFile;

Expand All @@ -14,6 +19,13 @@ public MapDrawer(string shapeFile) {
shapeFile.Close();
}

/// <summary>
/// Draws the Map using the loaded Shapefile on bitmap.
/// </summary>
/// <param name="bmp">Bitmap to be draw</param>
/// <param name="gc">Initialized GeoConverter</param>
/// <param name="color">Color of the lines</param>
/// <param name="lineWidth">Thickness of the Lines</param>
public void DrawMap(ref Bitmap bmp, GeoConverter gc, Color color, int lineWidth = 5) {
Pen pen = new Pen(color, lineWidth);
float lastX = -1;
Expand Down

0 comments on commit ac962f9

Please sign in to comment.