svn-gvsig-desktop / branches / v10 / libraries / libDielmoOpenLidar / src / com / dielmo / lidar / BINPoint2002.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 |
* BIN point that implement the BIN point data version BIN 20020715
|
60 |
*
|
61 |
* @author Oscar Garcia
|
62 |
*/
|
63 |
public class BINPoint2002 implements LidarPoint{ |
64 |
|
65 |
/**
|
66 |
* size of point format
|
67 |
*/
|
68 |
protected int sizeFormat; |
69 |
|
70 |
/**
|
71 |
* indicates if content color.
|
72 |
*/
|
73 |
private boolean isColor; |
74 |
|
75 |
/**
|
76 |
* indicates if content time GPS.
|
77 |
*/
|
78 |
private boolean isTimeGPS; |
79 |
|
80 |
/**
|
81 |
* Color RGB
|
82 |
*/
|
83 |
private char color[] = new char[4]; |
84 |
|
85 |
/**
|
86 |
* indicates if content color.
|
87 |
*/
|
88 |
private int time; |
89 |
|
90 |
|
91 |
/**
|
92 |
* X value
|
93 |
*/
|
94 |
private int x; |
95 |
|
96 |
/**
|
97 |
* Y value
|
98 |
*/
|
99 |
private int y; |
100 |
|
101 |
/**
|
102 |
* Z value
|
103 |
*/
|
104 |
private int z; |
105 |
|
106 |
/**
|
107 |
* The intensity value is the integer representation of the
|
108 |
* pulse return magnitude.
|
109 |
*/
|
110 |
private int intensity; |
111 |
|
112 |
/**
|
113 |
* The echo information of BIN is the pulse return number for a given output
|
114 |
* pulse.
|
115 |
*
|
116 |
* 0 Only echo
|
117 |
* 1 First of many echo
|
118 |
* 2 Intermediate echo
|
119 |
* 3 Last if many echo
|
120 |
*/
|
121 |
private byte echoInformation; |
122 |
|
123 |
/**
|
124 |
* The flight line number.
|
125 |
*/
|
126 |
private int flightLine; |
127 |
|
128 |
/**
|
129 |
* The classification field is a number to signify a given
|
130 |
* classification during filter processing.
|
131 |
*/
|
132 |
private char classification; |
133 |
|
134 |
/**
|
135 |
* Runtime flag.
|
136 |
*/
|
137 |
private char mark; |
138 |
|
139 |
/**
|
140 |
* Runtime flag (view visibility).
|
141 |
*/
|
142 |
private char flag; |
143 |
|
144 |
|
145 |
/**
|
146 |
* Default constructor, without arguments.
|
147 |
* Initializes all components to zero.
|
148 |
*/
|
149 |
public BINPoint2002(boolean c, boolean t) { |
150 |
|
151 |
x = 0;
|
152 |
y = 0;
|
153 |
z = 0;
|
154 |
intensity = 0;
|
155 |
echoInformation = 0;
|
156 |
flightLine = 0;
|
157 |
classification = 0;
|
158 |
isColor = c; |
159 |
isTimeGPS = t; |
160 |
color[0] = 0; |
161 |
color[1] = 0; |
162 |
color[2] = 0; |
163 |
color[3] = 0; |
164 |
time = 0;
|
165 |
sizeFormat = 20;
|
166 |
|
167 |
if(c)
|
168 |
sizeFormat += 4;
|
169 |
if(t)
|
170 |
sizeFormat += 4;
|
171 |
} |
172 |
|
173 |
// GET METHODS
|
174 |
/**
|
175 |
* Get GPS time as long.
|
176 |
*/
|
177 |
public int getTime() { |
178 |
|
179 |
return time;
|
180 |
} |
181 |
|
182 |
/**
|
183 |
* Get Color RGB
|
184 |
*/
|
185 |
public char[] getcolor() { |
186 |
return color;
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* Get red value of color
|
191 |
*/
|
192 |
public char getR() { |
193 |
return color[0]; |
194 |
} |
195 |
|
196 |
/**
|
197 |
* Get green value of color
|
198 |
*/
|
199 |
public char getG() { |
200 |
|
201 |
return color[1]; |
202 |
} |
203 |
|
204 |
/**
|
205 |
* Get blue value of color
|
206 |
*/
|
207 |
public char getB() { |
208 |
|
209 |
return color[2]; |
210 |
} |
211 |
|
212 |
/**
|
213 |
* Get infrared value of color
|
214 |
*/
|
215 |
public char getI() { |
216 |
|
217 |
return color[3]; |
218 |
} |
219 |
|
220 |
/**
|
221 |
* Return X value that is stored as long integer. The corresponding
|
222 |
* X scale from the public header block change this long integer to
|
223 |
* true floating point value. The corresponding offset value can
|
224 |
* also be used for projections with very large numbers.
|
225 |
*
|
226 |
* the coordinate = (X-OrgX)/Units
|
227 |
*
|
228 |
* @return x value
|
229 |
*/
|
230 |
public int getX() { |
231 |
|
232 |
return x;
|
233 |
} |
234 |
|
235 |
/**
|
236 |
* Return Y value that is stored as long integer. The corresponding
|
237 |
* Y scale from the public header block change this long integer to
|
238 |
* true floating point value. The corresponding offset value can
|
239 |
* also be used for projections with very large numbers.
|
240 |
*
|
241 |
* the coordinate = (Y-OrgY)/Units
|
242 |
*
|
243 |
* @return y value
|
244 |
*/
|
245 |
public int getY() { |
246 |
|
247 |
return y;
|
248 |
} |
249 |
|
250 |
/**
|
251 |
* Return Z value that is stored as long integer. The corresponding
|
252 |
* Z scale from the public header block change this long integer to
|
253 |
* true floating point value. The corresponding offset value can
|
254 |
* also be used for projections with very large numbers.
|
255 |
*
|
256 |
* the coordinate = (Z-OrgZ)/Units
|
257 |
*
|
258 |
* @return z value
|
259 |
*/
|
260 |
public int getZ() { |
261 |
return z;
|
262 |
} |
263 |
|
264 |
/**
|
265 |
* Get the intensity value as the integer representation of the pulse
|
266 |
* return magnitude. This value is optional and system specific
|
267 |
*
|
268 |
* @return intensity value
|
269 |
*/
|
270 |
public int getIntensity() { |
271 |
|
272 |
return intensity;
|
273 |
} |
274 |
|
275 |
/**
|
276 |
* Get The echo information of BIN is the pulse return number for
|
277 |
* a given output pulse.
|
278 |
*
|
279 |
* 0 Only echo
|
280 |
* 1 First of many echo
|
281 |
* 2 Intermediate echo
|
282 |
* 3 Last if many echo
|
283 |
*
|
284 |
* @return echo information
|
285 |
*/
|
286 |
public byte getEchoInformation() { |
287 |
|
288 |
return echoInformation;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* Get flight line number
|
293 |
*
|
294 |
* @return flight line number
|
295 |
*/
|
296 |
public int getFlightLine() { |
297 |
|
298 |
return flightLine;
|
299 |
} |
300 |
|
301 |
/**
|
302 |
* Get a given classification during filter processing.
|
303 |
*
|
304 |
* @return classification
|
305 |
*/
|
306 |
public char getClassification() { |
307 |
|
308 |
return classification;
|
309 |
} |
310 |
|
311 |
/**
|
312 |
* Get mark (Runtime flag).
|
313 |
*
|
314 |
* @return classification
|
315 |
*/
|
316 |
public char getMark() { |
317 |
|
318 |
return mark;
|
319 |
} |
320 |
|
321 |
/**
|
322 |
* Get flag (Runtime flag (view visibility) ).
|
323 |
*
|
324 |
* @return classification
|
325 |
*/
|
326 |
public char getFlag() { |
327 |
|
328 |
return flag;
|
329 |
} |
330 |
|
331 |
|
332 |
/**
|
333 |
* Get a bit size of point format
|
334 |
*
|
335 |
* @return sizeFormat
|
336 |
*/
|
337 |
public int getSizeFormat() { |
338 |
return sizeFormat;
|
339 |
} |
340 |
|
341 |
// SET METHODS
|
342 |
/**
|
343 |
* Set GPS time as long.
|
344 |
*/
|
345 |
public void setTime(int t) { |
346 |
time=t; |
347 |
} |
348 |
|
349 |
/**
|
350 |
* Set Color RGB
|
351 |
*
|
352 |
* @param c this array contains 4 chars for represents the RGBI
|
353 |
*/
|
354 |
public void setcolor(char[] c) { |
355 |
|
356 |
if(c.length == 4) |
357 |
color = c; |
358 |
} |
359 |
|
360 |
/**
|
361 |
* set X value that is stored as long integer.
|
362 |
*
|
363 |
* @param newx new value of x
|
364 |
*/
|
365 |
public void setX(int newx) { |
366 |
|
367 |
x = newx; |
368 |
} |
369 |
|
370 |
/**
|
371 |
* set Y value that is stored as long integer.
|
372 |
*
|
373 |
* @param newy new value of y
|
374 |
*/
|
375 |
public void setY(int newy) { |
376 |
|
377 |
y = newy; |
378 |
} |
379 |
|
380 |
/**
|
381 |
* set Z value that is stored as long integer.
|
382 |
*
|
383 |
* @param newz new value of z
|
384 |
*/
|
385 |
public void setZ(int newz) { |
386 |
|
387 |
z = newz; |
388 |
} |
389 |
|
390 |
/**
|
391 |
* Set the intensity value as the integer representation of the pulse
|
392 |
* return magnitude. This value is optional and system specific
|
393 |
*
|
394 |
* @param inten new intensity
|
395 |
*/
|
396 |
public void setIntensity(int inten) { |
397 |
|
398 |
try{
|
399 |
if(inten >=0 && inten <= UNSIGNED_SHORT_MAX) |
400 |
intensity = inten; |
401 |
else
|
402 |
throw new OutOfRangeLidarException("Out of range of intensity"); |
403 |
|
404 |
} catch(OutOfRangeLidarException e) {
|
405 |
|
406 |
e.printStackTrace(); |
407 |
} |
408 |
} |
409 |
|
410 |
/**
|
411 |
* Set The echo information of BIN is the pulse return number for
|
412 |
* a given output pulse.
|
413 |
*
|
414 |
* 0 Only echo
|
415 |
* 1 First of many echo
|
416 |
* 2 Intermediate echo
|
417 |
* 3 Last if many echo
|
418 |
*
|
419 |
* @param echo new echo information
|
420 |
*/
|
421 |
public void setEchoInformation(byte echo) { |
422 |
|
423 |
try{
|
424 |
if(echo >=0 && echo <= 3) |
425 |
echoInformation = echo; |
426 |
else
|
427 |
throw new OutOfRangeLidarException("Out of range of echo information"); |
428 |
|
429 |
} catch(OutOfRangeLidarException e) {
|
430 |
|
431 |
e.printStackTrace(); |
432 |
} |
433 |
} |
434 |
|
435 |
/**
|
436 |
* Set flight line number
|
437 |
*
|
438 |
* @param fl new flight line number
|
439 |
*/
|
440 |
public void setFlightLine(int fl) { |
441 |
|
442 |
try{
|
443 |
if(fl >=0 && fl <= UNSIGNED_SHORT_MAX) |
444 |
flightLine = fl; |
445 |
else
|
446 |
throw new OutOfRangeLidarException("Out of range of flightline"); |
447 |
|
448 |
} catch(OutOfRangeLidarException e) {
|
449 |
|
450 |
e.printStackTrace(); |
451 |
} |
452 |
} |
453 |
|
454 |
/**
|
455 |
* Set a given classification during filter processing.
|
456 |
*
|
457 |
* @return c new classification
|
458 |
*/
|
459 |
public void setClassification(char c) { |
460 |
|
461 |
try{
|
462 |
if(c >=0 && c <= 255) |
463 |
classification = c; |
464 |
else
|
465 |
throw new OutOfRangeLidarException("Out of range of classification"); |
466 |
|
467 |
} catch(OutOfRangeLidarException e) {
|
468 |
|
469 |
e.printStackTrace(); |
470 |
} |
471 |
} |
472 |
|
473 |
/**
|
474 |
* Set mark (Runtime flag).
|
475 |
*
|
476 |
* @return classification
|
477 |
*/
|
478 |
public void setMark(char m) { |
479 |
|
480 |
try{
|
481 |
if(m >=0 && m <= 255) |
482 |
mark=m; |
483 |
else
|
484 |
throw new OutOfRangeLidarException("Out of range of mark"); |
485 |
|
486 |
} catch(OutOfRangeLidarException e) {
|
487 |
|
488 |
e.printStackTrace(); |
489 |
} |
490 |
} |
491 |
|
492 |
/**
|
493 |
* Set flag (Runtime flag (view visibility) ).
|
494 |
*
|
495 |
* @return classification
|
496 |
*/
|
497 |
public void setFlag(char f) { |
498 |
|
499 |
try{
|
500 |
if(f >=0 && f <= 255) |
501 |
flag=f; |
502 |
else
|
503 |
throw new OutOfRangeLidarException("Out of range of flag"); |
504 |
|
505 |
} catch(OutOfRangeLidarException e) {
|
506 |
|
507 |
e.printStackTrace(); |
508 |
} |
509 |
} |
510 |
|
511 |
/**
|
512 |
* Read a point of BIN file
|
513 |
*
|
514 |
* @param input input file to read
|
515 |
* @param Offset Offset to data
|
516 |
* @param index index of points to read
|
517 |
* @return true if success else return false
|
518 |
*/
|
519 |
public void readPoint(BigByteBuffer2 input, LidarHeader hdr, long index) { |
520 |
|
521 |
try{
|
522 |
|
523 |
|
524 |
if(index>hdr.getNumPointsRecord() || index < 0) { |
525 |
throw new UnexpectedPointException("Out of index"); |
526 |
} |
527 |
|
528 |
int auxIndex;
|
529 |
byte[] punto = new byte[getSizeFormat()]; |
530 |
|
531 |
input.position(hdr.getOffsetData()+getSizeFormat()*index); |
532 |
input.get(punto); |
533 |
|
534 |
setX(ByteUtilities.arr2Int(punto, 0));
|
535 |
setY(ByteUtilities.arr2Int(punto, 4));
|
536 |
setZ(ByteUtilities.arr2Int(punto, 8));
|
537 |
|
538 |
setClassification((char)(punto[12] & 0xFF)); |
539 |
setEchoInformation((byte)(punto[13] & 0xFF)); |
540 |
setFlag((char)(punto[14] & 0xFF)); |
541 |
setMark((char)(punto[15] & 0xFF)); |
542 |
|
543 |
setFlightLine(ByteUtilities.arr2Unsignedshort(punto, 16));
|
544 |
setIntensity(ByteUtilities.arr2Unsignedshort(punto, 18));
|
545 |
|
546 |
auxIndex = 20;
|
547 |
|
548 |
// si hay gps leelo
|
549 |
if(isTimeGPS) {
|
550 |
setTime(ByteUtilities.arr2Int(punto, auxIndex)); |
551 |
auxIndex+=4;
|
552 |
} |
553 |
|
554 |
// si hay color leelo
|
555 |
if(isColor) {
|
556 |
|
557 |
color[0] = (char)(punto[auxIndex] & 0xFF); |
558 |
color[1] = (char)(punto[auxIndex+1] & 0xFF); |
559 |
color[2] = (char)(punto[auxIndex+2] & 0xFF); |
560 |
color[3] = (char)(punto[auxIndex+3] & 0xFF); |
561 |
} |
562 |
} catch(UnexpectedPointException e){
|
563 |
e.printStackTrace(); |
564 |
} |
565 |
} |
566 |
|
567 |
/**
|
568 |
* Read x and y in point of BIN file
|
569 |
*
|
570 |
* @param input input buffer to read
|
571 |
* @param Offset Offset to data
|
572 |
* @param index index of points to read
|
573 |
* @return true if success else return false
|
574 |
*/
|
575 |
public Point2D.Double readPoint2D(BigByteBuffer2 input, LidarHeader hdr, long index) { |
576 |
|
577 |
try{
|
578 |
if(index>hdr.getNumPointsRecord() || index < 0) { |
579 |
throw new UnexpectedPointException("Out of Index"); |
580 |
} |
581 |
|
582 |
byte[] punto = new byte[8]; |
583 |
|
584 |
input.position(hdr.getOffsetData()+getSizeFormat()*index); |
585 |
input.get(punto); |
586 |
|
587 |
setX(ByteUtilities.arr2Int(punto, 0));
|
588 |
setY(ByteUtilities.arr2Int(punto, 4));
|
589 |
|
590 |
return new Point2D.Double((getX()-hdr.getXOffset())/hdr.getXScale(), (getY()-hdr.getYOffset())/hdr.getYScale()); |
591 |
|
592 |
} catch(UnexpectedPointException e) {
|
593 |
|
594 |
e.printStackTrace(); |
595 |
} |
596 |
|
597 |
return null; |
598 |
} |
599 |
|
600 |
/**
|
601 |
* Read a x, y and z in point of BIN file
|
602 |
*
|
603 |
* @param input input buffer to read
|
604 |
* @param Offset Offset to data
|
605 |
* @param index index of points to read
|
606 |
* @return true if success else return false
|
607 |
*/
|
608 |
public void readPoint3D(BigByteBuffer2 input, LidarHeader hdr, long index) { |
609 |
|
610 |
try{
|
611 |
if(index>hdr.getNumPointsRecord() || index < 0) { |
612 |
throw new UnexpectedPointException("Out of Index"); |
613 |
} |
614 |
|
615 |
byte[] punto = new byte[12]; |
616 |
|
617 |
input.position(hdr.getOffsetData()+getSizeFormat()*index); |
618 |
input.get(punto); |
619 |
|
620 |
setX(ByteUtilities.arr2Int(punto, 0));
|
621 |
setY(ByteUtilities.arr2Int(punto, 4));
|
622 |
setZ(ByteUtilities.arr2Int(punto, 8));
|
623 |
|
624 |
} catch(UnexpectedPointException e) {
|
625 |
|
626 |
e.printStackTrace(); |
627 |
} |
628 |
} |
629 |
|
630 |
/**
|
631 |
* get field value by index:
|
632 |
*
|
633 |
* 0 return X
|
634 |
* 1 return Y
|
635 |
* 2 return Z
|
636 |
* 3 return intensity
|
637 |
* 4 return classification
|
638 |
* 5 return Line
|
639 |
* 6 return echo information
|
640 |
* 7 return Flag
|
641 |
* 8 return Mark
|
642 |
* 9-13 Time and Color RGBI
|
643 |
*
|
644 |
* @param bb byte buffer of data
|
645 |
* @param indexField index of field
|
646 |
* @param hdr LiDAR header
|
647 |
* @param index asked point index. (row)
|
648 |
* @return Value of row and column indicated
|
649 |
* @throws UnexpectedPointException
|
650 |
*/
|
651 |
public Object getFieldValueByIndex(BigByteBuffer2 bb, int indexField, |
652 |
LidarHeader hdr, long index) {
|
653 |
|
654 |
readPoint(bb, hdr, index); |
655 |
|
656 |
|
657 |
switch(indexField) {
|
658 |
|
659 |
case 0: |
660 |
return (getX()-hdr.getXOffset())/hdr.getXScale();
|
661 |
|
662 |
case 1: |
663 |
return (getY()-hdr.getYOffset())/hdr.getYScale();
|
664 |
|
665 |
case 2: |
666 |
return (getZ()-hdr.getZOffset())/hdr.getZScale();
|
667 |
|
668 |
case 3: |
669 |
return getIntensity();
|
670 |
|
671 |
case 4: |
672 |
return getClassification();
|
673 |
|
674 |
case 5: |
675 |
return getFlightLine();
|
676 |
|
677 |
case 6: |
678 |
return getEchoInformation();
|
679 |
|
680 |
case 7: |
681 |
return getFlag();
|
682 |
|
683 |
case 8: |
684 |
return getMark();
|
685 |
|
686 |
case 9: |
687 |
|
688 |
if(isTimeGPS)
|
689 |
return getTime();
|
690 |
else if(isColor) |
691 |
return getR();
|
692 |
|
693 |
case 10: |
694 |
|
695 |
if(isTimeGPS)
|
696 |
return getR();
|
697 |
else if(isColor) |
698 |
return getG();
|
699 |
|
700 |
case 11: |
701 |
|
702 |
if(isTimeGPS)
|
703 |
return getG();
|
704 |
else if(isColor) |
705 |
return getB();
|
706 |
|
707 |
case 12: |
708 |
|
709 |
if(isTimeGPS)
|
710 |
return getB();
|
711 |
else if(isColor) |
712 |
return getI();
|
713 |
|
714 |
case 13: |
715 |
if(isTimeGPS)
|
716 |
return getI();
|
717 |
} |
718 |
|
719 |
return null; |
720 |
} |
721 |
|
722 |
public Object getFieldValueByName(BigByteBuffer2 bb, String nameField, LidarHeader hdr, |
723 |
long index) {
|
724 |
|
725 |
readPoint(bb, hdr, index); |
726 |
|
727 |
if(nameField.equalsIgnoreCase("X")) |
728 |
return (getX()-hdr.getXOffset())/hdr.getXScale();
|
729 |
else if(nameField.equalsIgnoreCase("Y")) |
730 |
return (getY()-hdr.getYOffset())/hdr.getYScale();
|
731 |
else if(nameField.equalsIgnoreCase("Z")) |
732 |
return (getZ()-hdr.getZOffset())/hdr.getZScale();
|
733 |
else if(nameField.equalsIgnoreCase("Intensity")) |
734 |
return getIntensity();
|
735 |
else if(nameField.equalsIgnoreCase("Classification")) |
736 |
return getClassification();
|
737 |
else if(nameField.equalsIgnoreCase("Line")) |
738 |
return getFlightLine();
|
739 |
else if(nameField.equalsIgnoreCase("Echo")) |
740 |
return getEchoInformation();
|
741 |
else if(nameField.equalsIgnoreCase("Flag")) |
742 |
return getFlag();
|
743 |
else if(nameField.equalsIgnoreCase("Mark")) |
744 |
return getMark();
|
745 |
else if(nameField.equalsIgnoreCase("Time")) |
746 |
return getTime();
|
747 |
else if(nameField.equalsIgnoreCase("R")) |
748 |
return getR();
|
749 |
else if(nameField.equalsIgnoreCase("G")) |
750 |
return getG();
|
751 |
else if(nameField.equalsIgnoreCase("B")) |
752 |
return getB();
|
753 |
else if(nameField.equalsIgnoreCase("I")) |
754 |
return getI();
|
755 |
|
756 |
return null; |
757 |
} |
758 |
|
759 |
public ContainerColumnDescription getColumnsDescription(ContainerColumnDescription fields) {
|
760 |
|
761 |
|
762 |
fields.add("X", ColumnDescription.DOUBLE, 20, 3, 0.0); |
763 |
fields.add("Y", ColumnDescription.DOUBLE, 20, 3, 0.0); |
764 |
fields.add("Z", ColumnDescription.DOUBLE, 20, 3, 0.0); |
765 |
fields.add("Intensity", ColumnDescription.INT, 5, 0, 0); |
766 |
fields.add("Classification", ColumnDescription.BYTE, 1, 0, 0); |
767 |
fields.add("Line", ColumnDescription.INT, 3, 0, 0); |
768 |
fields.add("Echo", ColumnDescription.BYTE, 1, 0, 0); |
769 |
fields.add("Flag", ColumnDescription.BYTE, 1, 0, 0); |
770 |
fields.add("Mark", ColumnDescription.BYTE, 1, 0, 0); |
771 |
|
772 |
if(isTimeGPS) {
|
773 |
|
774 |
fields.add("Time", ColumnDescription.DOUBLE, 20, 5, 0.0); |
775 |
} |
776 |
|
777 |
if(isColor) {
|
778 |
|
779 |
fields.add("R", ColumnDescription.INT, 3, 0, 0); |
780 |
fields.add("G", ColumnDescription.INT, 3, 0, 0); |
781 |
fields.add("B", ColumnDescription.INT, 3, 0, 0); |
782 |
fields.add("I", ColumnDescription.INT, 3, 0, 0); |
783 |
} |
784 |
|
785 |
return fields;
|
786 |
} |
787 |
|
788 |
public void WritePoint(ByteBuffer bb) { |
789 |
|
790 |
byte[] punto = new byte[getSizeFormat()]; |
791 |
|
792 |
// bytes 0-4
|
793 |
ByteUtilities.int2Arr(getX(), punto, 0);
|
794 |
|
795 |
// bytes 4-8
|
796 |
ByteUtilities.int2Arr(getY(), punto, 4);
|
797 |
|
798 |
// bytes 8-12
|
799 |
ByteUtilities.int2Arr(getZ(), punto, 8);
|
800 |
|
801 |
// byte 12
|
802 |
punto[12] = (byte) (getClassification() & 0xFF); |
803 |
|
804 |
// byte 13
|
805 |
punto[13] = (byte) (getEchoInformation() & 0xFF); |
806 |
|
807 |
// byte 14
|
808 |
punto[14] = (byte) (getFlag() & 0xFF); |
809 |
|
810 |
// byte 15
|
811 |
punto[15] = (byte) (getMark() & 0xFF); |
812 |
|
813 |
// byte 16-18
|
814 |
ByteUtilities.unsignedShort2Arr(getFlightLine(), punto, 16);
|
815 |
|
816 |
// byte 18-20
|
817 |
ByteUtilities.unsignedShort2Arr(getIntensity(), punto, 18);
|
818 |
|
819 |
// si hay gps leelo
|
820 |
if(isTimeGPS){
|
821 |
|
822 |
// bytes 20-24
|
823 |
ByteUtilities.int2Arr(getTime(), punto, 20);
|
824 |
|
825 |
if(isColor){
|
826 |
|
827 |
// bytes 24-28
|
828 |
punto[24]= (byte) (color[0] & 0xFF); |
829 |
punto[25] = (byte) (color[1] & 0xFF); |
830 |
punto[26] = (byte) (color[2] & 0xFF); |
831 |
punto[27] = (byte) (color[3] & 0xFF); |
832 |
} |
833 |
} else {
|
834 |
|
835 |
// si hay color leelo
|
836 |
if(isColor) {
|
837 |
// bytes 20-24
|
838 |
punto[20]= (byte) (color[0] & 0xFF); |
839 |
punto[21] = (byte) (color[1] & 0xFF); |
840 |
punto[22] = (byte) (color[2] & 0xFF); |
841 |
punto[23] = (byte) (color[3] & 0xFF); |
842 |
} |
843 |
} |
844 |
|
845 |
bb.put(punto); |
846 |
|
847 |
return;
|
848 |
} |
849 |
|
850 |
/*
|
851 |
* Set Point from a row
|
852 |
* @see com.dielmo.gvsig.lidar.LidarPoint#setPoint(com.hardcode.gdbms.engine.values.Value[], com.dielmo.gvsig.lidar.LidarHeader)
|
853 |
*/
|
854 |
public void setPoint(Object[] row, LidarHeader hdr) { |
855 |
|
856 |
double auxX = ((Double)(row[0])); |
857 |
double auxY = ((Double)(row[1])); |
858 |
double auxZ = ((Double)(row[2])); |
859 |
|
860 |
setX((int) (auxX * (hdr.getXScale()) + hdr.getXOffset()));
|
861 |
setY((int) (auxY * (hdr.getYScale()) + hdr.getYOffset()));
|
862 |
setZ((int) (auxZ * (hdr.getZScale()) + hdr.getZOffset()));
|
863 |
|
864 |
setIntensity(((Integer)(row[3]))); |
865 |
setClassification((char) (((Integer)(row[4])).byteValue() & 0xFF)); |
866 |
setFlightLine(((Integer)(row[5]))); |
867 |
setEchoInformation(((Integer)(row[6])).byteValue()); |
868 |
|
869 |
setFlag((char) (((Integer)(row[7])).byteValue() & 0xFF)); |
870 |
setMark((char) (((Integer)(row[8])).byteValue() & 0xFF)); |
871 |
|
872 |
if(hdr instanceof BINHeader) { |
873 |
|
874 |
BINHeader hdrBin = (BINHeader) hdr; |
875 |
if(hdrBin.getTime()>0) { |
876 |
|
877 |
setTime(((Integer)(row[9]))); |
878 |
|
879 |
if(hdrBin.getColor()>0){ |
880 |
|
881 |
color[0] = (char) (((Integer)(row[10])).byteValue() & 0xFF); |
882 |
color[1] = (char) (((Integer)(row[11])).byteValue() & 0xFF); |
883 |
color[2] = (char) (((Integer)(row[12])).byteValue() & 0xFF); |
884 |
color[3] = (char) (((Integer)(row[13])).byteValue() & 0xFF); |
885 |
} |
886 |
} else {
|
887 |
|
888 |
if(hdrBin.getColor()>0) { |
889 |
color[0] = (char) (((Integer)(row[9])).byteValue() & 0xFF); |
890 |
color[1] = (char) (((Integer)(row[10])).byteValue() & 0xFF); |
891 |
color[2] = (char) (((Integer)(row[11])).byteValue() & 0xFF); |
892 |
color[3] = (char) (((Integer)(row[12])).byteValue() & 0xFF); |
893 |
} |
894 |
} |
895 |
} |
896 |
} |
897 |
} |