svn-gvsig-desktop / branches / v10 / libraries / libDielmoOpenLidar / src / com / dielmo / lidar / LASPoint10F0.java @ 26395
History | View | Annotate | Download (19.4 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.awt.geom.Point2D; |
53 |
import java.nio.ByteBuffer; |
54 |
|
55 |
import com.dielmo.lidar.fieldsDescription.ColumnDescription; |
56 |
import com.dielmo.lidar.fieldsDescription.ContainerColumnDescription; |
57 |
|
58 |
/**
|
59 |
* LAS point that implement the LAS point data version LAS1.0
|
60 |
* in format 0
|
61 |
*
|
62 |
* @author Oscar Garcia
|
63 |
*/
|
64 |
public class LASPoint10F0 implements LidarPoint{ |
65 |
|
66 |
protected int sizeFormat; |
67 |
/**
|
68 |
* X value
|
69 |
*/
|
70 |
protected int x; |
71 |
|
72 |
/**
|
73 |
* Y value
|
74 |
*/
|
75 |
protected int y; |
76 |
|
77 |
/**
|
78 |
* Z value
|
79 |
*/
|
80 |
protected int z; |
81 |
|
82 |
/**
|
83 |
* The intensity value is the integer representation of the
|
84 |
* pulse return magnitude.
|
85 |
*/
|
86 |
protected int intensity; |
87 |
|
88 |
/**
|
89 |
* The return number is the pulse return number for a given output
|
90 |
* pulse.
|
91 |
*/
|
92 |
protected byte returnNumber; |
93 |
|
94 |
/**
|
95 |
* Total number of returns for a given pulse.
|
96 |
*/
|
97 |
protected byte numberOfReturn; |
98 |
|
99 |
/**
|
100 |
* direction at which the scanner mirror was traveling at the time
|
101 |
* of the output pulse.
|
102 |
*/
|
103 |
protected byte scanDirectionFlag; |
104 |
|
105 |
/**
|
106 |
* The edge of flight line data bit has a value of 1 only when
|
107 |
* the point is at the end of a scan. It is the last point on a
|
108 |
* given scan line before it changes direction.
|
109 |
*/
|
110 |
protected byte edgeOfFlightLine; |
111 |
|
112 |
/**
|
113 |
* The classification field is a number to signify a given
|
114 |
* classification during filter processing.
|
115 |
*/
|
116 |
protected char classification; |
117 |
|
118 |
/**
|
119 |
* Angle at which the laser point was output from the laser system
|
120 |
* including the roll of the aircraft. The scan angle is within 1
|
121 |
* degree of accuracy from +90 to -90 degrees. The scan angle is an
|
122 |
* angle based on 0 degrees being NADIR, end -90 degrees to the left
|
123 |
* side of the aircraft in the direction of flight.
|
124 |
*/
|
125 |
protected byte scanAngleRank; |
126 |
|
127 |
/**
|
128 |
* The file marker is an optional field that should be used in
|
129 |
* conjunction with the variable length records.
|
130 |
* The file marker allows for the LAS flight-line based files
|
131 |
* to be combined into single files with more than one flight-line.
|
132 |
*/
|
133 |
protected char fileMarker; |
134 |
|
135 |
/**
|
136 |
* A bit field that is to be used at the users discretion.
|
137 |
*/
|
138 |
protected int UserBitField; |
139 |
|
140 |
/**
|
141 |
* Default constructor, without arguments.
|
142 |
* Initializes all components to zero.
|
143 |
*/
|
144 |
public LASPoint10F0() {
|
145 |
|
146 |
x = 0;
|
147 |
y = 0;
|
148 |
z = 0;
|
149 |
intensity = 0;
|
150 |
returnNumber = 0;
|
151 |
numberOfReturn = 0;
|
152 |
scanDirectionFlag = 0;
|
153 |
edgeOfFlightLine = 0;
|
154 |
classification = 0;
|
155 |
scanAngleRank = 0;
|
156 |
fileMarker = 0;
|
157 |
UserBitField = 0;
|
158 |
sizeFormat = 20;
|
159 |
} |
160 |
|
161 |
// GET METHODS
|
162 |
/**
|
163 |
* Return X value that is stored as integer. The corresponding
|
164 |
* X scale from the public header block change this long integer to
|
165 |
* true floating point value. The corresponding offset value can
|
166 |
* also be used for projections with very large numbers.
|
167 |
*
|
168 |
* the coordinate = X*Xscale+Xoffset
|
169 |
*
|
170 |
* @return x value
|
171 |
*/
|
172 |
public int getX() { |
173 |
return x;
|
174 |
} |
175 |
|
176 |
/**
|
177 |
* Return Y value that is stored as integer. The corresponding
|
178 |
* Y scale from the public header block change this long integer to
|
179 |
* true floating point value. The corresponding offset value can
|
180 |
* also be used for projections with very large numbers.
|
181 |
*
|
182 |
* * the coordinate = Y*Yscale+Yoffset
|
183 |
*
|
184 |
* @return y value
|
185 |
*/
|
186 |
public int getY() { |
187 |
return y;
|
188 |
} |
189 |
|
190 |
/**
|
191 |
* Return Z value that is stored as long integer. The corresponding
|
192 |
* Z scale from the public header block change this long integer to
|
193 |
* true floating point value. The corresponding offset value can
|
194 |
* also be used for projections with very large numbers.
|
195 |
*
|
196 |
* * the coordinate = Z*Zscale+Zoffset
|
197 |
*
|
198 |
* @return z value
|
199 |
*/
|
200 |
public int getZ() { |
201 |
return z;
|
202 |
} |
203 |
|
204 |
/**
|
205 |
* Get the intensity value as the integer representation of the pulse
|
206 |
* return magnitude. This value is optional and system specific
|
207 |
*
|
208 |
* @return intensity value
|
209 |
*/
|
210 |
public int getIntensity() { |
211 |
return intensity;
|
212 |
} |
213 |
|
214 |
/**
|
215 |
* Get the return number as the pulse return number for a given output
|
216 |
* pulse.
|
217 |
*
|
218 |
* @return pulse return number
|
219 |
*/
|
220 |
public byte getReturnNumber() { |
221 |
return returnNumber;
|
222 |
} |
223 |
|
224 |
/**
|
225 |
* Get total number of returns for a given pulse.
|
226 |
*
|
227 |
* @return number of return
|
228 |
*/
|
229 |
public byte getNumberOfReturn() { |
230 |
return numberOfReturn;
|
231 |
} |
232 |
|
233 |
/**
|
234 |
* Get direction at which the scanner mirror was traveling at the time
|
235 |
* of the output pulse.
|
236 |
*
|
237 |
* @return direction
|
238 |
*/
|
239 |
public byte getScanDirectionFlag() { |
240 |
return scanDirectionFlag;
|
241 |
} |
242 |
|
243 |
/**
|
244 |
* Get the edge of flight line data bit.
|
245 |
*
|
246 |
* @return edge of flight
|
247 |
*/
|
248 |
public byte getEdgeOfFlightLine() { |
249 |
return edgeOfFlightLine;
|
250 |
} |
251 |
|
252 |
/**
|
253 |
* Get a given classification during filter processing.
|
254 |
*
|
255 |
* @return classification
|
256 |
*/
|
257 |
public char getClassification() { |
258 |
return classification;
|
259 |
} |
260 |
|
261 |
/**
|
262 |
* Get angle at which the laser point was output from the laser system
|
263 |
* including the roll of the aircraft. The scan angle is within 1
|
264 |
* degree of accuracy from +90 to 90 degrees. The scan angle is an
|
265 |
* angle based on 0 degrees being NADIR, end -90 degrees to the left
|
266 |
* side of the aircraft in the direction of flight.
|
267 |
*
|
268 |
* @return scan angle rank
|
269 |
*/
|
270 |
public byte getScanAngleRank() { |
271 |
return scanAngleRank;
|
272 |
} |
273 |
|
274 |
/**
|
275 |
* Get file marker.
|
276 |
* The file marker allows for the LAS flight-line based files
|
277 |
* to be combined into single files with more than one flight-line.
|
278 |
*
|
279 |
* @return file marker
|
280 |
*/
|
281 |
public char getFileMarker() { |
282 |
return fileMarker;
|
283 |
} |
284 |
|
285 |
/**
|
286 |
* Get a bit field that is to be used at the users discretion.
|
287 |
*
|
288 |
* @return user bit field
|
289 |
*/
|
290 |
public int getUserBitField(){ |
291 |
return UserBitField;
|
292 |
} |
293 |
|
294 |
/**
|
295 |
* Get a bit size of point format
|
296 |
*
|
297 |
* @return sizeFormat
|
298 |
*/
|
299 |
public int getSizeFormat() { |
300 |
return sizeFormat;
|
301 |
} |
302 |
|
303 |
// SET METHODS
|
304 |
|
305 |
/**
|
306 |
* set X value that is stored as integer.
|
307 |
*
|
308 |
* @param newx new value of x
|
309 |
*/
|
310 |
public void setX(int newx) { |
311 |
|
312 |
x = newx; |
313 |
} |
314 |
|
315 |
/**
|
316 |
* set Y value that is stored as integer.
|
317 |
*
|
318 |
* @param newy new value of y
|
319 |
*/
|
320 |
public void setY(int newy) { |
321 |
y = newy; |
322 |
} |
323 |
|
324 |
/**
|
325 |
* set Z value that is stored as integer.
|
326 |
*
|
327 |
* @param newz new value of z
|
328 |
*/
|
329 |
public void setZ(int newz) { |
330 |
z = newz; |
331 |
} |
332 |
|
333 |
/**
|
334 |
* Set the intensity value as the integer representation of the pulse
|
335 |
* return magnitude. This value is optional and system specific
|
336 |
*
|
337 |
* @param inten new intensity
|
338 |
*/
|
339 |
public void setIntensity(int inten) { |
340 |
|
341 |
try{
|
342 |
|
343 |
if(inten >=0 && inten <= UNSIGNED_SHORT_MAX) { |
344 |
intensity = inten; |
345 |
} else {
|
346 |
throw new OutOfRangeLidarException("Out of range of intensity"); |
347 |
} |
348 |
|
349 |
} catch(OutOfRangeLidarException e) {
|
350 |
|
351 |
e.printStackTrace(); |
352 |
} |
353 |
|
354 |
} |
355 |
|
356 |
/**
|
357 |
* Set the return number.
|
358 |
*
|
359 |
* @param rn new pulse return number
|
360 |
*/
|
361 |
public void setReturnNumber(byte rn) { |
362 |
|
363 |
try{
|
364 |
if(rn>=0 && rn <= 7) { |
365 |
returnNumber = rn; |
366 |
} else {
|
367 |
throw new OutOfRangeLidarException("Out of range of return number"); |
368 |
} |
369 |
|
370 |
} catch(OutOfRangeLidarException e) {
|
371 |
|
372 |
e.printStackTrace(); |
373 |
} |
374 |
} |
375 |
|
376 |
/**
|
377 |
* Set total number of returns for a given pulse.
|
378 |
*
|
379 |
* @param nof new number of return
|
380 |
*/
|
381 |
public void setNumberOfReturn(byte nof) { |
382 |
|
383 |
try{
|
384 |
if(nof>=0 && nof <= 7) { |
385 |
numberOfReturn = nof; |
386 |
} else {
|
387 |
throw new OutOfRangeLidarException("Out of range of number of return"); |
388 |
} |
389 |
|
390 |
} catch(OutOfRangeLidarException e) {
|
391 |
|
392 |
e.printStackTrace(); |
393 |
} |
394 |
} |
395 |
|
396 |
/**
|
397 |
* Set direction at which the scanner mirror was traveling at the time
|
398 |
* of the output pulse.
|
399 |
*
|
400 |
* @param sdf new direction
|
401 |
*/
|
402 |
public void setScanDirectionFlag(byte sdf) { |
403 |
|
404 |
try{
|
405 |
if(sdf>=0 && sdf<=1) { |
406 |
scanDirectionFlag = sdf; |
407 |
} else {
|
408 |
throw new OutOfRangeLidarException("Out of range of scan direction flag"); |
409 |
} |
410 |
|
411 |
} catch(OutOfRangeLidarException e) {
|
412 |
|
413 |
e.printStackTrace(); |
414 |
} |
415 |
} |
416 |
|
417 |
/**
|
418 |
* Set the edge of flight line data bit.
|
419 |
*
|
420 |
* @param eofl new edge of flight
|
421 |
*/
|
422 |
public void setEdgeOfFlightLine(byte eofl) { |
423 |
|
424 |
try{
|
425 |
if(eofl>=0 && eofl <= 1) { |
426 |
edgeOfFlightLine = eofl; |
427 |
} else {
|
428 |
throw new OutOfRangeLidarException("Out of range of flight line"); |
429 |
} |
430 |
|
431 |
} catch(OutOfRangeLidarException e) {
|
432 |
|
433 |
e.printStackTrace(); |
434 |
} |
435 |
} |
436 |
|
437 |
/**
|
438 |
* Set a given classification during filter processing.
|
439 |
*
|
440 |
* @return c new classification
|
441 |
*/
|
442 |
public void setClassification(char c) { |
443 |
|
444 |
try{
|
445 |
if(c>=0 && c<=255) { |
446 |
classification = c; |
447 |
} else {
|
448 |
throw new OutOfRangeLidarException("Out of range of classification"); |
449 |
} |
450 |
|
451 |
} catch(OutOfRangeLidarException e) {
|
452 |
|
453 |
e.printStackTrace(); |
454 |
} |
455 |
} |
456 |
|
457 |
/**
|
458 |
* Set angle at which the laser point was output from the laser system
|
459 |
* including the roll of the aircraft.
|
460 |
*
|
461 |
* @param sar new scan angle rank
|
462 |
*/
|
463 |
public void setScanAngleRank(byte sar) { |
464 |
|
465 |
// try{
|
466 |
// if(sar>=-90 && sar<=90)
|
467 |
scanAngleRank = sar; |
468 |
// else
|
469 |
// throw new OutOfRangeLidarException("Out of range of scan angle rank");
|
470 |
|
471 |
// } catch(OutOfRangeLidarException e) {
|
472 |
|
473 |
// e.printStackTrace();
|
474 |
// }
|
475 |
} |
476 |
|
477 |
/**
|
478 |
* Set file marker.
|
479 |
* The file marker allows for the LAS flight-line based files
|
480 |
* to be combined into single files with more than one flight-line.
|
481 |
*
|
482 |
* @param fm new file marker
|
483 |
*/
|
484 |
public void setFileMarker(char fm) { |
485 |
|
486 |
try{
|
487 |
if(fm>=0 && fm<=255) { |
488 |
fileMarker = fm; |
489 |
} else {
|
490 |
throw new OutOfRangeLidarException("Out of range of file marker"); |
491 |
} |
492 |
|
493 |
} catch(OutOfRangeLidarException e) {
|
494 |
|
495 |
e.printStackTrace(); |
496 |
} |
497 |
} |
498 |
|
499 |
/**
|
500 |
* Set a bit field that be used at the users discretion.
|
501 |
*
|
502 |
* @param ubf new user bit field
|
503 |
*/
|
504 |
public void setUserBitField(int ubf) { |
505 |
|
506 |
try{
|
507 |
if(ubf>=0 && ubf <= UNSIGNED_SHORT_MAX) { |
508 |
UserBitField = ubf; |
509 |
} else {
|
510 |
throw new OutOfRangeLidarException("Out of range of user bit field"); |
511 |
} |
512 |
|
513 |
} catch(OutOfRangeLidarException e) {
|
514 |
|
515 |
e.printStackTrace(); |
516 |
} |
517 |
} |
518 |
|
519 |
/**
|
520 |
* Read a point of LAS file
|
521 |
*
|
522 |
* @param input input file to read
|
523 |
* @param Offset Offset to data
|
524 |
* @param index index of points to read
|
525 |
* @return true if success else return false
|
526 |
*/
|
527 |
public void readPoint(BigByteBuffer2 input, LidarHeader hdr, long index) { |
528 |
|
529 |
try {
|
530 |
|
531 |
if(index>hdr.getNumPointsRecord() || index < 0) { |
532 |
throw new UnexpectedPointException("Out of index"); |
533 |
} |
534 |
|
535 |
byte[] punto = new byte[getSizeFormat()]; |
536 |
|
537 |
input.position(hdr.getOffsetData()+getSizeFormat()*index); |
538 |
input.get(punto); |
539 |
|
540 |
setX(ByteUtilities.arr2Int(punto, 0));
|
541 |
setY(ByteUtilities.arr2Int(punto, 4));
|
542 |
setZ(ByteUtilities.arr2Int(punto, 8));
|
543 |
setIntensity(ByteUtilities.arr2Unsignedshort(punto, 12));
|
544 |
|
545 |
|
546 |
setReturnNumber((byte)(punto[14] & 0x07)); // 3 primeros bits del byte 14 |
547 |
setNumberOfReturn((byte)((punto[14] & 0x38) >> 3)); // 3 siguintes bits |
548 |
setScanDirectionFlag((byte)((punto[14] & 0x40) >> 6)); // 1 bit |
549 |
setEdgeOfFlightLine((byte)((punto[14] & 0x80) >> 7)); // 1 bit |
550 |
|
551 |
setClassification((char)(punto[15] & 0XFF)); |
552 |
setScanAngleRank((punto[16]));
|
553 |
setFileMarker((char)(punto[17] & 0XFF)); |
554 |
setUserBitField(ByteUtilities.arr2Unsignedshort(punto, 18));
|
555 |
|
556 |
} catch (UnexpectedPointException e) {
|
557 |
// TODO Auto-generated catch block
|
558 |
e.printStackTrace(); |
559 |
} |
560 |
} |
561 |
|
562 |
public Point2D.Double readPoint2D(BigByteBuffer2 input, LidarHeader hdr, long index){ |
563 |
|
564 |
try{
|
565 |
if(index>hdr.getNumPointsRecord() || index < 0) { |
566 |
throw new UnexpectedPointException("Out of index"); |
567 |
} |
568 |
|
569 |
byte[] punto = new byte[8]; |
570 |
|
571 |
input.position(hdr.getOffsetData()+getSizeFormat()*index); |
572 |
input.get(punto); |
573 |
|
574 |
setX(ByteUtilities.arr2Int(punto, 0));
|
575 |
setY(ByteUtilities.arr2Int(punto, 4));
|
576 |
|
577 |
return new Point2D.Double(getX()*hdr.getXScale()+hdr.getXOffset(), getY()*hdr.getYScale()+hdr.getYOffset()); |
578 |
|
579 |
} catch (UnexpectedPointException e) {
|
580 |
// TODO Auto-generated catch block
|
581 |
e.printStackTrace(); |
582 |
} |
583 |
return null; |
584 |
} |
585 |
|
586 |
/**
|
587 |
* Read a x, y and z in point of LAS file
|
588 |
*
|
589 |
* @param input input buffer to read
|
590 |
* @param Offset Offset to data
|
591 |
* @param index index of points to read
|
592 |
* @return true if success else return false
|
593 |
*/
|
594 |
public void readPoint3D(BigByteBuffer2 input, LidarHeader hdr, long index) throws UnexpectedPointException { |
595 |
|
596 |
try{
|
597 |
if(index>hdr.getNumPointsRecord() || index < 0) { |
598 |
throw new UnexpectedPointException("Out of index"); |
599 |
} |
600 |
|
601 |
byte[] punto = new byte[12]; |
602 |
|
603 |
input.position(hdr.getOffsetData()+getSizeFormat()*index); |
604 |
input.get(punto); |
605 |
|
606 |
setX(ByteUtilities.arr2Int(punto, 0));
|
607 |
setY(ByteUtilities.arr2Int(punto, 4));
|
608 |
setZ(ByteUtilities.arr2Int(punto, 8));
|
609 |
|
610 |
} catch (UnexpectedPointException e) {
|
611 |
// TODO Auto-generated catch block
|
612 |
e.printStackTrace(); |
613 |
} |
614 |
} |
615 |
|
616 |
/**
|
617 |
* get field value by index:
|
618 |
*
|
619 |
* 0 return X
|
620 |
* 1 return Y
|
621 |
* 2 return Z
|
622 |
* 3 return intensity
|
623 |
* 4 return returnNumber
|
624 |
* 5 return numberOfReturn
|
625 |
* 6 return scanDirectionFlag
|
626 |
* 7 return edgeOfFlightLine
|
627 |
* 8 return classification
|
628 |
* 9 return scanAngleRank
|
629 |
* 10 return fileMarker
|
630 |
* 11 return UserBitField
|
631 |
*
|
632 |
* @param bb byte buffer of data
|
633 |
* @param indexField index of field
|
634 |
* @param hdr LiDAR header
|
635 |
* @param index asked point index. (row)
|
636 |
* @return Value of row and column indicated
|
637 |
*/
|
638 |
public Object getFieldValueByIndex(BigByteBuffer2 bb, int indexField, |
639 |
LidarHeader hdr, long index) {
|
640 |
|
641 |
readPoint(bb, hdr, index); |
642 |
|
643 |
switch (indexField) {
|
644 |
case 0: |
645 |
return getX() * hdr.getXScale() + hdr.getXOffset();
|
646 |
case 1: |
647 |
return getY() * hdr.getYScale() + hdr.getYOffset();
|
648 |
|
649 |
case 2: |
650 |
return getZ() * hdr.getZScale() + hdr.getZOffset();
|
651 |
|
652 |
case 3: |
653 |
return getIntensity();
|
654 |
|
655 |
case 4: |
656 |
return getReturnNumber();
|
657 |
|
658 |
case 5: |
659 |
return getNumberOfReturn();
|
660 |
|
661 |
case 6: |
662 |
return getScanDirectionFlag();
|
663 |
|
664 |
case 7: |
665 |
return getEdgeOfFlightLine();
|
666 |
|
667 |
case 8: |
668 |
return getClassification();
|
669 |
|
670 |
case 9: |
671 |
return getScanAngleRank();
|
672 |
|
673 |
case 10: |
674 |
|
675 |
return getFileMarker();
|
676 |
|
677 |
case 11: |
678 |
return getUserBitField();
|
679 |
|
680 |
} |
681 |
|
682 |
return null; |
683 |
} |
684 |
|
685 |
public Object getFieldValueByName(BigByteBuffer2 bb, String nameField, |
686 |
LidarHeader hdr, long index) {
|
687 |
|
688 |
readPoint(bb, hdr, index); |
689 |
|
690 |
if(nameField.equalsIgnoreCase("X")) { |
691 |
return getX() * hdr.getXScale() + hdr.getXOffset();
|
692 |
} else if(nameField.equalsIgnoreCase("Y")) { |
693 |
return getY() * hdr.getYScale() + hdr.getYOffset();
|
694 |
} else if(nameField.equalsIgnoreCase("Z")) { |
695 |
return getZ() * hdr.getZScale() + hdr.getZOffset();
|
696 |
} else if(nameField.equalsIgnoreCase("Intensity")) { |
697 |
return getIntensity();
|
698 |
} else if(nameField.equalsIgnoreCase("Return_Number")) { |
699 |
return getReturnNumber();
|
700 |
} else if(nameField.equalsIgnoreCase("Number_of_Returns")) { |
701 |
return getNumberOfReturn();
|
702 |
} else if(nameField.equalsIgnoreCase("Scan_Direction_Flag")) { |
703 |
return getScanDirectionFlag();
|
704 |
} else if(nameField.equalsIgnoreCase("Edge_of_Flight_Line")) { |
705 |
return getEdgeOfFlightLine();
|
706 |
} else if(nameField.equalsIgnoreCase("Classification")) { |
707 |
return getClassification();
|
708 |
} else if(nameField.equalsIgnoreCase("Scan_Angle_Rank")) { |
709 |
return getScanAngleRank();
|
710 |
} else if(nameField.equalsIgnoreCase("File_Marker")) { |
711 |
return getFileMarker();
|
712 |
} else if(nameField.equalsIgnoreCase("User_Bit_Field")) { |
713 |
return getUserBitField();
|
714 |
} |
715 |
|
716 |
return null; |
717 |
} |
718 |
|
719 |
|
720 |
public ContainerColumnDescription getColumnsDescription(ContainerColumnDescription fields) {
|
721 |
|
722 |
fields.add("X", ColumnDescription.DOUBLE, 20, 3, 0.0); |
723 |
fields.add("Y", ColumnDescription.DOUBLE, 20, 3, 0.0); |
724 |
fields.add("Z", ColumnDescription.DOUBLE, 20, 3, 0.0); |
725 |
fields.add("Intensity", ColumnDescription.INT, 5, 0, 0); |
726 |
fields.add("Return_Number", ColumnDescription.BYTE, 1, 0, 0); |
727 |
fields.add("Number_of_Returns", ColumnDescription.BYTE, 1, 0, 0); |
728 |
fields.add("Scan_Direction_Flag", ColumnDescription.BYTE, 1, 0, 0); |
729 |
fields.add("Edge_of_Flight_Line", ColumnDescription.BYTE, 1, 0, 0); |
730 |
fields.add("Classification", ColumnDescription.BYTE, 1, 0, 0); |
731 |
fields.add("Scan_Angle_Rank", ColumnDescription.INT, 3, 0, 0); |
732 |
fields.add("File_Marker", ColumnDescription.INT, 3, 0, 0); |
733 |
fields.add("User_Bit_Field", ColumnDescription.INT, 10, 0, 0); |
734 |
|
735 |
return fields;
|
736 |
} |
737 |
|
738 |
|
739 |
public void WritePoint(ByteBuffer bb) { |
740 |
|
741 |
byte auxByte;
|
742 |
byte[] punto = new byte[getSizeFormat()]; |
743 |
|
744 |
// X bytes 0-4
|
745 |
ByteUtilities.int2Arr(getX(), punto, 0);
|
746 |
|
747 |
// Y bytes 4-8
|
748 |
ByteUtilities.int2Arr(getY(), punto, 4);
|
749 |
|
750 |
// bytes 8-12
|
751 |
ByteUtilities.int2Arr(getZ(), punto, 8);
|
752 |
|
753 |
// bytes 12-14
|
754 |
ByteUtilities.unsignedShort2Arr(getIntensity(), punto, 12);
|
755 |
|
756 |
// byte 14
|
757 |
auxByte = getReturnNumber(); |
758 |
auxByte |= (byte)((getNumberOfReturn()) << 3); |
759 |
auxByte |= (byte)((getScanDirectionFlag()) << 6); |
760 |
auxByte |= (byte)((getEdgeOfFlightLine()) << 7); |
761 |
punto[14] = auxByte;
|
762 |
|
763 |
// byte 15
|
764 |
punto[15] = (byte)((getClassification() & 0xFF)); |
765 |
|
766 |
// byte 16
|
767 |
punto[16] = (byte)((getScanAngleRank() & 0xFF)); |
768 |
|
769 |
// byte 17
|
770 |
punto[17] = (byte)((getFileMarker() & 0xFF)); |
771 |
|
772 |
// bytes 18-20
|
773 |
ByteUtilities.unsignedShort2Arr(getUserBitField(), punto, 18);
|
774 |
|
775 |
|
776 |
bb.put(punto); |
777 |
} |
778 |
|
779 |
/*
|
780 |
* Set Point from a row
|
781 |
*/
|
782 |
public void setPoint(Object[] row, LidarHeader hdr) { |
783 |
double auxX = ((Double) (row[0])); |
784 |
double auxY = ((Double) (row[1])); |
785 |
double auxZ = ((Double) (row[2])); |
786 |
|
787 |
setX((int) ((auxX - hdr.getXOffset()) / hdr.getXScale()));
|
788 |
setY((int) ((auxY - hdr.getYOffset()) / hdr.getYScale()));
|
789 |
setZ((int) ((auxZ - hdr.getZOffset()) / hdr.getZScale()));
|
790 |
|
791 |
setIntensity((Integer) row[3]); |
792 |
setReturnNumber(((Integer) row[4]).byteValue()); |
793 |
setNumberOfReturn(((Integer) (row[5])).byteValue()); |
794 |
setScanDirectionFlag(((Integer) (row[6])).byteValue()); |
795 |
setEdgeOfFlightLine(((Integer) (row[7])).byteValue()); |
796 |
setClassification((char) (((Integer) (row[8])).byteValue() & 0xFF)); |
797 |
setScanAngleRank(((Integer) (row[9])).byteValue()); |
798 |
setFileMarker((char) (((Integer) (row[10])).byteValue() & 0xFF)); |
799 |
setUserBitField(((Integer) (row[11]))); |
800 |
} |
801 |
} |