Search in sources :

Example 6 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class LasPointCloud method forEachPointLazChunked.

private void forEachPointLazChunked(final ArithmeticDecoder decoder, final LazDecompress[] pointDecompressors, final Consumer<? super LasPoint> action) {
    final ChannelReader reader = this.reader;
    final long chunkTableOffset = reader.getLong();
    final long chunkSize = getLasZipHeader().getChunkSize();
    long chunkReadCount = chunkSize;
    final long pointCount = getPointCount();
    for (int i = 0; i < pointCount; i++) {
        final LasPoint point;
        final LasPointFormat pointFormat = getPointFormat();
        if (chunkSize == chunkReadCount) {
            point = pointFormat.readLasPoint(this, reader);
            for (final LazDecompress pointDecompressor : pointDecompressors) {
                pointDecompressor.init(point);
            }
            decoder.reset();
            chunkReadCount = 0;
        } else {
            point = pointFormat.newLasPoint(this);
            for (final LazDecompress pointDecompressor : pointDecompressors) {
                pointDecompressor.read(point);
            }
        }
        action.accept(point);
        chunkReadCount++;
    }
}
Also used : ChannelReader(com.revolsys.io.channels.ChannelReader) LazDecompress(com.revolsys.elevation.cloud.las.zip.LazDecompress) LasPoint(com.revolsys.elevation.cloud.las.pointformat.LasPoint) LasPointFormat(com.revolsys.elevation.cloud.las.pointformat.LasPointFormat) LasPoint(com.revolsys.elevation.cloud.las.pointformat.LasPoint) Point(com.revolsys.geometry.model.Point)

Example 7 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class LasPointCloud method close.

@Override
public void close() {
    final ChannelReader reader = this.reader;
    this.reader = null;
    if (reader != null) {
        reader.close();
    }
    if (this.zipIn != null) {
        try {
            this.zipIn.close();
        } catch (final IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : ChannelReader(com.revolsys.io.channels.ChannelReader) IOException(java.io.IOException)

Example 8 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class LasPointCloud method forEachPointLazPointwise.

private void forEachPointLazPointwise(final ArithmeticDecoder decoder, final LazDecompress[] pointDecompressors, final Consumer<? super LasPoint> action) {
    final LasPointFormat pointFormat = getPointFormat();
    {
        final ChannelReader reader = this.reader;
        final LasPoint point = pointFormat.readLasPoint(this, reader);
        for (final LazDecompress pointDecompressor : pointDecompressors) {
            pointDecompressor.init(point);
        }
        decoder.reset();
        action.accept(point);
    }
    final long pointCount = getPointCount();
    for (int i = 1; i < pointCount; i++) {
        final LasPoint point = pointFormat.newLasPoint(this);
        for (final LazDecompress pointDecompressor : pointDecompressors) {
            pointDecompressor.read(point);
        }
        action.accept(point);
    }
}
Also used : ChannelReader(com.revolsys.io.channels.ChannelReader) LazDecompress(com.revolsys.elevation.cloud.las.zip.LazDecompress) LasPointFormat(com.revolsys.elevation.cloud.las.pointformat.LasPointFormat) LasPoint(com.revolsys.elevation.cloud.las.pointformat.LasPoint) LasPoint(com.revolsys.elevation.cloud.las.pointformat.LasPoint) Point(com.revolsys.geometry.model.Point)

Example 9 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class ArithmeticDecoder method renormDecoderInterval.

private void renormDecoderInterval() {
    final ChannelReader reader = this.reader;
    int value = this.value;
    int length = this.length;
    do {
        // read least-significant byte
        final byte b = reader.getByte();
        value = value << 8 | b & 0xff;
        // multiplied by 256
        length <<= 8;
    } while (Integer.compareUnsigned(length, AC_MIN_LENGTH) < 0);
    this.value = value;
    this.length = length;
}
Also used : ChannelReader(com.revolsys.io.channels.ChannelReader)

Example 10 with ChannelReader

use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadCoordinateAxis.

private static IntHashMap<List<Axis>> loadCoordinateAxis() {
    final IntHashMap<List<Axis>> axisesByCoordinateSystemId = new IntHashMap<>();
    try (ChannelReader reader = newChannelReader("coordinateAxis")) {
        while (true) {
            final int coordinateSystemId = reader.getInt();
            final AxisName axisName = readCode(reader, AXIS_NAMES);
            final String orientation = reader.getStringUtf8ByteCount();
            final Character abbreviation = (char) reader.getByte();
            final UnitOfMeasure unitOfMeasure = readCode(reader, UNIT_BY_ID);
            final Axis axis = new Axis(axisName, orientation, abbreviation.toString(), unitOfMeasure);
            List<Axis> axises = axisesByCoordinateSystemId.get(coordinateSystemId);
            if (axises == null) {
                axises = new ArrayList<>();
                axisesByCoordinateSystemId.put(coordinateSystemId, axises);
            }
            axises.add(axis);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
    return axisesByCoordinateSystemId;
}
Also used : WrappedException(com.revolsys.util.WrappedException) UnitOfMeasure(com.revolsys.geometry.cs.unit.UnitOfMeasure) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) IntHashMap(com.revolsys.collection.map.IntHashMap) AxisName(com.revolsys.geometry.cs.AxisName) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) List(java.util.List) ArrayList(java.util.ArrayList) Axis(com.revolsys.geometry.cs.Axis)

Aggregations

ChannelReader (com.revolsys.io.channels.ChannelReader)34 WrappedException (com.revolsys.util.WrappedException)20 EOFException (java.io.EOFException)19 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)14 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)12 ParameterName (com.revolsys.geometry.cs.ParameterName)7 Area (com.revolsys.geometry.cs.Area)4 Authority (com.revolsys.geometry.cs.Authority)4 ParameterValue (com.revolsys.geometry.cs.ParameterValue)4 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)4 IntHashMap (com.revolsys.collection.map.IntHashMap)3 LasPoint (com.revolsys.elevation.cloud.las.pointformat.LasPoint)3 LasPointFormat (com.revolsys.elevation.cloud.las.pointformat.LasPointFormat)3 BaseAuthority (com.revolsys.geometry.cs.BaseAuthority)3 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)3 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)3 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)3 PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)3 GeodeticDatum (com.revolsys.geometry.cs.datum.GeodeticDatum)3 VerticalDatum (com.revolsys.geometry.cs.datum.VerticalDatum)3