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