Class TimeZoneEngine

  • All Implemented Interfaces:
    java.io.Serializable

    public final class TimeZoneEngine
    extends java.lang.Object
    implements java.io.Serializable
    Class TimeZoneEngine is used to lookup the instance of ZoneId based on latitude and longitude.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.time.ZoneId> getKnownZoneIds()
      Returns all the time zones that can be looked up.
      static TimeZoneEngine initialize()
      Creates a new instance of TimeZoneEngine and initializes it.
      static TimeZoneEngine initialize​(boolean accelerateGeometry)
      Creates a new instance of TimeZoneEngine and initializes it.
      static TimeZoneEngine initialize​(double minLat, double minLon, double maxLat, double maxLon, boolean accelerateGeometry)
      Creates a new instance of TimeZoneEngine and initializes it.
      static TimeZoneEngine initialize​(double minLat, double minLon, double maxLat, double maxLon, boolean accelerateGeometry, org.apache.commons.compress.archivers.tar.TarArchiveInputStream f)
      Creates a new instance of TimeZoneEngine and initializes it from a given TarArchiveInputStream.
      static TimeZoneEngine initialize​(org.apache.commons.compress.archivers.tar.TarArchiveInputStream f)
      Creates a new instance of TimeZoneEngine and initializes it.
      java.util.Optional<java.time.ZoneId> query​(double latitude, double longitude)
      Queries the TimeZoneEngine for a ZoneId based on geo coordinates.
      java.util.List<java.time.ZoneId> queryAll​(double latitude, double longitude)
      Queries the TimeZoneEngine for a ZoneId based on geo coordinates.
      java.util.List<SameZoneSpan> queryPolyline​(double[] points)
      Queries the TimeZoneEngine for a ZoneId based on sequence of geo coordinates
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • queryAll

        public java.util.List<java.time.ZoneId> queryAll​(double latitude,
                                                         double longitude)
        Queries the TimeZoneEngine for a ZoneId based on geo coordinates.
        Parameters:
        latitude - latitude part of query
        longitude - longitude part of query
        Returns:
        List of all zones at given geo coordinate. Normally it's just one zone, but for several places in the world there might be more.
      • query

        public java.util.Optional<java.time.ZoneId> query​(double latitude,
                                                          double longitude)
        Queries the TimeZoneEngine for a ZoneId based on geo coordinates.
        Parameters:
        latitude - latitude part of query
        longitude - longitude part of query
        Returns:
        Optional<ZoneId>#of(ZoneId) if input corresponds to some zone, or Optional.empty() otherwise.
      • queryPolyline

        public java.util.List<SameZoneSpan> queryPolyline​(double[] points)
        Queries the TimeZoneEngine for a ZoneId based on sequence of geo coordinates
        Parameters:
        points - array of doubles representing the sequence of geo coordinates Must have the following shape: {lat_1, lon_1, lat_2, lon_2, ..., lat_N, lon_N}
        Returns:
        Sequence of SameZoneSpan, where SameZoneSpan.getEndIndex() represents the last index in the {@param points} array, which belong to the value of SameZoneSpan.getZoneIds() E.g. for {@param points} == {lat_1, lon_1, lat_2, lon_2, lat_3, lon_3}, that is, a polyline of 3 points: point_1, point_2, and point_3, and presuming point_1 belongs to Etc/GMT+1, point_2 belongs to Etc/GMT+2, and point_3 belongs to Etc/Gmt+3, the result will be: {SameZoneSpan(Etc/Gmt+1, 1), SameZoneSpan(Etc/Gmt+2, 3), SameZoneSpan(Etc/Gmt+3, 5)}
      • getKnownZoneIds

        public java.util.List<java.time.ZoneId> getKnownZoneIds()
        Returns all the time zones that can be looked up.
        Returns:
        all the time zones that can be looked up.
      • initialize

        public static TimeZoneEngine initialize​(boolean accelerateGeometry)
        Creates a new instance of TimeZoneEngine and initializes it. This is a blocking long running operation.
        Returns:
        an initialized instance of TimeZoneEngine
      • initialize

        public static TimeZoneEngine initialize()
        Creates a new instance of TimeZoneEngine and initializes it. This is a blocking long running operation.
        Returns:
        an initialized instance of TimeZoneEngine
      • initialize

        public static TimeZoneEngine initialize​(org.apache.commons.compress.archivers.tar.TarArchiveInputStream f)
        Creates a new instance of TimeZoneEngine and initializes it. This is a blocking long running operation.

        Example invocation:

        {{{ try (InputStream resourceAsStream = new FileInputStream("./core/target/resource_managed/main/data.tar.zstd"); TarArchiveInputStream f = new TarArchiveInputStream(new ZstdCompressorInputStream(resourceAsStream))) { return TimeZoneEngine.initialize(f); } catch (NullPointerException | IOException e) { throw new RuntimeException(e); } }}}

        Returns:
        an initialized instance of TimeZoneEngine
      • initialize

        public static TimeZoneEngine initialize​(double minLat,
                                                double minLon,
                                                double maxLat,
                                                double maxLon,
                                                boolean accelerateGeometry,
                                                org.apache.commons.compress.archivers.tar.TarArchiveInputStream f)
        Creates a new instance of TimeZoneEngine and initializes it from a given TarArchiveInputStream. This is a blocking long running operation. The InputStream resource must be managed by the caller.

        Example invocation: {{{ try (InputStream resourceAsStream = new FileInputStream("./core/target/resource_managed/main/data.tar.zstd"); TarArchiveInputStream f = new TarArchiveInputStream(new ZstdCompressorInputStream(resourceAsStream))) { return TimeZoneEngine.initialize(47.0599, 4.8237, 55.3300, 15.2486, true, f); } catch (NullPointerException | IOException e) { throw new RuntimeException(e); } }}}

        Returns:
        an initialized instance of TimeZoneEngine
      • initialize

        public static TimeZoneEngine initialize​(double minLat,
                                                double minLon,
                                                double maxLat,
                                                double maxLon,
                                                boolean accelerateGeometry)
        Creates a new instance of TimeZoneEngine and initializes it. This is a blocking long running operation.
        Returns:
        an initialized instance of TimeZoneEngine