Bryce L Nordgren a écrit :
(For those who are wondering why I care: consider that the "evaluate"
method of a Coverage takes a DirectPosition, which is an array of doubles.
So what is the unit of the time axis?  Absolute time?  A time interval in
years, months, days, seconds, or timesteps?)

We can get this information from the CoordinateReferenceSystem. The information is not immediate however; there is a fair amount of indirection levels. We have to check if the CRS is an instance of TemporalCRS. If it is not, then we have to check if the CRS is an instance of CompoundCRS, and then check if one of the CRS elements (as returned by the getCoordinateReferenceSystems() method, or the "includesCRS" association in ISO 19111) is an instanceof of TemporalCRS.

Once we have the TemporalCRS, we can get the temporal unit with:

   Unit unit = crs.getCoordinateSystem().getAxis(0).getUnit();

and the epoch (for example January 1st, 1970 00:00 UTC on Unix machine) with:

   Date epoch = crs.getDatum().getOrigin();

You now have enough informations for conversions to arbitrary time units. For example conversions to a java.util.Date object can be performed with the following code (note: Unit, Converter and SI are part of the Unit framework, not GeoAPI):

  long origin = epoch.getTime();
  Converter toMillis = unit.getConverterTo(SI.MILLI(SI.SECOND));
  Date time = new Date(Math.round(toMillis.convert(t)) + origin);

Note: Geotools implementation has a convenience method doing exactly that: DefaultTemporalCRS.toDate(double)

This mean that GeoAPI already has some minimal capability to answer the question "what is the unit of the time axis". However, it is possible to go further and to express the time according some calendar (using year or month units, which are more complex than second units for example). Maybe this is what ISO 19108 does. I can't tell, since I didn't had a chance to look at ISO 19108 yet.

        Martin.



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to