Class TimeZoneTree
- Namespace
- TZFinder
- Assembly
- TZFinder.dll
Represents a tree structure for efficiently locating time zones based on geographic coordinates.
public class TimeZoneTree
- Inheritance
-
TimeZoneTree
- Inherited Members
Constructors
TimeZoneTree(string[], TimeZoneNode)
Initializes a new instance of the TimeZoneTree class with the specified time zone identifierss and root node.
protected TimeZoneTree(string[] timeZoneIds, TimeZoneNode root)
Parameters
timeZoneIds
string[]An array of time zone identifiers.
root
TimeZoneNodeThe root node of the time zone tree.
Properties
NodeCount
Gets the number of nodes in the time zone tree.
public int NodeCount { get; }
Property Value
NodeCountRef
Gets a reference to the internal node count of the time zone tree. This property allows direct manipulation of the underlying node count value.
protected ref int NodeCountRef { get; }
Property Value
Root
Gets the root node of the time zone tree.
protected TimeZoneNode Root { get; }
Property Value
TimeZoneIds
Gets the array of time zone identifiers.
protected string[] TimeZoneIds { get; }
Property Value
- string[]
Methods
Deserialize(Stream)
Deserializes a TimeZoneTree from the specified Stream.
public static TimeZoneTree Deserialize(Stream stream)
Parameters
Returns
- TimeZoneTree
The deserialized TimeZoneTree instance.
Get(float, float)
Finds the time zone index, bounding box, and tree level for the specified geographic coordinates.
public (TimeZoneIndex Index, BBox Box, int Level) Get(float longitude, float latitude)
Parameters
longitude
floatThe longitude in degrees, between -180 and 180.
latitude
floatThe latitude in degrees, between -90 and 90.
Returns
- (TimeZoneIndex Index, BBox Box, int Level)
A tuple containing the TimeZoneIndex for the location, the BBox bounding box of the leaf node, and the tree level.
Exceptions
- ArgumentOutOfRangeException
Thrown if
longitude
orlatitude
is out of range.
GetIds(TimeZoneIndex)
Gets the time zone identifiers corresponding to the specified TimeZoneIndex.
public IEnumerable<string> GetIds(TimeZoneIndex index)
Parameters
index
TimeZoneIndexThe time zone index.
Returns
- IEnumerable<string>
An enumerable collection of up to 2 time zone identifiers.
Traverse(Action<TimeZoneIndex, BBox>)
Traverses the tree and invokes the specified action for each leaf node.
public void Traverse(Action<TimeZoneIndex, BBox> action)
Parameters
action
Action<TimeZoneIndex, BBox>The action to invoke, which receives the TimeZoneIndex and BBox of each leaf node.