use of com.revolsys.geometry.cs.unit.AngularUnit in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method loadPrimeMeridians.
private static void loadPrimeMeridians() {
try (ChannelReader reader = newChannelReader("primeMeridian")) {
while (true) {
final int id = reader.getInt();
final String name = reader.getStringUtf8ByteCount();
final AngularUnit unit = (AngularUnit) readCode(reader, UNIT_BY_ID);
final double longitude = reader.getDouble();
final double longitudeDegrees = unit.toDegrees(longitude);
final EpsgAuthority authority = new EpsgAuthority(id);
final PrimeMeridian primeMeridian = new PrimeMeridian(name, longitudeDegrees, authority, false);
PRIME_MERIDIAN_BY_ID.put(id, primeMeridian);
}
} catch (final NoSuchResourceException e) {
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
} else {
throw e;
}
}
}
use of com.revolsys.geometry.cs.unit.AngularUnit in project com.revolsys.open by revolsys.
the class EpsgCsWktWriter method write.
public static void write(final PrintWriter out, final GeographicCoordinateSystem coordinateSystem) {
if (coordinateSystem != null) {
out.print("GEOGCS[");
write(out, coordinateSystem.getCoordinateSystemName());
final GeodeticDatum geodeticDatum = coordinateSystem.getDatum();
write(out, geodeticDatum);
final PrimeMeridian primeMeridian = coordinateSystem.getPrimeMeridian();
write(out, primeMeridian);
final AngularUnit unit = coordinateSystem.getAngularUnit();
write(out, unit);
final Authority authority = coordinateSystem.getAuthority();
write(out, authority);
out.write(']');
}
}
use of com.revolsys.geometry.cs.unit.AngularUnit in project com.revolsys.open by revolsys.
the class EsriCsWktWriter method write.
public static void write(final Writer out, final GeographicCoordinateSystem coordinateSystem, final int indentLevel) throws IOException {
out.write("GEOGCS[");
write(out, coordinateSystem.getCoordinateSystemName(), incrementIndent(indentLevel));
final GeodeticDatum geodeticDatum = coordinateSystem.getDatum();
if (geodeticDatum != null) {
out.write(",");
indent(out, incrementIndent(indentLevel));
write(out, geodeticDatum, incrementIndent(indentLevel));
}
final PrimeMeridian primeMeridian = coordinateSystem.getPrimeMeridian();
if (primeMeridian != null) {
out.write(",");
indent(out, incrementIndent(indentLevel));
write(out, primeMeridian, incrementIndent(indentLevel));
}
final AngularUnit unit = coordinateSystem.getAngularUnit();
if (unit != null) {
write(out, unit, incrementIndent(indentLevel));
}
indent(out, indentLevel);
out.write(']');
}
use of com.revolsys.geometry.cs.unit.AngularUnit in project com.revolsys.open by revolsys.
the class WktCsParser method processGeographicCoordinateSystem.
private GeographicCoordinateSystem processGeographicCoordinateSystem(final List<Object> values) {
final String name = (String) values.get(0);
final GeodeticDatum geodeticDatum = (GeodeticDatum) values.get(1);
final PrimeMeridian primeMeridian = (PrimeMeridian) values.get(2);
final AngularUnit angularUnit = (AngularUnit) values.get(3);
int index = 4;
List<Axis> axis = null;
if (index < values.size() && values.get(index) instanceof Axis) {
axis = Arrays.asList((Axis) values.get(index++), (Axis) values.get(index++));
}
Authority authority = null;
if (index < values.size()) {
authority = (Authority) values.get(index);
}
final int coordinateSystemId = getCoordinateSystemId(authority);
return new GeographicCoordinateSystem(coordinateSystemId, name, geodeticDatum, primeMeridian, angularUnit, axis, authority);
}
use of com.revolsys.geometry.cs.unit.AngularUnit in project com.revolsys.open by revolsys.
the class EsriCoordinateSystemsLoader method geographic.
private void geographic() {
final Map<ByteArray, Map<Integer, GeographicCoordinateSystem>> csBymd5 = new LinkedHashMap<>();
try (RecordReader reader = RecordReader.newRecordReader(this.mainPath + "data/esri/esriGeographicCs.tsv");
final ChannelWriter writer = ChannelWriter.newChannelWriter(this.mainPath + "resources/CoordinateSystems/esri/Geographic.cs")) {
for (final Record record : reader) {
final int id = record.getInteger("ID");
final String wkt = record.getString("WKT");
final GeographicCoordinateSystem coordinateSystem = WktCsParser.read(wkt);
final byte[] digest = coordinateSystem.md5Digest();
Maps.addToMap(Maps::newTree, csBymd5, new ByteArray(digest), id, coordinateSystem);
final GeodeticDatum datum = coordinateSystem.getDatum();
final Ellipsoid ellipsoid = datum.getEllipsoid();
final PrimeMeridian primeMeridian = coordinateSystem.getPrimeMeridian();
final AngularUnit angularUnit = coordinateSystem.getAngularUnit();
final String csName = coordinateSystem.getCoordinateSystemName();
this.geographicIdByName.put(csName, id);
final String datumName = datum.getName();
final String spheroidName = ellipsoid.getName();
final double semiMajorAxis = ellipsoid.getSemiMajorAxis();
final double inverseFlattening = ellipsoid.getInverseFlattening();
final String primeMeridianName = primeMeridian.getName();
final double longitude = primeMeridian.getLongitude();
final String angularUnitName = angularUnit.getName();
final double conversionFactor = angularUnit.getConversionFactor();
writer.putInt(id);
writer.putStringUtf8ByteCount(csName);
writer.putStringUtf8ByteCount(datumName);
writer.putStringUtf8ByteCount(spheroidName);
writer.putDouble(semiMajorAxis);
writer.putDouble(inverseFlattening);
writer.putStringUtf8ByteCount(primeMeridianName);
writer.putDouble(longitude);
writer.putStringUtf8ByteCount(angularUnitName);
writer.putDouble(conversionFactor);
}
}
writeDigestFile(csBymd5, "Geographic");
}
Aggregations