|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.wisc.ssec.mcidas.McIDASUtil
public final class McIDASUtil
Class for static McIDAS utility methods. In many cases, these methods are the Java equivalents of McIDAS library functions.
Field Summary | |
---|---|
static int |
MCMISSING
McIDAS missing value for 4-byte integers |
Constructor Summary | |
---|---|
McIDASUtil()
|
Method Summary | |
---|---|
static int |
bytesToInteger(byte[] b,
int off)
convert four consequtive bytes into a (signed) int. |
static int[] |
bytesToIntegerArray(byte[] b,
int off,
int num)
convert consecutive bytes into a (signed) int array. |
static int |
doubleLatLonToInteger(double dvalue)
Converts a double latitude/longitude to a packed integer (SIGN DDD MM SS) Java version of McIDAS ilalo function. |
static void |
flip(int[] array,
int first,
int last)
Flip the bytes of an integer array. |
static AreaFile |
getAreaFile(String filename)
De-serialize an AreaFile object from disk |
static String |
intBitsToString(int value)
convert signed int to a String representation. |
static String |
intBitsToString(int[] values)
convert signed int array to a String representation. |
static double |
integerLatLonToDouble(int value)
Converts a packed integer (SIGN DDD MM SS) latitude/longitude to double. |
static boolean |
isChar(int value)
Check to see if the int value is the representation of a string or not. |
static GregorianCalendar |
makeCalendarForDayTimeToSecs()
Create a calendar to be used for mcDayTimeToSecs. |
static long |
mcDateHmsToSecs(int date,
int time)
Convert date (yymmdd or yyyymmdd) and hms (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT). |
static long |
mcDayTimeToSecs(int yearday,
int time)
Convert day (yyddd or yyyyddd) and time (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT). |
static long |
mcDayTimeToSecs(int yearday,
int time,
GregorianCalendar cal)
Convert day (yyddd or yyyyddd) and time (hhmmss) to seconds since the epoch (January 1, 1970, 00:00GMT). |
static int |
mcDoubleToPackedInteger(double dvalue)
Converts a double latitude/longitude or time (hours) to a packed integer (SIGN DDD/HH MM SS). |
static String |
mcHmsToStr(int hms)
Convert an HMS integer to a string of form hh:mm:ss. |
static double |
mcPackedIntegerToDouble(int value)
Converts a packed integer (SIGN DDD/HH MM SS) latitude/longitude or time (hours) to double. |
static int[] |
mcSecsToDayTime(long secs)
Convert seconds since the epoch (January 1, 1970, 00:00GMT) to day (yyyyddd) and time (hhmmss). |
static String |
padLeft(String s,
int desiredLength,
String padString)
Pad the given string with padString on the left up to the given length. |
static String |
padZero(int value,
int numDigits)
Left pad the given value with zeros up to the number of digits |
static boolean |
putAreaFile(String filename,
AreaFile af)
Serialize an AreaFile object to disk |
static int |
swbyt4(int val)
Flip the bytes of an integer. |
static void |
swbyt4(int[] array,
int first,
int num)
Flip the bytes of an integer array. |
static double |
timdif(int yrday1,
int hms1,
int yrday2,
int hms2)
Calculate difference in minutes between two dates/times. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MCMISSING
Constructor Detail |
---|
public McIDASUtil()
Method Detail |
---|
public static double integerLatLonToDouble(int value)
flalo
function except returns a
double instead of a float.
value
- integer containing the packed data
public static int doubleLatLonToInteger(double dvalue)
ilalo
function.
dvalue
- double value of lat/lon
public static double mcPackedIntegerToDouble(int value)
flalo
and ftime
functions except returns a double instead of a float.
value
- integer containing the packed data
public static int mcDoubleToPackedInteger(double dvalue)
ilalo
and m0itime
functions.
dvalue
- double value of lat/lon or time
public static double timdif(int yrday1, int hms1, int yrday2, int hms2)
yrday1
- Year/day of first time (yyddd or yyyyddd)hms1
- Hours/minutes/seconds of first time (hhmmss).yrday2
- Year/day of second time (yyddd).hms2
- Hours/minutes/seconds of second time (hhmmss).
public static GregorianCalendar makeCalendarForDayTimeToSecs()
public static long mcDayTimeToSecs(int yearday, int time)
yearday
- year/day in either yyddd or yyyyddd format.
Only works for years > 1900.time
- time in packed integer format (hhmmss)
public static long mcDayTimeToSecs(int yearday, int time, GregorianCalendar cal)
yearday
- year/day in either yyddd or yyyyddd format.
Only works for years > 1900.time
- time in packed integer format (hhmmss)cal
- If non-null then use this calendar to do the formatting.
else create a new one. Note: The calendar you pass in should be
one created from makeCalendarForDayTimeToSecs
public static long mcDateHmsToSecs(int date, int time)
date
- year/day in yyymmdd format.
Only works for years > 1900.time
- time in packed integer format (hhmmss)
public static int[] mcSecsToDayTime(long secs)
secs
- seconds since the epoch
public static String mcHmsToStr(int hms)
hms
- integer hhmmss
public static String padZero(int value, int numDigits)
value
- The value.numDigits
- number of digits
public static String padLeft(String s, int desiredLength, String padString)
s
- String to paddesiredLength
- ending lengthpadString
- String to pad with (e.g, " ")
public static int swbyt4(int val)
val
- value to swap
public static void swbyt4(int[] array, int first, int num)
array
- array of integers to be flippedfirst
- starting element of the arraynum
- number of values to swappublic static void flip(int[] array, int first, int last)
array
- array of integers to be flippedfirst
- starting element of the arraylast
- last element of array to flippublic static int bytesToInteger(byte[] b, int off)
b
- array of 4 bytesoff
- is the offset into the byte array
public static int[] bytesToIntegerArray(byte[] b, int off, int num)
b
- array of bytesoff
- is the offset into the byte arraynum
- number of integers to create
public static String intBitsToString(int value)
value
- - integer representation of a string
public static String intBitsToString(int[] values)
values
- - integer array representation of a string
public static boolean isChar(int value)
value
- integer representation
public static boolean putAreaFile(String filename, AreaFile af)
filename
- - name of disk file to write toaf
-
public static AreaFile getAreaFile(String filename)
filename
- - name of disk file to read
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |