use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class ScaledIntegerTriangulatedIrregularNetworkReader method forEachTriangle.
public void forEachTriangle(final TriangleConsumer action) {
open();
final GeometryFactory geometryFactory = this.geometryFactory;
final ChannelReader in = this.in;
try {
boolean hasMore = true;
while (hasMore) {
int triangleVertexCount = 0;
try {
final double x1 = geometryFactory.toDoubleX(in.getInt());
final double y1 = geometryFactory.toDoubleY(in.getInt());
final double z1 = geometryFactory.toDoubleZ(in.getInt());
final double x2 = geometryFactory.toDoubleX(in.getInt());
final double y2 = geometryFactory.toDoubleY(in.getInt());
final double z2 = geometryFactory.toDoubleZ(in.getInt());
final double x3 = geometryFactory.toDoubleX(in.getInt());
final double y3 = geometryFactory.toDoubleY(in.getInt());
final double z3 = geometryFactory.toDoubleZ(in.getInt());
action.accept(x1, y1, z1, x2, y2, z2, x3, y3, z3);
triangleVertexCount = 9;
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class) && triangleVertexCount == 0) {
hasMore = false;
} else {
throw e;
}
}
}
} finally {
close();
}
}
use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class ScaledIntegerTriangulatedIrregularNetworkReader method newTriangulatedIrregularNetwork.
public TriangulatedIrregularNetwork newTriangulatedIrregularNetwork() {
open();
int capacity = 10;
int[] triangleXCoordinates = new int[capacity];
int[] triangleYCoordinates = new int[capacity];
int[] triangleZCoordinates = new int[capacity];
int coordinateIndex = 0;
boolean hasMore = true;
while (hasMore) {
try {
if (coordinateIndex >= capacity) {
final int minCapacity = coordinateIndex + 1;
capacity = capacity + (capacity >> 1);
if (capacity - minCapacity < 0) {
capacity = minCapacity;
}
if (capacity - MAX_ARRAY_SIZE > 0) {
if (minCapacity < 0) {
throw new OutOfMemoryError();
} else if (minCapacity > MAX_ARRAY_SIZE) {
capacity = Integer.MAX_VALUE;
} else {
capacity = MAX_ARRAY_SIZE;
}
}
triangleXCoordinates = Arrays.copyOf(triangleXCoordinates, capacity);
triangleYCoordinates = Arrays.copyOf(triangleYCoordinates, capacity);
triangleZCoordinates = Arrays.copyOf(triangleZCoordinates, capacity);
}
triangleXCoordinates[coordinateIndex] = this.in.getInt();
triangleYCoordinates[coordinateIndex] = this.in.getInt();
triangleZCoordinates[coordinateIndex] = this.in.getInt();
coordinateIndex++;
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class) && coordinateIndex % 3 == 0) {
hasMore = false;
} else {
throw e;
}
}
}
triangleXCoordinates = Arrays.copyOf(triangleXCoordinates, coordinateIndex);
triangleYCoordinates = Arrays.copyOf(triangleYCoordinates, coordinateIndex);
triangleZCoordinates = Arrays.copyOf(triangleZCoordinates, coordinateIndex);
final int triangleCount = coordinateIndex / 3;
final IntArrayScaleTriangulatedIrregularNetwork tin = new IntArrayScaleTriangulatedIrregularNetwork(this.geometryFactory, this.boundingBox, triangleCount, triangleXCoordinates, triangleYCoordinates, triangleZCoordinates);
tin.setProperties(getProperties());
return tin;
}
use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class AbstractScaledIntegerPointCloudGeometryReader method getNext.
@SuppressWarnings("unchecked")
@Override
protected G getNext() {
final ChannelReader reader = this.reader;
if (reader == null) {
throw new NoSuchElementException();
} else {
try {
final int xInt = reader.getInt();
final int yInt = reader.getInt();
final int zInt = reader.getInt();
final double x = this.geometryFactory.toDoubleX(xInt);
final double y = this.geometryFactory.toDoubleY(yInt);
final double z = this.geometryFactory.toDoubleZ(zInt);
return (G) this.geometryFactory.point(x, y, z);
} catch (final WrappedException e) {
if (e.getCause() instanceof EOFException) {
throw new NoSuchElementException();
} else {
throw e;
}
}
}
}
use of com.revolsys.util.WrappedException 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;
}
use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method loadCoordOperationMethod.
private static IntHashMap<CoordinateOperationMethod> loadCoordOperationMethod(final IntHashMap<List<ParameterName>> paramOrderByMethodId, final IntHashMap<List<Byte>> paramReversalByMethodId) {
final IntHashMap<CoordinateOperationMethod> methodById = new IntHashMap<>();
try (ChannelReader reader = newChannelReader("coordOperationMethod")) {
while (true) {
final int id = reader.getInt();
final String name = reader.getStringUtf8ByteCount();
final boolean reverse = readBoolean(reader);
final boolean deprecated = readBoolean(reader);
final List<ParameterName> parameterNames = paramOrderByMethodId.getOrDefault(id, Collections.emptyList());
final List<Byte> reversal = paramReversalByMethodId.getOrDefault(id, Collections.emptyList());
final CoordinateOperationMethod method = new CoordinateOperationMethod(id, name, reverse, deprecated, parameterNames);
methodById.put(id, method);
}
} catch (final NoSuchResourceException e) {
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
} else {
throw e;
}
}
return methodById;
}
Aggregations