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