use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class EsriCoordinateSystems method getVerticalCoordinateSystem.
public static VerticalCoordinateSystem getVerticalCoordinateSystem(final int id) {
VerticalCoordinateSystem coordinateSystem = (VerticalCoordinateSystem) COORDINATE_SYSTEM_BY_ID.get(id);
if (coordinateSystem == null) {
try (final ChannelReader reader = ChannelReader.newChannelReader("classpath:CoordinateSystems/esri/Vertical.cs")) {
while (true) {
final int coordinateSystemId = reader.getInt();
final String csName = reader.getStringUtf8ByteCount();
final String datumName = reader.getStringUtf8ByteCount();
final Map<ParameterName, ParameterValue> parameters = readParameters(reader);
final String linearUnitName = reader.getStringUtf8ByteCount();
final double conversionFactor = reader.getDouble();
if (id == coordinateSystemId) {
final VerticalDatum verticalDatum = new VerticalDatum(null, datumName, 0);
LinearUnit linearUnit = LINEAR_UNITS_BY_NAME.get(linearUnitName);
if (linearUnit == null) {
linearUnit = new LinearUnit(linearUnitName, conversionFactor, null);
LINEAR_UNITS_BY_NAME.put(linearUnitName, linearUnit);
}
final Authority authority = new BaseAuthority("ESRI", coordinateSystemId);
coordinateSystem = new VerticalCoordinateSystem(authority, csName, verticalDatum, parameters, linearUnit, Collections.emptyList());
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.util.WrappedException in project com.revolsys.open by revolsys.
the class EsriCoordinateSystems method getCoordinateSystemIdsByDigest.
private static List<Integer> getCoordinateSystemIdsByDigest(final CoordinateSystem coordinateSystem, final ByteArray digest) {
List<Integer> ids = COORDINATE_SYSTEM_IDS_BY_DIGEST.get(digest);
if (ids == null) {
final byte[] bytes = new byte[16];
final ByteArray newDigest = new ByteArray(bytes);
final String type = coordinateSystem.getCoordinateSystemType();
try (ChannelReader reader = ChannelReader.newChannelReader("classpath:CoordinateSystems/esri/" + type + ".digest")) {
while (true) {
reader.getBytes(bytes);
final short count = reader.getShort();
if (digest.equals(newDigest)) {
ids = new ArrayList<>();
for (int i = 0; i < count; i++) {
final int csId = reader.getInt();
ids.add(csId);
}
COORDINATE_SYSTEM_IDS_BY_DIGEST.put(digest, ids);
return ids;
} else {
for (int i = 0; i < count; i++) {
reader.getInt();
}
}
}
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
return Collections.emptyList();
} else {
throw e;
}
}
} else {
return ids;
}
}
use of com.revolsys.util.WrappedException in project com.revolsys.open by revolsys.
the class ArcGisResponse method refresh.
@Override
public final void refresh() {
synchronized (this.resfreshSync) {
try (BaseCloseable noCache = FileResponseCache.disable()) {
refreshDo();
this.hasError = false;
} catch (final WrappedException e) {
this.hasError = true;
final Throwable cause = Exceptions.unwrap(e);
if (cause instanceof UnknownHostException) {
Logs.error(this, "Cannot find host " + cause.getMessage());
}
} catch (final Throwable e) {
this.hasError = true;
throw Exceptions.wrap("Unable to initialize: " + this, e);
}
}
}
use of com.revolsys.util.WrappedException 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.util.WrappedException 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);
}
}
}
Aggregations