Class TLQTNode
Unit
Declaration
type TLQTNode = class(TObject)
Description
TLQTNode A node in the Tree. The node is assumed to be the root node, if the ParentNode is not assigned. The node can contain data items. These data items are generic TObjects. There actual Coordinates are fetched via an Event in the Tree
Hierarchy
- TObject
- TLQTNode
Overview
Fields
![]() |
FTotalNodeItemsCount: Integer; |
Methods
![]() |
function DoFetchItemCoords(const AItemIndex : Integer) : Boolean; virtual; |
![]() |
function GetNodeItemsLength: Integer; virtual; |
![]() |
procedure SetNodeItemsLength(Value : Integer); virtual; |
![]() |
function GetNodeItems(Index : Integer) : TObject; virtual; |
![]() |
procedure SetNodeItems(Index : Integer; Value : TObject); virtual; |
![]() |
function GetAssignedNodeItemsCount: Integer; virtual; |
![]() |
function GetAssignedNodeItems(Index : Integer) : TObject; virtual; |
![]() |
function GetChildNodes(Index : TLQTNodeChildLocation) : TLQTNode; virtual; |
![]() |
function GetChildRects(Index : TLQTNodeChildLocation) : TLQTRect; virtual; |
![]() |
function MoveItemToParentNode(const AItemIndex : Integer; out ATargetItemIndex : Integer) : Boolean; virtual; |
![]() |
function MoveItemToChildNode(const AItemIndex : Integer; out ATargetChildNode : TLQTNode; out ATargetItemIndex : Integer) : Boolean; virtual; |
![]() |
function NodeItemToListEnumerationCallBack(Sender : TObject; ANode : TLQTNode; ANodeItem : TObject; ANodeItemIndex : Integer; AUserData : Pointer) : Boolean; virtual; |
![]() |
function NodeAgglomerationToArrayEnumerationCallBack(ANode : TLQTNode; const ATreeAgglomerationRec : TLQTAgglomerationRec; AUserData : Pointer) : Boolean; |
![]() |
procedure WriteStreamNodeHeader(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure WriteStreamNodeProperties(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure WriteStreamNodeChildren(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure WriteStreamNodeItems(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure WriteStreamNodeItem(const AStream : TStream; const AQuadTreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal; const AItemIndex : Integer); virtual; |
![]() |
procedure ReadStreamNodeHeader(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; out ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure ReadStreamNodeProperties(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure ReadStreamNodeChildren(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure ReadStreamNodeItems(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure ReadStreamNodeItem(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal; const AItemIndex : Integer); virtual; |
![]() |
function UpdateOccupiedRectLocal: Boolean; virtual; |
![]() |
function UpdateOccupiedRect: Boolean; virtual; |
![]() |
function GetOccupiedRect: TLQTRect; virtual; |
![]() |
function CountNodes: Integer; |
![]() |
function CreateOrGetChildNode(const AChildLocation : TLQTNodeChildLocation) : TLQTNode; |
![]() |
procedure DeleteChildNode(const AChildLocation : TLQTNodeChildLocation); |
![]() |
function CoordIsInNodeRect(const AX, AY : Double) : Boolean; virtual; |
![]() |
function FindCoordNode(const AX, AY : Double) : TLQTNode; virtual; |
![]() |
function NodeRectOverlapTest(const ARect : TLQTRect) : TLQTRectOverlapKind; virtual; |
![]() |
function OccupiedRectOverlapTest(const ARect : TLQTRect) : TLQTRectOverlapKind; virtual; |
![]() |
function NodeRectOverlap(const ARect : TLQTRect) : Boolean; virtual; |
![]() |
function AddNodeItem(const AItem : TObject; const APointValid : Boolean = False; const ARectValid : Boolean = False; const APointX : Double = 0.0; const APointY : Double = 0.0; const ARectLeft : Double = 0.0; const ARectTop : Double = 0.0; const ARectRight : Double = 0.0; const ARectBottom : Double = 0.0 ) : Integer; virtual; |
![]() |
function ExtractNodeItem(const AItemIndex : Integer) : TObject; |
![]() |
function ExtractNodeItem(const ANodeItem : TObject) : TObject; |
![]() |
function SplitNode: Boolean; virtual; |
![]() |
function PackNode: Boolean; virtual; |
![]() |
function ExpandNode: Boolean; virtual; |
![]() |
function NodeHasZeroDataItems: Boolean; virtual; |
![]() |
function HasChildNodes: Boolean; |
![]() |
function IsDescendantOf(ANode : TLQTNode) : Boolean; |
![]() |
function NodeItemIndex(const AItem : TObject) : Integer; |
![]() |
function PackNodeItems(const APackToZero : Boolean = False) : Boolean; virtual; |
![]() |
function GetNodesParentChildLocation(var AChildLocation : TLQTNodeChildLocation) : Boolean; |
![]() |
function AgglomerateNodeAsEnumeration(const AAgglomerationDepth : Integer; const AMinimumItemNumberInAgglomeration : Integer; const AItemEnumFunc : TLQTItemEnumerationCallBack; const AItemUserData : Pointer; const AAgglomerationEnumFunc : TLQTAgglomerationEnumerationCallBack; const AAgglomerationUserData : Pointer) : Boolean; virtual; |
![]() |
procedure AgglomerateNodeAsList(const AAgglomerationDepth : Integer; const AMinimumItemNumberInAgglomeration : Integer; var AAgglomerationArray : TLQTAgglomerationArray; const AItemList : TList); |
![]() |
procedure RebuildOccupiedRect; |
![]() |
function NodeAsString: String; virtual; |
![]() |
procedure NodeAsStrings(const AStrings : TStrings); virtual; |
![]() |
procedure Clear; |
![]() |
procedure WriteNodeToStream(const AStream : TStream; const AQuadTreeStreamDataVersion : Cardinal); virtual; |
![]() |
procedure ReadNodeFromStream(const AStream : TStream; const AQuadTreeStreamDataVersion : Cardinal; const AStreamReadOptions : Cardinal = 0); virtual; |
![]() |
constructor Create(const AOwner : TLazQuadTree; const AParentNode : TLQTNode; const ALQTRect : TLQTRect); |
![]() |
destructor Destroy; override; |
Properties
![]() |
property Owner : TLazQuadTree read FOwner; |
![]() |
property ParentNode : TLQTNode read FParentNode; |
![]() |
property ChildNodes[Index:TLQTNodeChildLocation]: TLQTNode read GetChildNodes; |
![]() |
property ChildNodeNE : TLQTNode index nclNE read GetChildNodes; |
![]() |
property ChildNodeSE : TLQTNode index nclSE read GetChildNodes; |
![]() |
property ChildNodeSW : TLQTNode index nclSW read GetChildNodes; |
![]() |
property ChildNodeNW : TLQTNode index nclNW read GetChildNodes; |
![]() |
property ChildRects[Index:TLQTNodeChildLocation]: TLQTRect read GetChildRects; |
![]() |
property NodeLevel : Integer read FNodeLevel; |
![]() |
property NodeRect : TLQTRect read FNodeRect; |
![]() |
property Left : Double read FNodeRect.Left; |
![]() |
property Top : Double read FNodeRect.Top; |
![]() |
property Right : Double read FNodeRect.Right; |
![]() |
property Bottom : Double read FNodeRect.Bottom; |
![]() |
property OccupiedRect : TLQTRect read GetOccupiedRect; |
![]() |
property TotalNodeItemsCount : Integer read FTotalNodeItemsCount write SetTotalNodeItemsCount; |
![]() |
property NodeItemsLength : Integer read GetNodeItemsLength write SetNodeItemsLength; |
![]() |
property NodeItems[Index:Integer]: TObject read GetNodeItems write SetNodeItems; |
![]() |
property AssignedNodeItemsCount : Integer read GetAssignedNodeItemsCount; |
![]() |
property AssignedNodeItems[Index:Integer]: TObject read GetAssignedNodeItems; |
![]() |
property NodeToken : Cardinal read FNodeToken; |
Description
Fields
![]() |
FTotalNodeItemsCount: Integer; |
Methods
![]() |
function GetNodeItemsLength: Integer; virtual; |
![]() |
procedure SetNodeItemsLength(Value : Integer); virtual; |
![]() |
function GetNodeItems(Index : Integer) : TObject; virtual; |
![]() |
procedure SetNodeItems(Index : Integer; Value : TObject); virtual; |
![]() |
function GetAssignedNodeItemsCount: Integer; virtual; |
![]() |
function GetAssignedNodeItems(Index : Integer) : TObject; virtual; |
![]() |
function GetChildNodes(Index : TLQTNodeChildLocation) : TLQTNode; virtual; |
![]() |
function GetChildRects(Index : TLQTNodeChildLocation) : TLQTRect; virtual; |
![]() |
function MoveItemToChildNode(const AItemIndex : Integer; out ATargetChildNode : TLQTNode; out ATargetItemIndex : Integer) : Boolean; virtual; |
MoveItemToChildNode moves the specified item to a fitting childnode The result is true if the movement was succesful, false if not. In the latter case the item was not moved. |
![]() |
function NodeItemToListEnumerationCallBack(Sender : TObject; ANode : TLQTNode; ANodeItem : TObject; ANodeItemIndex : Integer; AUserData : Pointer) : Boolean; virtual; |
NodeItemToListEnumerationCallBack is used by the some ListItems methods to accumlate the found items into a list. Caution: The function assumes that the parameter UserData is a pointer to a TList Descendand! The method is used only internal but is declared protected and virtual for future expansions. If the parameter ANodeItem is Nil, nothing is inserted into the list The result true if the AUserData is assigned, else false |
![]() |
function NodeAgglomerationToArrayEnumerationCallBack(ANode : TLQTNode; const ATreeAgglomerationRec : TLQTAgglomerationRec; AUserData : Pointer) : Boolean; |
NodeAgglomerationEnumerationCallBack is used by the AgglomerateNodeAsList method to store the agglomeration data in the data array Caution: The function assumes that the parameter UserData is a Pointer from the type PLQTAgglomerationArray. The method is used only internal but is declared protected and virtual for future expansions. If the parameter ANodeItem is Nil, nothing is inserted into the list The result true if the AUserData is assigned, else false |
![]() |
procedure WriteStreamNodeItems(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
WriteNodeItems writes the items to the stream |
![]() |
procedure ReadStreamNodeItems(const AStream : TStream; const ATreeStreamDataVersion : Cardinal; const ANodeStreamDataVersion : Cardinal); virtual; |
ReadNodeItems reads the items from the stream |
![]() |
function GetOccupiedRect: TLQTRect; virtual; |
GetOccupiedRect returns the FOccupiedRect field value. The method could be overwritten to implement a different way to obtain the occupied area of the item in the tree |
![]() |
function CountNodes: Integer; |
CountNodes recurses through the Childnodes and return the sum of all nodes below. The minimum result is one, since this node is assigned. |
![]() |
function CreateOrGetChildNode(const AChildLocation : TLQTNodeChildLocation) : TLQTNode; |
CreateOrGetChildNode creates a childnode unless one exists in this location. The result is the new created or the existing ChildNode from this position. CAUTION: If a new childnode is created, the new node tooks all belonging items from his parent node (this node), thus the number of items in this node may be reduced down to zero. A call of AssignedNodeItemsCount might be necesarry! |
![]() |
procedure DeleteChildNode(const AChildLocation : TLQTNodeChildLocation); |
DeleteChildNode deletes the childnode (if existing) and all subchildnodes. The function moves all NodeItems from the deleted ChildNodes to this Node. |
![]() |
function CoordIsInNodeRect(const AX, AY : Double) : Boolean; virtual; |
CoordIsInNodeRect returns true if the Point AX, AY is located within the NodeRect. |
![]() |
function FindCoordNode(const AX, AY : Double) : TLQTNode; virtual; |
FindCoordNode iterates through the part of the tree that is covered by this node. returns the deepest (leaf)node which contains the coordinate. The result is nil, if the coordinate is not located within this part of the tree. |
![]() |
function NodeRectOverlapTest(const ARect : TLQTRect) : TLQTRectOverlapKind; virtual; |
NodeRectOverlapTest returns the Test result of the comparism of ARect with the NodeRect. |
![]() |
function OccupiedRectOverlapTest(const ARect : TLQTRect) : TLQTRectOverlapKind; virtual; |
OccupiedRectOverlapTest returns the Test result of the comparism of ARect with the OccupiedRect. |
![]() |
function NodeRectOverlap(const ARect : TLQTRect) : Boolean; virtual; |
NodeRectOverlap returns true, if ARect overlap at least partly the NodeRect. |
![]() |
function SplitNode: Boolean; virtual; |
SplitNode split the node into child nodes if necesarry. Recurses down with splitting, if necesarry. Returns true, if at least one node is splitted. |
![]() |
function PackNode: Boolean; virtual; |
PackNode tries to remove unused ChildNodes. Recurses down with packing, if useful. Return true if at least one node was combined |
![]() |
function NodeHasZeroDataItems: Boolean; virtual; |
NodeHasZeroDataItems recurses through all subnodes and counts all populated DataItems. If there are none, the result is true. |
![]() |
function HasChildNodes: Boolean; |
HasChildNodes returns true if at least one of the four possible ChildNodes exists |
![]() |
function IsDescendantOf(ANode : TLQTNode) : Boolean; |
IsDescendantOf returns True if this node is an descendand of the passed node, else the Result is false |
![]() |
function NodeItemIndex(const AItem : TObject) : Integer; |
NodeItemIndex returns the Index of the passed Item, -1 if not found |
![]() |
function GetNodesParentChildLocation(var AChildLocation : TLQTNodeChildLocation) : Boolean; |
GetNodesParentChildLocation determine the ChildLocation of this node in its Parent's ChildNode array. The Value is valid if the return value of the function is true. The return value false means, that the Node is the Root node and no parent node is assignd. |
![]() |
function AgglomerateNodeAsEnumeration(const AAgglomerationDepth : Integer; const AMinimumItemNumberInAgglomeration : Integer; const AItemEnumFunc : TLQTItemEnumerationCallBack; const AItemUserData : Pointer; const AAgglomerationEnumFunc : TLQTAgglomerationEnumerationCallBack; const AAgglomerationUserData : Pointer) : Boolean; virtual; |
AgglomerateNodeAsEnumeration build a summary of the Items within this node and his children. The usage is e.g. to build clickable items on a map, which represents a bunch of items below, to prevent that thousands of items will be drawn, while a "10K"-sign would do the job. Another usage would be to colorize parts of an image recording to the "density" of the Agglomerations. Parameters AAgglomerationDepth determines how many node-leves below should be taken into account. Due to the math (every level contains 4 times nodes than the parents level) a value of 1 will return up to 4 agglomeration records, 2 will return 16 and 3 = 64. If one Node cover an square of e.g. 256 pixel (as one OSM-Tile does), a level of 3 will place up to 64 ( = 16 * 16) agglomeration records on this tile. AMinimumItemNumberInAgglomeration will control the minimum ammount in one agglomeration. The value should not be less than MaxQuadNodeItemCount. A good value depends on the Data structure and the tile size. If one agglomeration contains a square of 16 x 16 pixel, the value could be 16 to place (in average) 4 x 4 items in this area. AItemEnumFunc, AAgglomerationEnumFunc both callback function must be provided to allow a sucessful operation. Each function will be called once for every item or build agglomeration. AItemUserData, AAgglomerationUserData are passed unmodified to the callback functions to allow the management of the passed data. |
![]() |
procedure AgglomerateNodeAsList(const AAgglomerationDepth : Integer; const AMinimumItemNumberInAgglomeration : Integer; var AAgglomerationArray : TLQTAgglomerationArray; const AItemList : TList); |
AgglomerateNodeAsList build a summary of the Items within this node and his children. The usage is to build clickable items on a map, which represents a bunch of items below, to prevent that thousands of items will be drawn, while a "10K"-sign would do the job. Parameters AAgglomerationDepth determines how many node-leves below should be taken into account. Due to the math (every level contains 4 times nodes than the parents level) a value of 1 will return up to 4 agglomeration records, 2 will return 16 and 3 = 64. If one Node cover an square of e.g. 256 pixel (as one OSM-Tile does), a level of 3 will place up to 64 ( = 16 * 16) agglomeration records on this tile. AMinimumItemNumberInAgglomeration will control the minimum ammount in one agglomeration. The value should not be less than MaxQuadNodeItemCount. A good value depends on the Data structure and the tile size. If one agglomeration contains a square of 16 x 16 pixel, the value could be 16 to place (in average) 4 x 4 items in this area AAgglomerationArray will be populated with the agglomeration records AItemList must be created prior and freed after the call by the using code. The list will contain the items outside of the agglomerations |
![]() |
procedure RebuildOccupiedRect; |
RebuildOccupiedRect iterate through all Nodes and Items and refreshes the Nodes FOccupiedRect. This method might be useful after a manually reconfiguration of the Tree. |
![]() |
function NodeAsString: String; virtual; |
NodeAsString returns some information of the current node in a string |
![]() |
procedure NodeAsStrings(const AStrings : TStrings); virtual; |
NodeAsStrings returns the content of the Node and its children in readable form for debugging purpose. |
![]() |
procedure Clear; |
Clear recursivly delete all Childnodes. If the related Tree OwnsObjects, all containing Items are freed |
![]() |
procedure WriteNodeToStream(const AStream : TStream; const AQuadTreeStreamDataVersion : Cardinal); virtual; |
WriteNodeToStream writes this Node and all Children into the stream |
![]() |
constructor Create(const AOwner : TLazQuadTree; const AParentNode : TLQTNode; const ALQTRect : TLQTRect); |
Create the Node within the owning Tree, a Parent and an covered Rect. Caution: It is not allowed that Parent- and Child-node have different Owners. Caution: It is assumed that the NodeRect contains a part of the Rect of the Parent, in a way, that the Rects of the four children covers exactly the Rect of the parent node. Saying this, Create will be used in very rare cases outside this unit. |
![]() |
destructor Destroy; override; |
Destroy frees the Node. Clear is called prior inherited destroy, causing all Items are freed, if the owning tree owns the items, and all child nodes are freed. |
Properties
![]() |
property Owner : TLazQuadTree read FOwner; |
Owner: The Tree this node belongs to |
![]() |
property ParentNode : TLQTNode read FParentNode; |
ParentNode: The node, where this node is one of the four ChildNodes. If Nil, this node is the RootNode of the Tree |
![]() |
property ChildNodes[Index:TLQTNodeChildLocation]: TLQTNode read GetChildNodes; |
ChildNodes: Indexed array of the four ChildNode. Each Node covers one quadrant of the Rect of this node |
![]() |
property ChildNodeNE : TLQTNode index nclNE read GetChildNodes; |
![]() |
property ChildNodeSE : TLQTNode index nclSE read GetChildNodes; |
![]() |
property ChildNodeSW : TLQTNode index nclSW read GetChildNodes; |
![]() |
property ChildNodeNW : TLQTNode index nclNW read GetChildNodes; |
![]() |
property ChildRects[Index:TLQTNodeChildLocation]: TLQTRect read GetChildRects; |
ChildRects: Contains the definition of the for quadrants (=Rects) of the ChildNodes. The virtual getter function GetChildRects might be overwritten in derived classes to implement a different distribution to adapt to different projections. |
![]() |
property NodeLevel : Integer read FNodeLevel; |
NodeLevel: The depth of this node. 0 for the RootNode |
![]() |
property NodeRect : TLQTRect read FNodeRect; |
NodeRect: The Rect covered by this node. Care mus be taken, by interpreting the values of the Rect. Depending of the configuration of the WorldRect of the related tree, the value Top is greater or lesser than Bottom. The NodeRect is guaranteed never passing the Borders of the Tree's WorldRect. |
![]() |
property Left : Double read FNodeRect.Left; |
![]() |
property Top : Double read FNodeRect.Top; |
![]() |
property Right : Double read FNodeRect.Right; |
![]() |
property Bottom : Double read FNodeRect.Bottom; |
![]() |
property OccupiedRect : TLQTRect read GetOccupiedRect; |
OccupiedRect comprise all items of this node and all subnodes. If TotalNodeItems = 0, the the result is an empty rectangle |
![]() |
property TotalNodeItemsCount : Integer read FTotalNodeItemsCount write SetTotalNodeItemsCount; |
TotalNodeItemsCount: Contains the maintained Number of assigned Items of this Node and all Child-nodes to the bottom |
![]() |
property NodeItemsLength : Integer read GetNodeItemsLength write SetNodeItemsLength; |
NodeItemsLength contains the Length of the NodeItems array. Caution: When writing a smaller value than the current length, the ItemsArePacked and if still need to be shortended, some Items are freed, if the related Tree owns the objects! |
![]() |
property NodeItems[Index:Integer]: TObject read GetNodeItems write SetNodeItems; |
NodeItems gives a raw access to the NodeItems array. Caution: overwriting existing Items will not free them, this has to be done manually if needed! Caution: placing items into the wrong node is not checked! |
![]() |
property AssignedNodeItemsCount : Integer read GetAssignedNodeItemsCount; |
AssignedNodeItemsCount gives the number of assigned items in this node. |
![]() |
property AssignedNodeItems[Index:Integer]: TObject read GetAssignedNodeItems; |
AssignedNodeItems gives access to the assigned items in the raw NodeItems array |
![]() |
property NodeToken : Cardinal read FNodeToken; |
DefaultLQTNodeToken a value that is used during the Stream read and write methods identifying the class of the QuadNode |
Generated by PasDoc 0.16.0.