final TimeCS sourceCS = sourceCRS.getCoordinateSystem(); final TimeCS targetCS = targetCRS.getCoordinateSystem(); final Unit targetUnit = targetCS.getAxis(0).getUnit(); double epochShift = sourceDatum.getOrigin().getTime() - targetDatum.getOrigin().getTime();
/** Possibly sets {@link #coordinateSystem} to a predefined CS matching the axes defined in the netCDF file. */ @Override void candidate(final Decoder decoder) { final Axis axis = getFirstAxis(); final Unit<?> unit = axis.getUnit(); final CommonCRS.Temporal predefined; if (Units.DAY.equals(unit)) { predefined = CommonCRS.Temporal.JULIAN; } else if (Units.SECOND.equals(unit)) { predefined = CommonCRS.Temporal.UNIX; } else if (Units.MILLISECOND.equals(unit)) { predefined = CommonCRS.Temporal.JAVA; } else { return; } coordinateSystem = predefined.crs().getCoordinateSystem(); }
/** * Verifies the CRS name, datum and axis for {@code TIMECRS[“GPS Time”]}. */ private void verifyGPSTime(final TemporalCRS crs) { verifyIdentification (crs, "GPS Time", null); verifyDatum (crs.getDatum(), "Time origin"); verifyCoordinateSystem (crs.getCoordinateSystem(), TimeCS.class, new AxisDirection[] {FUTURE}, units.day()); assertEquals("TimeOrigin", new Date(315532800000L), crs.getDatum().getOrigin()); }
/** * Validates the given coordinate reference system. * * @param object The object to validate, or {@code null}. */ public void validate(final TemporalCRS object) { if (object == null) { return; } validateReferenceSystem(object); final TimeCS cs = object.getCoordinateSystem(); mandatory("TemporalCRS: must have a CoordinateSystem.", cs); container.cs.validate(cs); final TemporalDatum datum = object.getDatum(); mandatory("TemporalCRS: must have a Datum.", datum); container.datum.validate(datum); }
final TimeCS candidate = crs.getCoordinateSystem(); if (unit.equals(candidate.getAxis(0).getUnit())) { if (datum == candidate && properties.isEmpty()) { if (cs == null) { final CSFactory csFactory = getCSFactory(); cs = CommonCRS.Temporal.JAVA.crs().getCoordinateSystem(); // To be used as a template, except for units. cs = csFactory.createTimeCS(name(cs), csFactory.createCoordinateSystemAxis(name(cs.getAxis(0)), "t", AxisDirection.FUTURE, unit));
final TimeCS candidate = crs.getCoordinateSystem(); if (unit.equals(candidate.getAxis(0).getUnit())) { if (datum == candidate && properties.isEmpty()) { if (cs == null) { final CSFactory csFactory = factories.getCSFactory(); cs = CommonCRS.Temporal.JAVA.crs().getCoordinateSystem(); // To be used as a template, except for units. cs = csFactory.createTimeCS(name(cs), csFactory.createCoordinateSystemAxis(name(cs.getAxis(0)), "t", AxisDirection.FUTURE, unit));
/** * Validates the given coordinate reference system. * * @param object the object to validate, or {@code null}. */ public void validate(final TemporalCRS object) { if (object == null) { return; } validateReferenceSystem(object); final TimeCS cs = object.getCoordinateSystem(); mandatory("TemporalCRS: shall have a CoordinateSystem.", cs); container.validate(cs); final TemporalDatum datum = object.getDatum(); mandatory("TemporalCRS: shall have a Datum.", datum); container.validate(datum); }
default: { return TRUNCATED_JULIAN.crs().getCoordinateSystem(); final TimeCS share = JAVA.crs().getCoordinateSystem(); cs = IdentifiedObjects.getProperties(share, EXCLUDE); axis = IdentifiedObjects.getProperties(share.getAxis(0), EXCLUDE);
default: { return TRUNCATED_JULIAN.crs().getCoordinateSystem(); final TimeCS share = JAVA.crs().getCoordinateSystem(); cs = IdentifiedObjects.getProperties(share, EXCLUDE); axis = IdentifiedObjects.getProperties(share.getAxis(0), EXCLUDE);
/** * Implementation of the public {@code setBounds} methods for the temporal extent. * * @param envelope the source envelope. * @param target the target temporal extent. * @param crs the envelope CRS (mandatory, can not be {@code null}). * @param temporalCRS the temporal component of the given CRS (mandatory). * @throws UnsupportedOperationException if no implementation of {@code TemporalFactory} has been found * on the classpath. */ private static void setTemporalExtent(final Envelope envelope, final DefaultTemporalExtent target, final CoordinateReferenceSystem crs, final TemporalCRS temporalCRS) { final int dim = AxisDirections.indexOfColinear(crs.getCoordinateSystem(), temporalCRS.getCoordinateSystem()); assert dim >= 0 : crs; // Should not fail since 'temporalCRS' has been extracted from 'crs' by the caller. final DefaultTemporalCRS converter = DefaultTemporalCRS.castOrCopy(temporalCRS); target.setBounds(converter.toDate(envelope.getMinimum(dim)), converter.toDate(envelope.getMaximum(dim))); }
final TimeCS sourceCS = sourceCRS.getCoordinateSystem(); final TimeCS targetCS = targetCRS.getCoordinateSystem();
final TimeCS sourceCS = sourceCRS.getCoordinateSystem(); final TimeCS targetCS = targetCRS.getCoordinateSystem();
/** * Implementation of the public {@code setBounds} methods for the temporal extent. * * @param envelope the source envelope. * @param target the target temporal extent. * @param crs the envelope CRS (mandatory, can not be {@code null}). * @param temporalCRS the temporal component of the given CRS (mandatory). * @throws UnsupportedOperationException if no implementation of {@code TemporalFactory} has been found * on the classpath. */ private static void setTemporalExtent(final Envelope envelope, final DefaultTemporalExtent target, final CoordinateReferenceSystem crs, final TemporalCRS temporalCRS) { final int dim = AxisDirections.indexOfColinear(crs.getCoordinateSystem(), temporalCRS.getCoordinateSystem()); assert dim >= 0 : crs; // Should not fail since 'temporalCRS' has been extracted from 'crs' by the caller. final DefaultTemporalCRS converter = DefaultTemporalCRS.castOrCopy(temporalCRS); target.setBounds(TemporalUtilities.toDate(converter.toInstant(envelope.getMinimum(dim))), TemporalUtilities.toDate(converter.toInstant(envelope.getMaximum(dim)))); }