final TemporalDatum sourceDatum = sourceCRS.getDatum(); final TemporalDatum targetDatum = targetCRS.getDatum(); if (!equalsIgnoreMetadata(sourceDatum, targetDatum)) { throw new OperationNotFoundException(getErrorMessage(sourceDatum, targetDatum)); 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();
/** * Returns the datum associated to the given object, or {@code null} if none. */ private static TemporalDatum datum(final IdentifiedObject object) { if (object instanceof TemporalDatum) { return (TemporalDatum) object; } if (object instanceof TemporalCRS) { return ((TemporalCRS) object).getDatum(); } return null; } }
/** 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(); }
/** * Returns the datum associated to the given object, or {@code null} if none. */ private static TemporalDatum datum(final IdentifiedObject object) { if (object instanceof TemporalDatum) { return (TemporalDatum) object; } if (object instanceof TemporalCRS) { return ((TemporalCRS) object).getDatum(); } return null; } }
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));
/** * 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()); }
/** * Constructs a new coordinate reference system with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param crs the coordinate reference system to copy. * * @see #castOrCopy(TemporalCRS) */ protected DefaultTemporalCRS(final TemporalCRS crs) { super(crs); datum = crs.getDatum(); }
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: 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); }
/** * Constructs a new coordinate reference system with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param crs the coordinate reference system to copy. * * @see #castOrCopy(TemporalCRS) */ protected DefaultTemporalCRS(final TemporalCRS crs) { super(crs); datum = crs.getDatum(); initializeConverter(); }
default: { return TRUNCATED_JULIAN.crs().getCoordinateSystem(); final TimeCS share = JAVA.crs().getCoordinateSystem(); cs = IdentifiedObjects.getProperties(share, EXCLUDE); axis = IdentifiedObjects.getProperties(share.getAxis(0), EXCLUDE);
/** * 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); }
epochs [i] = ((TemporalCRS) t).getDatum().getOrigin().getTime(); setConverter(dimension, i, unit.asType(Time.class).getConverterTo(Units.MILLISECOND)); if (AxisDirection.PAST.equals(axis.getDirection())) {
default: { return TRUNCATED_JULIAN.crs().getCoordinateSystem(); final TimeCS share = JAVA.crs().getCoordinateSystem(); cs = IdentifiedObjects.getProperties(share, EXCLUDE); axis = IdentifiedObjects.getProperties(share.getAxis(0), EXCLUDE);
throws FactoryException final TemporalDatum sourceDatum = sourceCRS.getDatum(); final TemporalDatum targetDatum = targetCRS.getDatum(); final TimeCS sourceCS = sourceCRS.getCoordinateSystem(); final TimeCS targetCS = targetCRS.getCoordinateSystem();
epochs [i] = ((TemporalCRS) t).getDatum().getOrigin().getTime(); setConverter(dimension, i, unit.asType(Time.class).getConverterTo(Units.MILLISECOND)); if (AxisDirection.PAST.equals(axis.getDirection())) {
/** * 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))); }
throws FactoryException final TemporalDatum sourceDatum = sourceCRS.getDatum(); final TemporalDatum targetDatum = targetCRS.getDatum(); final TimeCS sourceCS = sourceCRS.getCoordinateSystem(); final TimeCS targetCS = targetCRS.getCoordinateSystem();