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);
}
}
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;
}
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;
}
}
}
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);
}
}
}
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;
}
Aggregations