svn-gvsig-desktop / branches / v10 / libraries / libDielmoOpenLidar / src / com / dielmo / lidar / LASPoint10F1.java @ 26395
History | View | Annotate | Download (6.17 KB)
1 |
/* DielmoOpenLiDAR
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2008 DIELMO 3D S.L. (DIELMO) and Infrastructures
|
4 |
* and Transports Department of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For more information, contact:
|
22 |
*
|
23 |
* DIELMO 3D S.L.
|
24 |
* Plaza Vicente Andr?s Estell?s 1 Bajo E
|
25 |
* 46950 Xirivella, Valencia
|
26 |
* SPAIN
|
27 |
*
|
28 |
* +34 963137212
|
29 |
* dielmo@dielmo.com
|
30 |
* www.dielmo.com
|
31 |
*
|
32 |
* or
|
33 |
*
|
34 |
* Generalitat Valenciana
|
35 |
* Conselleria d'Infraestructures i Transport
|
36 |
* Av. Blasco Ib??ez, 50
|
37 |
* 46010 VALENCIA
|
38 |
* SPAIN
|
39 |
*
|
40 |
* +34 963862235
|
41 |
* gvsig@gva.es
|
42 |
* www.gvsig.gva.es
|
43 |
*/
|
44 |
|
45 |
/*
|
46 |
* AUTHORS (In addition to DIELMO and CIT):
|
47 |
*
|
48 |
*/
|
49 |
|
50 |
package com.dielmo.lidar; |
51 |
|
52 |
import java.nio.ByteBuffer; |
53 |
|
54 |
import com.dielmo.lidar.fieldsDescription.ColumnDescription; |
55 |
import com.dielmo.lidar.fieldsDescription.ContainerColumnDescription; |
56 |
|
57 |
|
58 |
|
59 |
/**
|
60 |
* LAS point that implement the LAS point data version LAS1.0
|
61 |
* in format 1
|
62 |
*
|
63 |
* @author Oscar Garcia
|
64 |
*/
|
65 |
public class LASPoint10F1 extends LASPoint10F0{ |
66 |
|
67 |
/**
|
68 |
* The GPS time is the double floating point time tag Object at which the
|
69 |
* point was acquired.
|
70 |
*/
|
71 |
private double timeGPS; |
72 |
|
73 |
/**
|
74 |
* Default constructor, without arguments.
|
75 |
* Initializes all components to zero.
|
76 |
*/
|
77 |
public LASPoint10F1() {
|
78 |
super();
|
79 |
timeGPS = 0;
|
80 |
sizeFormat = 28;
|
81 |
} |
82 |
|
83 |
/**
|
84 |
* Get GPS time as double floating point time tag Object at which the point
|
85 |
* was acquired.
|
86 |
*/
|
87 |
public double getTimeGPS() { |
88 |
return timeGPS;
|
89 |
} |
90 |
|
91 |
/**
|
92 |
* Set GPS time to double floating point time tag Object at which the point
|
93 |
* was acquired.
|
94 |
*/
|
95 |
public void setTimeGPS(double tGPS) { |
96 |
timeGPS = tGPS; |
97 |
} |
98 |
|
99 |
/**
|
100 |
* Read a point of LAS file
|
101 |
*
|
102 |
* @param input input file to read
|
103 |
* @param Offset Offset to data
|
104 |
* @param index index of points to read
|
105 |
* @return true if success else return false
|
106 |
*/
|
107 |
public void readPoint(BigByteBuffer2 input, LidarHeader hdr, long index) { |
108 |
|
109 |
try{
|
110 |
if(index>hdr.getNumPointsRecord() || index < 0) { |
111 |
throw new UnexpectedPointException("Out of index"); |
112 |
} |
113 |
|
114 |
byte[] punto = new byte[getSizeFormat()]; |
115 |
|
116 |
input.position(hdr.getOffsetData()+getSizeFormat()*index); |
117 |
input.get(punto); |
118 |
|
119 |
setX(ByteUtilities.arr2Int(punto, 0));
|
120 |
setY(ByteUtilities.arr2Int(punto, 4));
|
121 |
setZ(ByteUtilities.arr2Int(punto, 8));
|
122 |
setIntensity(ByteUtilities.arr2Unsignedshort(punto, 12));
|
123 |
|
124 |
setReturnNumber((byte)(punto[14] & 0x07)); // 3 primeros bits del byte 14 |
125 |
setNumberOfReturn((byte)((punto[14] & 0x38) >> 3)); // 3 siguintes bits |
126 |
setScanDirectionFlag((byte)((punto[14] & 0x40) >> 6)); // 1 bit |
127 |
setEdgeOfFlightLine((byte)((punto[14] & 0x80) >> 7)); // 1 bit |
128 |
|
129 |
setClassification((char)(punto[15] & 0XFF)); |
130 |
setScanAngleRank((punto[16]));
|
131 |
setFileMarker((char)(punto[17] & 0XFF)); |
132 |
setUserBitField(ByteUtilities.arr2Unsignedshort(punto, 18));
|
133 |
timeGPS = ByteUtilities.arr2Double(punto, 20);
|
134 |
} catch (UnexpectedPointException e) {
|
135 |
// TODO Auto-generated catch block
|
136 |
e.printStackTrace(); |
137 |
} |
138 |
} |
139 |
|
140 |
/**
|
141 |
* get field Object by index:
|
142 |
*
|
143 |
* 0 return X 1 return Y 2 return Z 3 return intensity 4 return returnNumber
|
144 |
* 5 return numberOfReturn 6 return scanDirectionFlag 7 return
|
145 |
* edgeOfFlightLine 8 return classification 9 return scanAngleRank 10 return
|
146 |
* fileMarker 11 return UserBitField 12 return Time GPS
|
147 |
*
|
148 |
* @param bb byte buffer of data
|
149 |
* @param indexField index of field
|
150 |
* @param hdr LiDAR header
|
151 |
* @param index asked point index. (row)
|
152 |
* @return Object of row and column indicated
|
153 |
*/
|
154 |
public Object getFieldValueByIndex(BigByteBuffer2 bb, int indexField, |
155 |
LidarHeader hdr, long index) {
|
156 |
|
157 |
if (indexField == 12) { |
158 |
readPoint(bb, hdr, index); |
159 |
return getTimeGPS();
|
160 |
} |
161 |
return super.getFieldValueByIndex(bb, indexField, hdr, index); |
162 |
} |
163 |
|
164 |
|
165 |
public Object getFieldValueByName(BigByteBuffer2 bb, String nameField, |
166 |
LidarHeader hdr, long index) {
|
167 |
|
168 |
if (nameField.equalsIgnoreCase("GPS_Time")) { |
169 |
readPoint(bb, hdr, index); |
170 |
return getTimeGPS();
|
171 |
} |
172 |
return super.getFieldValueByName(bb, nameField, hdr, index); |
173 |
} |
174 |
|
175 |
|
176 |
public ContainerColumnDescription getColumnsDescription(ContainerColumnDescription fields) {
|
177 |
|
178 |
super.getColumnsDescription(fields);
|
179 |
fields.add("GPS_Time", ColumnDescription.DOUBLE, 20, 5, 0.0); |
180 |
|
181 |
return fields;
|
182 |
} |
183 |
|
184 |
|
185 |
public void WritePoint(ByteBuffer bb) { |
186 |
byte auxByte;
|
187 |
byte[] punto = new byte[getSizeFormat()]; |
188 |
|
189 |
|
190 |
// X bytes 0-4
|
191 |
ByteUtilities.int2Arr(getX(), punto, 0);
|
192 |
|
193 |
// Y bytes 4-8
|
194 |
ByteUtilities.int2Arr(getY(), punto, 4);
|
195 |
|
196 |
// bytes 8-12
|
197 |
ByteUtilities.int2Arr(getZ(), punto, 8);
|
198 |
|
199 |
// bytes 12-14
|
200 |
ByteUtilities.unsignedShort2Arr(getIntensity(), punto, 12);
|
201 |
|
202 |
// byte 14
|
203 |
auxByte = getReturnNumber(); |
204 |
auxByte |= (byte)((getNumberOfReturn()) << 3); |
205 |
auxByte |= (byte)((getScanDirectionFlag()) << 6); |
206 |
auxByte |= (byte)((getEdgeOfFlightLine()) << 7); |
207 |
punto[14] = auxByte;
|
208 |
|
209 |
// byte 15
|
210 |
punto[15] = (byte)((getClassification() & 0xFF)); |
211 |
|
212 |
// byte 16
|
213 |
punto[16] = (byte)((getScanAngleRank() & 0xFF)); |
214 |
|
215 |
// byte 17
|
216 |
punto[17] = (byte)((getFileMarker() & 0xFF)); |
217 |
|
218 |
// bytes 18-20
|
219 |
ByteUtilities.unsignedShort2Arr(getUserBitField(), punto, 18);
|
220 |
|
221 |
// bytes 20-28
|
222 |
ByteUtilities.double2Arr(getTimeGPS(), punto, 20);
|
223 |
|
224 |
bb.put(punto); |
225 |
} |
226 |
|
227 |
/*
|
228 |
* Set Point from a row
|
229 |
*/
|
230 |
public void setPoint(Object[] row, LidarHeader hdr) { |
231 |
|
232 |
super.setPoint(row, hdr);
|
233 |
setTimeGPS(((Double) (row[12]))); |
234 |
} |
235 |
} |