|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectuavsim.windmodel.WindVelocityCell
public class WindVelocityCell
This class defines a lookup table for a simple encoding that provides approximate wind velocity in knots through linear interpolation on discrete altitude planes within a three-dimensional cell in the world. A cell is defined as a square with the size of one degree of latitude in our flat-earth world model. Its bottom-right corner anchors to the world by the degree component of a latitude and longitude. Six stacked altitude planes define the velocities at 0, 3000, 6000, 9000, 12000 feet, and 15000 feet. Altitudes outside this range clamp to the limits.
The definition resides in a separate text file for each cell. The format is as follows, where each dot grid is an altitude plane left to right in the order indicated above. Rows are latitude, and columns are longitude, both on six-minute intervals offset from the anchor. For simplicity, the navigation model is limited to the northern, western hemisphere, which means latitude is always degrees north and increases upward, and longitude is always degrees west and increases leftward.
latitude_degrees,longitude_degrees
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
............ ............ ............ ............ ............ ............
A dot indicates no wind. The encoding for the other discrete wind velocities is a single character that takes the place of a dot. It is a two-phase encoding that combines both the direction and speed. The direction component is based on the eight cardinal and intercardinal directions with the following base characters:
Char Direction ---- --------- a 0 f 45 k 90 p 135 u 180 z 225 E 270 J 315The speed component is alphabetically derived from the base character, which itself indicates 10 knots in the specified direction. Adding 1 to the character (e.g., a+1=b) indicates 20 knots, whereas 2 is 30, 3 is 40, and 4 is 50. The complete encoding table is as follows:
Char Direction Speed Char Direction Speed ---- --------- ----- ---- --------- ----- . 0 0 a 0 10 u 180 10 b 0 20 v 180 20 c 0 30 w 180 30 d 0 40 x 180 40 e 0 50 y 180 50
f 45 10 z 225 10 g 45 20 A 225 20 h 45 30 B 225 30 i 45 40 C 225 40 j 45 50 D 225 50
k 90 10 E 270 10 l 90 20 F 270 20 m 90 30 G 270 30 n 90 40 H 270 40 o 90 50 I 270 50
p 135 10 J 315 10 q 135 20 K 315 20 r 135 30 L 315 30 s 135 40 M 315 40 t 135 50 N 315 50
| Nested Class Summary | |
|---|---|
private class |
WindVelocityCell.SubcellIndex
Defines a data wrapper for the row, column, and plane indices into the cell. |
| Field Summary | |
|---|---|
private CoordinateWorld |
_cellAnchor
the bottom-right cell coordinate in degrees latitude and longitude. |
private java.lang.String |
_filename
the fully qualified filename of the cell definition |
private Velocity[][][] |
_subcells
the subcell grid, as minutes of latitude, minutes of longitude, and altitude |
private static int[] |
ALTITUDES
the altitude planes in feet |
private static int |
CELL_SIZE_HORIZONTAL
the horizontal size of the square cell, where each subcell corresponds to six degrees of latitude and latitude |
private static int |
CELL_SIZE_VERTICAL
the vertical size of the cell, where the altitude layers are 0, 3000, 6000, 9000, 12000, and 15000 feet |
private static char |
ENCODING_NO_WIND
the velocity encoding for no wind |
private static java.lang.String |
ENCODING_WIND
the velocity encoding for wind |
private static int |
MINUTES_PER_SUBCELL
the span in latitude and longitude minutes represented by each subcell |
private static int[] |
WIND_RATES
the wind rates corresponding to base encoding plus 0, 1, 2, 3, and 4, respectively |
| Constructor Summary | |
|---|---|
WindVelocityCell(java.lang.String filename)
Creates a wind-velocity cell. |
|
| Method Summary | |
|---|---|
private Scaler |
calculateScaler(A_LatitudeLongitude<?> latitudeOrLongitude)
Calculates the scaler between the two nearest latitude or longitude samples. |
private Scaler |
calculateScaler(Altitude altitude)
Calculates the scaler between the two nearest altitude samples. |
private Velocity |
decodeVelocity(char encoding)
Decodes a character encoding into a velocity. |
java.lang.StringBuilder |
dump()
Generates a tabular representation of the wind definition, where the first value is direction in navigational degrees and the second speed in knots. |
CoordinateWorld |
getCellAnchor()
Gets the bottom-right anchor coordinate of this cell. |
java.lang.String |
getCellFilename()
Gets the fully qualified filename of the definition file for this cell. |
Velocity |
interpolate(CoordinateWorld3D coordinate)
Esimates the wind velocity at a coordinate through three-dimension linear interpolation. |
private Velocity |
interpolatePlane(CoordinateWorld3D coordinate,
boolean isPlaneBelowOrAbovecoordinate)
Interpolates a coordinate by interpolating longitude at a latitude above and below a coordinate, then interpolating a latitude between these two results. |
private Velocity |
interpolateVelocity(Velocity velocity1,
Velocity velocity2,
Scaler scaler)
Interpolates between two velocities. |
private void |
loadCellDefinition()
Loads the cell definition from a file. |
private void |
loadCellDefinitionAnchor(java.io.BufferedReader infile)
Loads the anchor component of the cell definition. |
private void |
loadCellDefinitionBody(java.io.BufferedReader infile)
Loads the body component of the cell definition. |
private int |
mapPlaneIndex(Altitude altitude)
Determines which altitude plane on the supported interval lies below an altitude. |
private int |
mapRowColumnIndex(A_LatitudeLongitude<?> latitudeOrLongitude)
Determines the row or column index in the subcell grid based on the minutes component of a latitude or longitude, respectively. |
private WindVelocityCell.SubcellIndex |
mapSubcellIndex(CoordinateWorld3D coordinate)
Calculates the three-dimensional index in the subcell grid based on a coordinate with altitude. |
java.lang.String |
toString()
Returns a text representation of this object with the cell anchor and definition filename. |
private void |
validateCoordinate(CoordinateWorld coordinate)
Validates that a coordinate resides on this cell. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private CoordinateWorld _cellAnchor
private final java.lang.String _filename
private final Velocity[][][] _subcells
private static final int[] ALTITUDES
private static final int CELL_SIZE_HORIZONTAL
private static final int CELL_SIZE_VERTICAL
private static final char ENCODING_NO_WIND
private static final java.lang.String ENCODING_WIND
private static final int MINUTES_PER_SUBCELL
private static final int[] WIND_RATES
| Constructor Detail |
|---|
public WindVelocityCell(java.lang.String filename)
throws java.io.IOException
filename - - the fully qualified filename of the cell definition
java.io.IOException - for any file error| Method Detail |
|---|
private Scaler calculateScaler(A_LatitudeLongitude<?> latitudeOrLongitude)
latitudeOrLongitude - - the latitude or longitude
private Scaler calculateScaler(Altitude altitude)
altitude - - the altitude
private Velocity decodeVelocity(char encoding)
encoding - - the encoding
public java.lang.StringBuilder dump()
public CoordinateWorld getCellAnchor()
public java.lang.String getCellFilename()
public Velocity interpolate(CoordinateWorld3D coordinate)
throws UnsupportedCoordinateException
coordinate - - the coordinate
UnsupportedCoordinateException - if the coordinate is not on this cell
private Velocity interpolatePlane(CoordinateWorld3D coordinate,
boolean isPlaneBelowOrAbovecoordinate)
coordinate - - the coordinateisPlaneBelowOrAbovecoordinate - - whether to use the altitude plane below or above the coordinate
private Velocity interpolateVelocity(Velocity velocity1,
Velocity velocity2,
Scaler scaler)
velocity1 - - the first velocityvelocity2 - - the second velocityscaler - - the scaler between the velocities
private void loadCellDefinition()
throws java.io.IOException
java.io.IOException - for any file error
private void loadCellDefinitionAnchor(java.io.BufferedReader infile)
throws java.io.IOException
infile - - the input file
java.io.IOException - for any file error
private void loadCellDefinitionBody(java.io.BufferedReader infile)
throws java.io.IOException
infile - - the input file
java.io.IOException - for any file errorprivate int mapPlaneIndex(Altitude altitude)
altitude - - the altitude
private int mapRowColumnIndex(A_LatitudeLongitude<?> latitudeOrLongitude)
latitudeOrLongitude - - the latitude or longitude
private WindVelocityCell.SubcellIndex mapSubcellIndex(CoordinateWorld3D coordinate)
coordinate - - the coordinate
public java.lang.String toString()
toString in class java.lang.Object
private void validateCoordinate(CoordinateWorld coordinate)
throws UnsupportedCoordinateException
coordinate - - the coordinate
UnsupportedCoordinateException - if the coordinate is not on this cell
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||