Search in sources :

Example 1 with PrimeMeridian

use of com.revolsys.geometry.cs.PrimeMeridian in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadDatum.

private static void loadDatum() {
    final IntHashMap<Ellipsoid> ellipsoids = loadEllipsoid();
    try (ChannelReader reader = newChannelReader("datum")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final int datumType = reader.getByte();
            final Ellipsoid ellipsoid = readCode(reader, ellipsoids);
            final PrimeMeridian primeMeridian = readCode(reader, PRIME_MERIDIAN_BY_ID);
            final Area area = readCode(reader, AREA_BY_ID);
            final boolean deprecated = readBoolean(reader);
            final EpsgAuthority authority = new EpsgAuthority(id);
            Datum datum;
            if (datumType == 0) {
                datum = new GeodeticDatum(authority, name, area, deprecated, ellipsoid, primeMeridian);
            } else if (datumType == 1) {
                datum = new VerticalDatum(authority, name, area, deprecated);
            } else if (datumType == 2) {
                datum = new EngineeringDatum(authority, name, area, deprecated);
            } else {
                throw new IllegalArgumentException("Unknown datumType=" + datumType);
            }
            DATUM_BY_ID.put(id, datum);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
}
Also used : WrappedException(com.revolsys.util.WrappedException) Datum(com.revolsys.geometry.cs.datum.Datum) EngineeringDatum(com.revolsys.geometry.cs.datum.EngineeringDatum) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) GeodeticDatum(com.revolsys.geometry.cs.datum.GeodeticDatum) VerticalDatum(com.revolsys.geometry.cs.datum.VerticalDatum) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) PrimeMeridian(com.revolsys.geometry.cs.PrimeMeridian) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) EngineeringDatum(com.revolsys.geometry.cs.datum.EngineeringDatum) Area(com.revolsys.geometry.cs.Area) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) Ellipsoid(com.revolsys.geometry.cs.Ellipsoid)

Example 2 with PrimeMeridian

use of com.revolsys.geometry.cs.PrimeMeridian 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 3 with PrimeMeridian

use of com.revolsys.geometry.cs.PrimeMeridian 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 4 with PrimeMeridian

use of com.revolsys.geometry.cs.PrimeMeridian 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 5 with PrimeMeridian

use of com.revolsys.geometry.cs.PrimeMeridian 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

PrimeMeridian (com.revolsys.geometry.cs.PrimeMeridian)7 GeodeticDatum (com.revolsys.geometry.cs.datum.GeodeticDatum)6 AngularUnit (com.revolsys.geometry.cs.unit.AngularUnit)5 Authority (com.revolsys.geometry.cs.Authority)3 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)3 GeographicCoordinateSystem (com.revolsys.geometry.cs.GeographicCoordinateSystem)3 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)3 ChannelReader (com.revolsys.io.channels.ChannelReader)3 WrappedException (com.revolsys.util.WrappedException)3 EOFException (java.io.EOFException)3 Area (com.revolsys.geometry.cs.Area)2 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IntHashMap (com.revolsys.collection.map.IntHashMap)1 Maps (com.revolsys.collection.map.Maps)1 Axis (com.revolsys.geometry.cs.Axis)1 BaseAuthority (com.revolsys.geometry.cs.BaseAuthority)1 CompoundCoordinateSystem (com.revolsys.geometry.cs.CompoundCoordinateSystem)1 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)1