gvsig-projects-pool / org.gvsig.lidar.prov / org.gvsig.lidar.prov.common / src / main / java / org / gvsig / lidar / prov / ConversionUtils.java @ 281
History | View | Annotate | Download (1.46 KB)
1 |
package org.gvsig.lidar.prov; |
---|---|
2 |
|
3 |
public class ConversionUtils { |
4 |
|
5 |
private static final int RED_MASK = 255 << 16; |
6 |
private static final int GREEN_MASK = 255 << 8; |
7 |
private static final int BLUE_MASK = 255; |
8 |
|
9 |
/**
|
10 |
* GPS time as GPS timestamp = LAS GPS adjusted time + 1000000000
|
11 |
* GPS time as Unix timestamp = GPS time as GPS timestamp + 315964800
|
12 |
* UTC time as Unix timestamp = GPS time as Unix timestamp + leap seconds
|
13 |
* As leap seconds depend on the actual date being converted, we'll ignore them
|
14 |
* Therefore, we'll use the following constant
|
15 |
* UNIX TIME = LAS GPS adjusted time + LAS_TIME_TO_UNIX_TIME,
|
16 |
* where LAS_TIME_TO_UNIX_TIME = 1000000000 + 315964800 = 1315964800
|
17 |
*/
|
18 |
final public static long LAS_TIME_TO_UNIX_TIME = 1315964800; |
19 |
|
20 |
/**
|
21 |
* Converts red, green and blue values to a RGB int as defined
|
22 |
* by java.awt.Color(int) constructor.
|
23 |
*
|
24 |
*/
|
25 |
public static int rgbToInt(int red, int green, int blue) { |
26 |
return (red << 16) | (green << 8) | blue; |
27 |
} |
28 |
|
29 |
/**
|
30 |
* Converts a RGB int as defined by java.awt.Color(int) constructor
|
31 |
* to separate red, green and blue values
|
32 |
*
|
33 |
* @returns an array containing the red, green and blue values
|
34 |
*/
|
35 |
public static int[] intToRgb(int rgb) { |
36 |
int[] rgbArray = new int[3]; |
37 |
rgbArray[0] = (rgb & RED_MASK) >> 16; |
38 |
rgbArray[1] = (rgb & GREEN_MASK) >> 8; |
39 |
rgbArray[2] = rgb & BLUE_MASK;
|
40 |
return rgbArray;
|
41 |
} |
42 |
} |