Example #1
0
  /**
   * Read a x, y and z in point of LAS file
   *
   * @param input input buffer to read
   * @param Offset Offset to data
   * @param index index of points to read
   * @return true if success else return false
   */
  public void readPoint3D(BigByteBuffer2 input, LidarHeader hdr, long index) {

    byte[] punto = new byte[16];

    input.position((hdr.getOffsetData() + getSizeFormat() * index) + 4);
    input.get(punto);

    setX(ByteUtilities.arr2Int(punto, 4));
    setY(ByteUtilities.arr2Int(punto, 8));
    setZ(ByteUtilities.arr2Int(punto, 12));
  }
Example #2
0
  /**
   * Read a point of BIN file
   *
   * @param input input file to read
   * @param Offset Offset to data
   * @param index index of points to read
   * @return true if success else return false
   */
  public void readPoint(BigByteBuffer2 input, LidarHeader hdr, long index) {

    try {
      if (index > hdr.getNumPointsRecord() || index < 0) {
        throw new UnexpectedPointException("Out of Index");
      }

      if (index == lasIndex) return;
      else lasIndex = index;

      int auxIndex;
      byte[] punto = new byte[getSizeFormat()];
      byte[] aux = new byte[2];

      input.position(hdr.getOffsetData() + getSizeFormat() * index);
      input.get(punto);

      setClassification((char) (punto[0] & 0xFF));
      setFlightLine((char) (punto[1] & 0xFF));

      aux[0] = punto[2];
      aux[1] = (byte) (punto[3] & 0X3F);
      setIntensity(ByteUtilities.arr2Unsignedshort(aux, 0)); // bits de 0-13
      setEchoInformation((byte) ((punto[3] & 0xC0) >> 2)); // bits 14 y 15

      setX(ByteUtilities.arr2Int(punto, 4));
      setY(ByteUtilities.arr2Int(punto, 8));
      setZ(ByteUtilities.arr2Int(punto, 12));

      auxIndex = 16;

      // si hay gps leelo
      if (isTimeGPS) {
        setTime(ByteUtilities.arr2Int(punto, auxIndex));
        auxIndex += 4;
      }

      // si hay color leelo
      if (isColor) {

        char[] c = new char[4];
        c[0] = (char) (punto[auxIndex] & 0xFF);
        c[1] = (char) (punto[auxIndex + 1] & 0xFF);
        c[2] = (char) (punto[auxIndex + 2] & 0xFF);
        c[3] = (char) (punto[auxIndex + 3] & 0xFF);
        setcolor(c);
      }

    } catch (UnexpectedPointException e) {
      e.printStackTrace();
    }
  }
Example #3
0
  /**
   * Read x and y in point of BIN file
   *
   * @param input input buffer to read
   * @param Offset Offset to data
   * @param index index of points to read
   * @return true if success else return false
   */
  public Point2D.Double readPoint2D(BigByteBuffer2 input, LidarHeader hdr, long index) {

    byte[] punto = new byte[12];

    input.position((hdr.getOffsetData() + getSizeFormat() * index) + 4);
    input.get(punto);

    setX(ByteUtilities.arr2Int(punto, 4));
    setY(ByteUtilities.arr2Int(punto, 8));

    return new Point2D.Double(
        (getX() - hdr.getXOffset()) / hdr.getXScale(),
        (getY() - hdr.getYOffset()) / hdr.getYScale());
  }
Example #4
0
  /**
   * @param name
   * @param f
   * @param numPruebas
   * @throws Exception
   */
  private void prueba2(String name, File f, int numPruebas) throws Exception {
    FileInputStream fin;
    fin = new FileInputStream(f);
    // Open the file and then get a channel from the stream
    FileChannel channel = fin.getChannel();
    int size = (int) channel.size();
    // Get the file's size and then map it into memory
    ByteBuffer bbCorrect = channel.map(FileChannel.MapMode.READ_ONLY, 0, size);
    // Chunkeo a 1KB
    Random rnd = new Random();
    long t1 = System.currentTimeMillis();

    for (int i = 0; i < numPruebas; i++) {
      int pos = rnd.nextInt(size - 10);
      // pos = 0;
      bbCorrect.position(pos);
      int bCorrect = bbCorrect.getInt();
      //            	   bb.position(pos);
      int bPrueba = bb.getInt(pos);
      if (bCorrect != bPrueba) {
        System.err.println(name + "Error de lectura. " + bCorrect + " " + bPrueba);
        throw new Exception("Error con pos=" + pos);
      } else {
        System.out.println(name + "Correcto: pos=" + pos + " byte= " + bPrueba);
      }
    }
    close(channel2, fin2, bb);
    long t2 = System.currentTimeMillis();
    System.out.println("T=" + (t2 - t1) + "mseconds");
  }