Search in sources :

Example 21 with ChannelReader

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

the class ScaledIntegerGriddedDigitalElevationModelFile method readHeader.

private void readHeader() {
    try {
        final ChannelReader reader = getReader();
        final byte[] fileTypeBytes = new byte[6];
        this.reader.getBytes(fileTypeBytes);
        @SuppressWarnings("unused") final String // File
        fileType = new String(fileTypeBytes, StandardCharsets.UTF_8);
        // type
        final short version = this.reader.getShort();
        final GeometryFactory geometryFactory = GeometryFactory.readOffsetScaled3d(this.reader);
        this.scaleZ = geometryFactory.getScaleZ();
        final double minX = reader.getDouble();
        final double minY = reader.getDouble();
        final double minZ = reader.getDouble();
        final double maxX = reader.getDouble();
        final double maxY = reader.getDouble();
        final double maxZ = reader.getDouble();
        // Grid Cell Size
        final int gridCellSize = reader.getInt();
        // Grid Width
        final int gridWidth = reader.getInt();
        // Grid Height
        final int gridHeight = reader.getInt();
        setGeometryFactory(geometryFactory);
        final BoundingBox boundingBox = geometryFactory.newBoundingBox(3, minX, minY, minZ, maxX, maxY, maxZ);
        setBoundingBox(boundingBox);
        setGridCellSize(gridCellSize);
        setGridWidth(gridWidth);
        setGridHeight(gridHeight);
    } catch (final IOException e) {
        throw Exceptions.wrap("Unable to read: " + this.path, e);
    }
}
Also used : ChannelReader(com.revolsys.io.channels.ChannelReader) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) BoundingBox(com.revolsys.geometry.model.BoundingBox) IOException(java.io.IOException)

Example 22 with ChannelReader

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

the class BynReader method close.

@Override
public void close() {
    super.close();
    final ChannelReader reader = this.reader;
    this.reader = null;
    if (reader != null) {
        reader.close();
    }
    this.resource = null;
}
Also used : ChannelReader(com.revolsys.io.channels.ChannelReader)

Example 23 with ChannelReader

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

the class EpsgCoordinateSystems method loadCoordinateAxisNames.

private static void loadCoordinateAxisNames() {
    try (ChannelReader reader = newChannelReader("coordinateAxisName")) {
        while (true) {
            final int code = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final AxisName axisName = new AxisName(code, name);
            AXIS_NAMES.putInt(code, axisName);
            AXIS_NAME_BY_NAME.put(name.toLowerCase(), axisName);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
}
Also used : NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) AxisName(com.revolsys.geometry.cs.AxisName) WrappedException(com.revolsys.util.WrappedException) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString)

Example 24 with ChannelReader

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

the class EpsgCoordinateSystems method loadCoordOperationParamUsage.

private static void loadCoordOperationParamUsage(final IntHashMap<List<ParameterName>> paramOrderByMethodId, final IntHashMap<List<Byte>> paramReversal) {
    try (ChannelReader reader = newChannelReader("coordOperationParamUsage")) {
        while (true) {
            final int methodId = reader.getInt();
            final ParameterName parameterName = readCode(reader, PARAM_NAME_BY_ID);
            final int sortOrder = reader.getInt();
            final byte signReversal = reader.getByte();
            Maps.addToList(paramOrderByMethodId, methodId, parameterName);
            Maps.addToList(paramReversal, methodId, signReversal);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            Logs.error(EpsgCoordinateSystems.class, "Error loading coordOperationParamValue", e);
        }
    }
}
Also used : NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) WrappedException(com.revolsys.util.WrappedException) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) ParameterName(com.revolsys.geometry.cs.ParameterName)

Example 25 with ChannelReader

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

the class EpsgCoordinateSystems method loadEllipsoid.

private static IntHashMap<Ellipsoid> loadEllipsoid() {
    final IntHashMap<Ellipsoid> ellipsoids = new IntHashMap<>();
    try (ChannelReader reader = newChannelReader("ellipsoid")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final int unitId = reader.getInt();
            final LinearUnit unit = (LinearUnit) UNIT_BY_ID.get(unitId);
            final double semiMinorAxis = unit.toBase(reader.getDouble());
            final double semiMajorAxis = unit.toBase(reader.getDouble());
            final double inverseFlattening = unit.toBase(reader.getDouble());
            final int ellipsoidShape = reader.getByte();
            final boolean deprecated = readBoolean(reader);
            final EpsgAuthority authority = new EpsgAuthority(id);
            final Ellipsoid ellipsoid = new Ellipsoid(name, semiMajorAxis, semiMinorAxis, inverseFlattening, authority, deprecated);
            ellipsoids.put(id, ellipsoid);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
    return ellipsoids;
}
Also used : WrappedException(com.revolsys.util.WrappedException) LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) IntHashMap(com.revolsys.collection.map.IntHashMap) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) Ellipsoid(com.revolsys.geometry.cs.Ellipsoid)

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