Class TimeZoneEngine
- java.lang.Object
-
- net.iakovlev.timeshape.TimeZoneEngine
-
- All Implemented Interfaces:
java.io.Serializable
public final class TimeZoneEngine extends java.lang.Object implements java.io.SerializableClassTimeZoneEngineis used to lookup the instance ofZoneIdbased 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 TimeZoneEngineinitialize()Creates a new instance ofTimeZoneEngineand initializes it.static TimeZoneEngineinitialize(boolean accelerateGeometry)Creates a new instance ofTimeZoneEngineand initializes it.static TimeZoneEngineinitialize(double minLat, double minLon, double maxLat, double maxLon, boolean accelerateGeometry)Creates a new instance ofTimeZoneEngineand initializes it.static TimeZoneEngineinitialize(double minLat, double minLon, double maxLat, double maxLon, boolean accelerateGeometry, org.apache.commons.compress.archivers.tar.TarArchiveInputStream f)Creates a new instance ofTimeZoneEngineand initializes it from a given TarArchiveInputStream.static TimeZoneEngineinitialize(org.apache.commons.compress.archivers.tar.TarArchiveInputStream f)Creates a new instance ofTimeZoneEngineand initializes it.java.util.Optional<java.time.ZoneId>query(double latitude, double longitude)Queries theTimeZoneEnginefor aZoneIdbased on geo coordinates.java.util.List<java.time.ZoneId>queryAll(double latitude, double longitude)Queries theTimeZoneEnginefor aZoneIdbased on geo coordinates.java.util.List<SameZoneSpan>queryPolyline(double[] points)Queries theTimeZoneEnginefor aZoneIdbased on sequence of geo coordinates
-
-
-
Method Detail
-
queryAll
public java.util.List<java.time.ZoneId> queryAll(double latitude, double longitude)Queries theTimeZoneEnginefor aZoneIdbased on geo coordinates.- Parameters:
latitude- latitude part of querylongitude- 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 theTimeZoneEnginefor aZoneIdbased on geo coordinates.- Parameters:
latitude- latitude part of querylongitude- longitude part of query- Returns:
Optional<ZoneId>#of(ZoneId)if input corresponds to some zone, orOptional.empty()otherwise.
-
queryPolyline
public java.util.List<SameZoneSpan> queryPolyline(double[] points)
Queries theTimeZoneEnginefor aZoneIdbased 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, whereSameZoneSpan.getEndIndex()represents the last index in the {@param points} array, which belong to the value ofSameZoneSpan.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 ofTimeZoneEngineand initializes it. This is a blocking long running operation.- Returns:
- an initialized instance of
TimeZoneEngine
-
initialize
public static TimeZoneEngine initialize()
Creates a new instance ofTimeZoneEngineand 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 ofTimeZoneEngineand 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 ofTimeZoneEngineand 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 ofTimeZoneEngineand initializes it. This is a blocking long running operation.- Returns:
- an initialized instance of
TimeZoneEngine
-
-