Search in sources :

Example 1 with IntHashMap

use of com.revolsys.collection.map.IntHashMap 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;
}
Also used : WrappedException(com.revolsys.util.WrappedException) UnitOfMeasure(com.revolsys.geometry.cs.unit.UnitOfMeasure) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) IntHashMap(com.revolsys.collection.map.IntHashMap) AxisName(com.revolsys.geometry.cs.AxisName) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) List(java.util.List) ArrayList(java.util.ArrayList) Axis(com.revolsys.geometry.cs.Axis)

Example 2 with IntHashMap

use of com.revolsys.collection.map.IntHashMap 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;
}
Also used : WrappedException(com.revolsys.util.WrappedException) ParameterName(com.revolsys.geometry.cs.ParameterName) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) IntHashMap(com.revolsys.collection.map.IntHashMap) ChannelReader(com.revolsys.io.channels.ChannelReader) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) EOFException(java.io.EOFException)

Example 3 with IntHashMap

use of com.revolsys.collection.map.IntHashMap in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method initialize.

public static synchronized void initialize() {
    if (!initialized) {
        initialized = true;
        final long startTime = System.currentTimeMillis();
        try {
            loadUnitOfMeasure();
            loadCoordinateAxisNames();
            final IntHashMap<List<Axis>> axisMap = loadCoordinateAxis();
            loadArea();
            loadPrimeMeridians();
            loadDatum();
            loadCoordOperationParam();
            final IntHashMap<List<ParameterName>> paramOrderByMethodId = new IntHashMap<>();
            final IntHashMap<List<Byte>> paramReversalByMethodId = new IntHashMap<>();
            loadCoordOperationParamUsage(paramOrderByMethodId, paramReversalByMethodId);
            final IntHashMap<CoordinateOperationMethod> methodById = loadCoordOperationMethod(paramOrderByMethodId, paramReversalByMethodId);
            final IntHashMap<Map<ParameterName, ParameterValue>> operationParameters = new IntHashMap<>();
            loadCoordOperationParamValue(methodById, operationParameters, paramReversalByMethodId);
            loadCoordOperation(methodById, operationParameters, paramReversalByMethodId);
            loadCoordinateSystem();
            loadCoordinateReferenceSystem(axisMap);
            final ProjectedCoordinateSystem worldMercator = (ProjectedCoordinateSystem) coordinateSystemsById.get(3857);
            coordinateSystemsById.put(900913, worldMercator);
            coordinateSystems = Collections.unmodifiableSet(new LinkedHashSet<>(coordinateSystemsById.values()));
            Dates.debugEllapsedTime(EpsgCoordinateSystems.class, "initialize", startTime);
        } catch (final Throwable t) {
            t.printStackTrace();
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) IntHashMap(com.revolsys.collection.map.IntHashMap) CoordinateOperationMethod(com.revolsys.geometry.cs.CoordinateOperationMethod) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) IntHashMap(com.revolsys.collection.map.IntHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 4 with IntHashMap

use of com.revolsys.collection.map.IntHashMap in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method loadEllipsoid.

private static IntHashMap<Ellipsoid> loadEllipsoid() {
    final IntHashMap<Ellipsoid> ellipsoids = new IntHashMap<>();
    try (ChannelReader reader = newChannelReader("ellipsoid")) {
        while (true) {
            final int id = reader.getInt();
            final String name = reader.getStringUtf8ByteCount();
            final int unitId = reader.getInt();
            final LinearUnit unit = (LinearUnit) UNIT_BY_ID.get(unitId);
            final double semiMinorAxis = unit.toBase(reader.getDouble());
            final double semiMajorAxis = unit.toBase(reader.getDouble());
            final double inverseFlattening = unit.toBase(reader.getDouble());
            final int ellipsoidShape = reader.getByte();
            final boolean deprecated = readBoolean(reader);
            final EpsgAuthority authority = new EpsgAuthority(id);
            final Ellipsoid ellipsoid = new Ellipsoid(name, semiMajorAxis, semiMinorAxis, inverseFlattening, authority, deprecated);
            ellipsoids.put(id, ellipsoid);
        }
    } catch (final NoSuchResourceException e) {
    } catch (final WrappedException e) {
        if (Exceptions.isException(e, EOFException.class)) {
        } else {
            throw e;
        }
    }
    return ellipsoids;
}
Also used : WrappedException(com.revolsys.util.WrappedException) LinearUnit(com.revolsys.geometry.cs.unit.LinearUnit) ParameterValueString(com.revolsys.geometry.cs.ParameterValueString) NoSuchResourceException(com.revolsys.spring.resource.NoSuchResourceException) IntHashMap(com.revolsys.collection.map.IntHashMap) ChannelReader(com.revolsys.io.channels.ChannelReader) EOFException(java.io.EOFException) Ellipsoid(com.revolsys.geometry.cs.Ellipsoid)

Aggregations

IntHashMap (com.revolsys.collection.map.IntHashMap)4 ParameterValueString (com.revolsys.geometry.cs.ParameterValueString)3 ChannelReader (com.revolsys.io.channels.ChannelReader)3 NoSuchResourceException (com.revolsys.spring.resource.NoSuchResourceException)3 WrappedException (com.revolsys.util.WrappedException)3 EOFException (java.io.EOFException)3 CoordinateOperationMethod (com.revolsys.geometry.cs.CoordinateOperationMethod)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Axis (com.revolsys.geometry.cs.Axis)1 AxisName (com.revolsys.geometry.cs.AxisName)1 Ellipsoid (com.revolsys.geometry.cs.Ellipsoid)1 ParameterName (com.revolsys.geometry.cs.ParameterName)1 ProjectedCoordinateSystem (com.revolsys.geometry.cs.ProjectedCoordinateSystem)1 LinearUnit (com.revolsys.geometry.cs.unit.LinearUnit)1 UnitOfMeasure (com.revolsys.geometry.cs.unit.UnitOfMeasure)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1