use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.
the class EsriCoordinateSystems method getGeographicCoordinateSystem.
public static GeographicCoordinateSystem getGeographicCoordinateSystem(final int id) {
GeographicCoordinateSystem coordinateSystem = (GeographicCoordinateSystem) COORDINATE_SYSTEM_BY_ID.get(id);
if (coordinateSystem == null) {
try (final ChannelReader reader = ChannelReader.newChannelReader("classpath:CoordinateSystems/esri/Geographic.cs")) {
while (true) {
final int coordinateSystemId = reader.getInt();
final String csName = reader.getStringUtf8ByteCount();
final String datumName = reader.getStringUtf8ByteCount();
final String spheroidName = reader.getStringUtf8ByteCount();
final double semiMajorAxis = reader.getDouble();
final double inverseFlattening = reader.getDouble();
final String primeMeridianName = reader.getStringUtf8ByteCount();
final double longitude = reader.getDouble();
final String angularUnitName = reader.getStringUtf8ByteCount();
final double conversionFactor = reader.getDouble();
if (id == coordinateSystemId) {
final Ellipsoid ellipsoid = new Ellipsoid(spheroidName, semiMajorAxis, inverseFlattening, null);
final PrimeMeridian primeMeridian = new PrimeMeridian(primeMeridianName, longitude, null);
final GeodeticDatum geodeticDatum = new GeodeticDatum(null, datumName, null, false, ellipsoid, primeMeridian);
AngularUnit angularUnit = ANGULAR_UNITS_BY_NAME.get(angularUnitName);
if (angularUnit == null) {
angularUnit = new AngularUnit(angularUnitName, conversionFactor, null);
ANGULAR_UNITS_BY_NAME.put(angularUnitName, angularUnit);
}
final Authority authority = new BaseAuthority("ESRI", coordinateSystemId);
coordinateSystem = new GeographicCoordinateSystem(coordinateSystemId, csName, geodeticDatum, primeMeridian, angularUnit, null, authority);
COORDINATE_SYSTEM_BY_ID.put(id, coordinateSystem);
return coordinateSystem;
}
}
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
return null;
} else {
Logs.error("Cannot load coordinate system=" + id, e);
throw e;
}
}
}
return coordinateSystem;
}
use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.
the class LasPointCloud method forEachPoint.
@Override
public void forEachPoint(final Consumer<? super LasPoint> action) {
final long pointCount = getPointCount();
try {
final ChannelReader reader = this.reader;
if (reader == null) {
this.points.forEach(action);
} else if (pointCount == 0) {
this.reader = null;
} else if (this.header.isLaszip()) {
forEachPointLaz(action);
} else {
try (BaseCloseable closable = this) {
final LasPointFormat pointFormat = getPointFormat();
for (int i = 0; i < pointCount; i++) {
final LasPoint point = pointFormat.readLasPoint(this, reader);
action.accept(point);
}
}
}
} finally {
this.reader = null;
}
}
use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.
the class ArithmeticDecoder method reset.
public void reset() {
this.length = AC_MAX_LENGTH;
final ChannelReader reader = this.reader;
int value = (reader.getByte() & 0xff) << 24;
value |= (reader.getByte() & 0xff) << 16;
value |= (reader.getByte() & 0xff) << 8;
value |= reader.getByte() & 0xff;
this.value = value;
}
use of com.revolsys.io.channels.ChannelReader in project com.revolsys.open by revolsys.
the class AbstractScaledIntegerPointCloudGeometryReader method initDo.
@Override
protected void initDo() {
super.initDo();
final ChannelReader reader = this.resource.newChannelReader(this.byteBuffer);
this.reader = reader;
if (reader == null) {
this.exists = false;
} else {
this.exists = true;
// File
final String fileType = reader.getString(4, StandardCharsets.UTF_8);
// type
if (!ScaledIntegerPointCloud.FILE_TYPE_HEADER.equals(fileType)) {
throw new IllegalArgumentException("File must start with the text: " + ScaledIntegerPointCloud.FILE_TYPE_HEADER + " not " + fileType);
}
@SuppressWarnings("unused") final short version = reader.getShort();
@SuppressWarnings("unused") final short flags = reader.getShort();
this.geometryFactory = GeometryFactory.readOffsetScaled3d(reader);
}
}
Aggregations