Search in sources :

Example 1 with AngularUnit

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;
        }
    }
}
Also used : NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) WrappedException(com.revolsys.util.WrappedException) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) AngularUnit(com.revolsys.geometry.cs.unit.AngularUnit) PrimeMeridian(com.revolsys.geometry.cs.PrimeMeridian)

Example 2 with AngularUnit

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(']');
    }
}
Also used : Authority(com.revolsys.geometry.cs.Authority) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) PrimeMeridian(com.revolsys.geometry.cs.PrimeMeridian) AngularUnit(com.revolsys.geometry.cs.unit.AngularUnit)

Example 3 with AngularUnit

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(']');
}
Also used : GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) PrimeMeridian(com.revolsys.geometry.cs.PrimeMeridian) AngularUnit(com.revolsys.geometry.cs.unit.AngularUnit)

Example 4 with AngularUnit

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);
}
Also used : GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) AngularUnit(com.revolsys.geometry.cs.unit.AngularUnit)

Example 5 with AngularUnit

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");
}
Also used : RecordReader(com.revolsys.record.io.RecordReader) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) PrimeMeridian(com.revolsys.geometry.cs.PrimeMeridian) AngularUnit(com.revolsys.geometry.cs.unit.AngularUnit) LinkedHashMap(java.util.LinkedHashMap) ChannelWriter(com.revolsys.io.channels.ChannelWriter) Maps(com.revolsys.collection.map.Maps) Record(com.revolsys.record.Record) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Ellipsoid(com.revolsys.geometry.cs.Ellipsoid)

Aggregations

AngularUnit (com.revolsys.geometry.cs.unit.AngularUnit)7 PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)5 GeodeticDatum (com.revolsys.geometry.cs.datum.GeodeticDatum)5 ChannelReader (com.revolsys.io.channels.ChannelReader)3 WrappedException (com.revolsys.util.WrappedException)3 EOFException (java.io.EOFException)3 Authority (com.revolsys.geometry.cs.Authority)2 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)2 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)2 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)2 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)2 Maps (com.revolsys.collection.map.Maps)1 BaseAuthority (com.revolsys.geometry.cs.BaseAuthority)1 Degree (com.revolsys.geometry.cs.unit.Degree)1 DegreeSexagesimalDMS (com.revolsys.geometry.cs.unit.DegreeSexagesimalDMS)1 Grad (com.revolsys.geometry.cs.unit.Grad)1 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)1 Metre (com.revolsys.geometry.cs.unit.Metre)1 ScaleUnit (com.revolsys.geometry.cs.unit.ScaleUnit)1 TimeUnit (com.revolsys.geometry.cs.unit.TimeUnit)1