59 (m_children * (4 * m_pTree->m_dimension *
sizeof(
double) +
sizeof(
double) +
sizeof(
id_type) +
sizeof(uint32_t))) +
61 (4 * m_pTree->m_dimension *
sizeof(
double)));
66 m_nodeMBR = m_pTree->m_infiniteRegion;
69 ptr +=
sizeof(uint32_t);
71 memcpy(&m_level, ptr,
sizeof(uint32_t));
72 ptr +=
sizeof(uint32_t);
74 memcpy(&m_children, ptr,
sizeof(uint32_t));
75 ptr +=
sizeof(uint32_t);
77 memcpy(&(m_nodeMBR.
m_startTime), ptr,
sizeof(
double));
78 ptr +=
sizeof(double);
79 m_nodeMBR.
m_endTime = std::numeric_limits<double>::max();
83 for (uint32_t cChild = 0; cChild < m_children; ++cChild)
85 m_ptrMBR[cChild] = m_pTree->m_regionPool.acquire();
88 memcpy(m_ptrMBR[cChild]->m_pLow, ptr, m_pTree->m_dimension *
sizeof(
double));
89 ptr += m_pTree->m_dimension *
sizeof(double);
90 memcpy(m_ptrMBR[cChild]->m_pHigh, ptr, m_pTree->m_dimension *
sizeof(
double));
91 ptr += m_pTree->m_dimension *
sizeof(double);
92 memcpy(m_ptrMBR[cChild]->m_pVLow, ptr, m_pTree->m_dimension *
sizeof(
double));
93 ptr += m_pTree->m_dimension *
sizeof(double);
94 memcpy(m_ptrMBR[cChild]->m_pVHigh, ptr, m_pTree->m_dimension *
sizeof(
double));
95 ptr += m_pTree->m_dimension *
sizeof(double);
96 memcpy(&(m_ptrMBR[cChild]->m_startTime), ptr,
sizeof(
double));
97 ptr +=
sizeof(double);
98 m_ptrMBR[cChild]->
m_endTime = std::numeric_limits<double>::max();
100 memcpy(&(m_pIdentifier[cChild]), ptr,
sizeof(
id_type));
103 memcpy(&(m_pDataLength[cChild]), ptr,
sizeof(uint32_t));
104 ptr +=
sizeof(uint32_t);
106 if (m_pDataLength[cChild] > 0)
108 m_totalDataLength += m_pDataLength[cChild];
109 m_pData[cChild] =
new uint8_t[m_pDataLength[cChild]];
110 memcpy(m_pData[cChild], ptr, m_pDataLength[cChild]);
111 ptr += m_pDataLength[cChild];
115 m_pData[cChild] =
nullptr;
121 memcpy(m_nodeMBR.
m_pLow, ptr, m_pTree->m_dimension *
sizeof(
double));
122 ptr += m_pTree->m_dimension *
sizeof(double);
123 memcpy(m_nodeMBR.
m_pHigh, ptr, m_pTree->m_dimension *
sizeof(
double));
124 ptr += m_pTree->m_dimension *
sizeof(double);
125 memcpy(m_nodeMBR.
m_pVLow, ptr, m_pTree->m_dimension *
sizeof(
double));
126 ptr += m_pTree->m_dimension *
sizeof(double);
127 memcpy(m_nodeMBR.
m_pVHigh, ptr, m_pTree->m_dimension *
sizeof(
double));
135 *data =
new uint8_t[len];
136 uint8_t* ptr = *data;
143 memcpy(ptr, &nodeType,
sizeof(uint32_t));
144 ptr +=
sizeof(uint32_t);
146 memcpy(ptr, &m_level,
sizeof(uint32_t));
147 ptr +=
sizeof(uint32_t);
149 memcpy(ptr, &m_children,
sizeof(uint32_t));
150 ptr +=
sizeof(uint32_t);
152 memcpy(ptr, &(m_nodeMBR.
m_startTime),
sizeof(
double));
153 ptr +=
sizeof(double);
155 for (uint32_t cChild = 0; cChild < m_children; ++cChild)
157 memcpy(ptr, m_ptrMBR[cChild]->m_pLow, m_pTree->m_dimension *
sizeof(
double));
158 ptr += m_pTree->m_dimension *
sizeof(double);
159 memcpy(ptr, m_ptrMBR[cChild]->m_pHigh, m_pTree->m_dimension *
sizeof(
double));
160 ptr += m_pTree->m_dimension *
sizeof(double);
161 memcpy(ptr, m_ptrMBR[cChild]->m_pVLow, m_pTree->m_dimension *
sizeof(
double));
162 ptr += m_pTree->m_dimension *
sizeof(double);
163 memcpy(ptr, m_ptrMBR[cChild]->m_pVHigh, m_pTree->m_dimension *
sizeof(
double));
164 ptr += m_pTree->m_dimension *
sizeof(double);
165 memcpy(ptr, &(m_ptrMBR[cChild]->m_startTime),
sizeof(
double));
166 ptr +=
sizeof(double);
168 memcpy(ptr, &(m_pIdentifier[cChild]),
sizeof(
id_type));
171 memcpy(ptr, &(m_pDataLength[cChild]),
sizeof(uint32_t));
172 ptr +=
sizeof(uint32_t);
174 if (m_pDataLength[cChild] > 0)
176 memcpy(ptr, m_pData[cChild], m_pDataLength[cChild]);
177 ptr += m_pDataLength[cChild];
182 memcpy(ptr, m_nodeMBR.
m_pLow, m_pTree->m_dimension *
sizeof(
double));
183 ptr += m_pTree->m_dimension *
sizeof(double);
184 memcpy(ptr, m_nodeMBR.
m_pHigh, m_pTree->m_dimension *
sizeof(
double));
185 ptr += m_pTree->m_dimension *
sizeof(double);
186 memcpy(ptr, m_nodeMBR.
m_pVLow, m_pTree->m_dimension *
sizeof(
double));
187 ptr += m_pTree->m_dimension *
sizeof(double);
188 memcpy(ptr, m_nodeMBR.
m_pVHigh, m_pTree->m_dimension *
sizeof(
double));
191 assert(len == (ptr - *data) + m_pTree->m_dimension *
sizeof(
double));
219 return m_pIdentifier[index];
232 if (m_pData[index] ==
nullptr)
239 length = m_pDataLength[index];
240 *data = m_pData[index];
251 return (m_level == 0);
256 return (m_level != 0);
271 m_capacity(capacity),
274 m_pIdentifier(nullptr),
275 m_pDataLength(nullptr),
282 m_pDataLength =
new uint32_t[m_capacity + 1];
283 m_pData =
new uint8_t*[m_capacity + 1];
285 m_pIdentifier =
new id_type[m_capacity + 1];
289 delete[] m_pDataLength;
292 delete[] m_pIdentifier;
299 if (m_pData !=
nullptr)
301 for (uint32_t cChild = 0; cChild < m_children; ++cChild)
303 if (m_pData[cChild] !=
nullptr)
delete[] m_pData[cChild];
309 delete[] m_pDataLength;
311 delete[] m_pIdentifier;
321 assert(m_children < m_capacity);
323 m_pDataLength[m_children] = dataLength;
324 m_pData[m_children] = pData;
325 m_ptrMBR[m_children] = m_pTree->m_regionPool.acquire();
326 *(m_ptrMBR[m_children]) = mbr;
327 m_pIdentifier[m_children] = id;
329 m_totalDataLength += dataLength;
332 if (m_nodeMBR.
m_startTime != m_pTree->m_currentTime)
336 for (uint32_t cDim = 0; cDim < m_nodeMBR.
m_dimension; ++cDim)
338 m_nodeMBR.
m_pLow[cDim] = std::numeric_limits<double>::max();
339 m_nodeMBR.
m_pHigh[cDim] = -std::numeric_limits<double>::max();
340 m_nodeMBR.
m_pVLow[cDim] = std::numeric_limits<double>::max();
341 m_nodeMBR.
m_pVHigh[cDim] = -std::numeric_limits<double>::max();
343 for (uint32_t cChild = 0; cChild < m_children; ++cChild)
345 m_nodeMBR.
m_pLow[cDim] = std::min(m_nodeMBR.
m_pLow[cDim], m_ptrMBR[cChild]->getExtrapolatedLow(cDim, m_nodeMBR.
m_startTime));
346 m_nodeMBR.
m_pHigh[cDim] = std::max(m_nodeMBR.
m_pHigh[cDim], m_ptrMBR[cChild]->getExtrapolatedHigh(cDim, m_nodeMBR.
m_startTime));
347 m_nodeMBR.
m_pVLow[cDim] = std::min(m_nodeMBR.
m_pVLow[cDim], m_ptrMBR[cChild]->m_pVLow[cDim]);
348 m_nodeMBR.
m_pVHigh[cDim] = std::max(m_nodeMBR.
m_pVHigh[cDim], m_ptrMBR[cChild]->m_pVHigh[cDim]);
350 m_nodeMBR.
m_pLow[cDim] -= 2.0 * std::numeric_limits<double>::epsilon();
351 m_nodeMBR.
m_pHigh[cDim] += 2.0 * std::numeric_limits<double>::epsilon();
358 for (uint32_t cDim = 0; cDim < m_nodeMBR.
m_dimension; ++cDim)
364 m_nodeMBR.
m_pLow[cDim] = rl - 2.0 * std::numeric_limits<double>::epsilon();
371 m_nodeMBR.
m_pHigh[cDim] = rh + 2.0 * std::numeric_limits<double>::epsilon();
382 void Node::deleteEntry(uint32_t index)
384 assert(index >= 0 && index < m_children);
389 m_totalDataLength -= m_pDataLength[index];
390 if (m_pData[index] !=
nullptr)
delete[] m_pData[index];
392 if (m_children > 1 && index != m_children - 1)
394 m_pDataLength[index] = m_pDataLength[m_children - 1];
395 m_pData[index] = m_pData[m_children - 1];
396 m_ptrMBR[index] = m_ptrMBR[m_children - 1];
397 m_pIdentifier[index] = m_pIdentifier[m_children - 1];
406 m_nodeMBR = m_pTree->m_infiniteRegion;
412 for (uint32_t cDim = 0; cDim < m_nodeMBR.
m_dimension; ++cDim)
414 m_nodeMBR.
m_pLow[cDim] = std::numeric_limits<double>::max();
415 m_nodeMBR.
m_pHigh[cDim] = -std::numeric_limits<double>::max();
416 m_nodeMBR.
m_pVLow[cDim] = std::numeric_limits<double>::max();
417 m_nodeMBR.
m_pVHigh[cDim] = -std::numeric_limits<double>::max();
419 for (uint32_t cChild = 0; cChild < m_children; ++cChild)
421 m_nodeMBR.
m_pLow[cDim] = std::min(m_nodeMBR.
m_pLow[cDim], m_ptrMBR[cChild]->getExtrapolatedLow(cDim, m_nodeMBR.
m_startTime));
422 m_nodeMBR.
m_pHigh[cDim] = std::max(m_nodeMBR.
m_pHigh[cDim], m_ptrMBR[cChild]->getExtrapolatedHigh(cDim, m_nodeMBR.
m_startTime));
423 m_nodeMBR.
m_pVLow[cDim] = std::min(m_nodeMBR.
m_pVLow[cDim], m_ptrMBR[cChild]->m_pVLow[cDim]);
424 m_nodeMBR.
m_pVHigh[cDim] = std::max(m_nodeMBR.
m_pVHigh[cDim], m_ptrMBR[cChild]->m_pVHigh[cDim]);
426 m_nodeMBR.
m_pLow[cDim] -= 2.0 * std::numeric_limits<double>::epsilon();
427 m_nodeMBR.
m_pHigh[cDim] += 2.0 * std::numeric_limits<double>::epsilon();
433 bool Node::insertData(uint32_t dataLength, uint8_t* pData,
MovingRegion& mbr,
id_type id, std::stack<id_type>& pathBuffer, uint8_t* overflowTable)
435 if (m_children < m_capacity)
437 bool bNeedToAdjust = insertEntry(dataLength, pData, mbr,
id);
438 m_pTree->writeNode(
this);
440 if (bNeedToAdjust && ! pathBuffer.empty())
442 id_type cParent = pathBuffer.top(); pathBuffer.pop();
443 NodePtr ptrN = m_pTree->readNode(cParent);
445 p->adjustTree(
this, pathBuffer);
448 return bNeedToAdjust;
452 !pathBuffer.empty() &&
453 overflowTable[m_level] == 0)
455 overflowTable[m_level] = 1;
457 std::vector<uint32_t> vReinsert, vKeep;
458 reinsertData(dataLength, pData, mbr,
id, vReinsert, vKeep);
460 uint32_t lReinsert =
static_cast<uint32_t
>(vReinsert.size());
461 uint32_t lKeep =
static_cast<uint32_t
>(vKeep.size());
463 uint8_t** reinsertdata =
nullptr;
466 uint32_t* reinsertlen =
nullptr;
467 uint8_t** keepdata =
nullptr;
470 uint32_t* keeplen =
nullptr;
474 reinsertdata =
new uint8_t*[lReinsert];
476 reinsertid =
new id_type[lReinsert];
477 reinsertlen =
new uint32_t[lReinsert];
479 keepdata =
new uint8_t*[m_capacity + 1];
481 keepid =
new id_type[m_capacity + 1];
482 keeplen =
new uint32_t[m_capacity + 1];
486 delete[] reinsertdata;
487 delete[] reinsertmbr;
489 delete[] reinsertlen;
499 for (cIndex = 0; cIndex < lReinsert; ++cIndex)
501 reinsertlen[cIndex] = m_pDataLength[vReinsert[cIndex]];
502 reinsertdata[cIndex] = m_pData[vReinsert[cIndex]];
503 reinsertmbr[cIndex] = m_ptrMBR[vReinsert[cIndex]];
504 reinsertid[cIndex] = m_pIdentifier[vReinsert[cIndex]];
507 for (cIndex = 0; cIndex < lKeep; ++cIndex)
509 keeplen[cIndex] = m_pDataLength[vKeep[cIndex]];
510 keepdata[cIndex] = m_pData[vKeep[cIndex]];
511 keepmbr[cIndex] = m_ptrMBR[vKeep[cIndex]];
512 keepid[cIndex] = m_pIdentifier[vKeep[cIndex]];
515 delete[] m_pDataLength;
518 delete[] m_pIdentifier;
520 m_pDataLength = keeplen;
523 m_pIdentifier = keepid;
525 m_totalDataLength = 0;
527 for (uint32_t cChild = 0; cChild < m_children; ++cChild) m_totalDataLength += m_pDataLength[cChild];
531 for (uint32_t cDim = 0; cDim < m_nodeMBR.
m_dimension; ++cDim)
533 m_nodeMBR.
m_pLow[cDim] = std::numeric_limits<double>::max();
534 m_nodeMBR.
m_pHigh[cDim] = -std::numeric_limits<double>::max();
535 m_nodeMBR.
m_pVLow[cDim] = std::numeric_limits<double>::max();
536 m_nodeMBR.
m_pVHigh[cDim] = -std::numeric_limits<double>::max();
538 for (uint32_t cChild = 0; cChild < m_children; ++cChild)
540 m_nodeMBR.
m_pLow[cDim] = std::min(m_nodeMBR.
m_pLow[cDim], m_ptrMBR[cChild]->getExtrapolatedLow(cDim, m_nodeMBR.
m_startTime));
541 m_nodeMBR.
m_pHigh[cDim] = std::max(m_nodeMBR.
m_pHigh[cDim], m_ptrMBR[cChild]->getExtrapolatedHigh(cDim, m_nodeMBR.
m_startTime));
542 m_nodeMBR.
m_pVLow[cDim] = std::min(m_nodeMBR.
m_pVLow[cDim], m_ptrMBR[cChild]->m_pVLow[cDim]);
543 m_nodeMBR.
m_pVHigh[cDim] = std::max(m_nodeMBR.
m_pVHigh[cDim], m_ptrMBR[cChild]->m_pVHigh[cDim]);
545 m_nodeMBR.
m_pLow[cDim] -= 2.0 * std::numeric_limits<double>::epsilon();
546 m_nodeMBR.
m_pHigh[cDim] += 2.0 * std::numeric_limits<double>::epsilon();
549 m_pTree->writeNode(
this);
554 id_type cParent = pathBuffer.top(); pathBuffer.pop();
555 NodePtr ptrN = m_pTree->readNode(cParent);
557 p->adjustTree(
this, pathBuffer);
559 for (cIndex = 0; cIndex < lReinsert; ++cIndex)
561 m_pTree->insertData_impl(
562 reinsertlen[cIndex], reinsertdata[cIndex],
563 *(reinsertmbr[cIndex]), reinsertid[cIndex],
564 m_level, overflowTable);
567 delete[] reinsertdata;
568 delete[] reinsertmbr;
570 delete[] reinsertlen;
578 split(dataLength, pData, mbr,
id, n, nn);
580 if (pathBuffer.empty())
582 n->m_level = m_level;
583 nn->m_level = m_level;
584 n->m_identifier = -1;
585 nn->m_identifier = -1;
587 m_pTree->writeNode(n.
get());
588 m_pTree->writeNode(nn.
get());
590 NodePtr ptrR = m_pTree->m_indexPool.acquire();
591 if (ptrR.
get() ==
nullptr)
593 ptrR =
NodePtr(
new Index(m_pTree, m_pTree->m_rootID, m_level + 1), &(m_pTree->m_indexPool));
598 ptrR->m_identifier = m_pTree->m_rootID;
599 ptrR->m_level = m_level + 1;
600 ptrR->m_nodeMBR = m_pTree->m_infiniteRegion;
603 ptrR->insertEntry(0,
nullptr, n->m_nodeMBR, n->m_identifier);
604 ptrR->insertEntry(0,
nullptr, nn->m_nodeMBR, nn->m_identifier);
606 m_pTree->writeNode(ptrR.
get());
608 m_pTree->m_stats.m_nodesInLevel[m_level] = 2;
609 m_pTree->m_stats.m_nodesInLevel.push_back(1);
610 m_pTree->m_stats.m_treeHeight = m_level + 2;
614 n->m_level = m_level;
615 nn->m_level = m_level;
616 n->m_identifier = m_identifier;
617 nn->m_identifier = -1;
619 m_pTree->writeNode(n.
get());
620 m_pTree->writeNode(nn.
get());
622 id_type cParent = pathBuffer.top(); pathBuffer.pop();
623 NodePtr ptrN = m_pTree->readNode(cParent);
625 p->adjustTree(n.
get(), nn.
get(), pathBuffer, overflowTable);
632 void Node::reinsertData(uint32_t dataLength, uint8_t* pData,
MovingRegion& mbr,
id_type id, std::vector<uint32_t>& reinsert, std::vector<uint32_t>& keep)
634 ReinsertEntry** v =
new ReinsertEntry*[m_capacity + 1];
636 m_pDataLength[m_children] = dataLength;
637 m_pData[m_children] = pData;
638 m_ptrMBR[m_children] = m_pTree->m_regionPool.acquire();
639 *(m_ptrMBR[m_children]) = mbr;
640 m_pIdentifier[m_children] = id;
642 Tools::Interval ivT(m_pTree->m_currentTime, m_pTree->m_currentTime + m_pTree->m_horizon);
644 for (uint32_t cChild = 0; cChild < m_capacity + 1; ++cChild)
648 v[cChild] =
new ReinsertEntry(cChild, 0.0);
652 for (uint32_t i = 0; i < cChild; ++i)
delete v[i];
661 ::qsort(v, m_capacity + 1,
sizeof(ReinsertEntry*), ReinsertEntry::compareReinsertEntry);
663 uint32_t cReinsert =
static_cast<uint32_t
>(std::floor((m_capacity + 1) * m_pTree->m_reinsertFactor));
667 for (cCount = 0; cCount < cReinsert; ++cCount)
669 reinsert.push_back(v[cCount]->m_index);
673 for (cCount = cReinsert; cCount < m_capacity + 1; ++cCount)
675 keep.push_back(v[cCount]->m_index);
837 void Node::rstarSplit(uint32_t dataLength, uint8_t* pData,
MovingRegion& mbr,
id_type id, std::vector<uint32_t>& group1, std::vector<uint32_t>& group2)
839 RstarSplitEntry** dataLow =
nullptr;
840 RstarSplitEntry** dataHigh =
nullptr;
841 RstarSplitEntry** dataVLow =
nullptr;
842 RstarSplitEntry** dataVHigh =
nullptr;
846 dataLow =
new RstarSplitEntry*[m_capacity + 1];
847 dataHigh =
new RstarSplitEntry*[m_capacity + 1];
848 dataVLow =
new RstarSplitEntry*[m_capacity + 1];
849 dataVHigh =
new RstarSplitEntry*[m_capacity + 1];
860 m_pDataLength[m_capacity] = dataLength;
861 m_pData[m_capacity] = pData;
862 m_ptrMBR[m_capacity] = m_pTree->m_regionPool.acquire();
863 *(m_ptrMBR[m_capacity]) = mbr;
864 m_pIdentifier[m_capacity] = id;
866 uint32_t nodeSPF =
static_cast<uint32_t
>(std::floor((m_capacity + 1) * m_pTree->m_splitDistributionFactor));
867 uint32_t splitDistribution = (m_capacity + 1) - (2 * nodeSPF) + 2;
869 Tools::Interval ivT(m_pTree->m_currentTime, m_pTree->m_currentTime + m_pTree->m_horizon);
871 uint32_t cChild = 0, cDim, cIndex;
873 for (cChild = 0; cChild <= m_capacity; ++cChild)
877 dataLow[cChild] =
new RstarSplitEntry(m_ptrMBR[cChild].get(), cChild, 0);
881 for (uint32_t i = 0; i < cChild; ++i)
delete dataLow[i];
887 dataHigh[cChild] = dataLow[cChild];
888 dataVLow[cChild] = dataLow[cChild];
889 dataVHigh[cChild] = dataLow[cChild];
892 double minimumMargin = std::numeric_limits<double>::max();
893 uint32_t splitAxis = std::numeric_limits<uint32_t>::max();
894 uint32_t sortOrder = std::numeric_limits<uint32_t>::max();
897 for (cDim = 0; cDim < m_pTree->m_dimension; ++cDim)
899 ::qsort(dataLow, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareLow);
900 ::qsort(dataHigh, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareHigh);
901 ::qsort(dataVLow, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareVLow);
902 ::qsort(dataVHigh, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareVHigh);
905 double marginl = 0.0;
906 double marginh = 0.0;
907 double marginvl = 0.0;
908 double marginvh = 0.0;
913 for (cChild = 1; cChild <= splitDistribution; ++cChild)
915 uint32_t l = nodeSPF - 1 + cChild;
917 bbl1 = *(dataLow[0]->m_pRegion);
918 bbh1 = *(dataHigh[0]->m_pRegion);
919 bbvl1 = *(dataVLow[0]->m_pRegion);
920 bbvh1 = *(dataVHigh[0]->m_pRegion);
922 for (cIndex = 1; cIndex < l; ++cIndex)
930 bbl2 = *(dataLow[l]->m_pRegion);
931 bbh2 = *(dataHigh[l]->m_pRegion);
932 bbvl2 = *(dataVLow[l]->m_pRegion);
933 bbvh2 = *(dataVHigh[l]->m_pRegion);
935 for (cIndex = l + 1; cIndex <= m_capacity; ++cIndex)
949 double margin = std::min(std::min(marginl, marginh), std::min(marginvl, marginvh));
952 if (margin < minimumMargin)
954 minimumMargin = margin;
956 if (marginl < marginh && marginl < marginvl && marginl < marginvh) sortOrder = 0;
957 else if (marginh < marginl && marginh < marginvl && marginh < marginvh) sortOrder = 1;
958 else if (marginvl < marginl && marginvl < marginh && marginvl < marginvh) sortOrder = 2;
959 else if (marginvh < marginl && marginvh < marginh && marginvh < marginvl) sortOrder = 3;
963 for (cChild = 0; cChild <= m_capacity; ++cChild)
965 dataLow[cChild]->m_sortDim = cDim + 1;
969 for (cChild = 0; cChild <= m_capacity; ++cChild)
971 dataLow[cChild]->m_sortDim = splitAxis;
975 ::qsort(dataLow, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareLow);
976 else if (sortOrder == 1)
977 ::qsort(dataLow, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareHigh);
978 else if (sortOrder == 2)
979 ::qsort(dataLow, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareVLow);
980 else if (sortOrder == 3)
981 ::qsort(dataLow, m_capacity + 1,
sizeof(RstarSplitEntry*), RstarSplitEntry::compareVHigh);
983 double ma = std::numeric_limits<double>::max();
984 double mo = std::numeric_limits<double>::max();
985 uint32_t splitPoint = std::numeric_limits<uint32_t>::max();
989 for (cChild = 1; cChild <= splitDistribution; ++cChild)
991 uint32_t l = nodeSPF - 1 + cChild;
993 bb1 = *(dataLow[0]->m_pRegion);
995 for (cIndex = 1; cIndex < l; ++cIndex)
1000 bb2 = *(dataLow[l]->m_pRegion);
1002 for (cIndex = l + 1; cIndex <= m_capacity; ++cIndex)
1011 splitPoint = cChild;
1021 splitPoint = cChild;
1027 uint32_t l1 = nodeSPF - 1 + splitPoint;
1029 for (cIndex = 0; cIndex < l1; ++cIndex)
1031 group1.push_back(dataLow[cIndex]->m_index);
1032 delete dataLow[cIndex];
1035 for (cIndex = l1; cIndex <= m_capacity; ++cIndex)
1037 group2.push_back(dataLow[cIndex]->m_index);
1038 delete dataLow[cIndex];
1126 void Node::condenseTree(std::stack<NodePtr>& toReinsert, std::stack<id_type>& pathBuffer,
NodePtr& ptrThis)
1128 uint32_t minimumLoad =
static_cast<uint32_t
>(std::floor(m_capacity * m_pTree->m_fillFactor));
1130 if (pathBuffer.empty())
1133 if (m_level != 0 && m_children == 1)
1135 NodePtr ptrN = m_pTree->readNode(m_pIdentifier[0]);
1136 m_pTree->deleteNode(ptrN.
get());
1137 ptrN->m_identifier = m_pTree->m_rootID;
1138 m_pTree->writeNode(ptrN.
get());
1140 m_pTree->m_stats.m_nodesInLevel.pop_back();
1141 m_pTree->m_stats.m_treeHeight -= 1;
1143 m_pTree->m_stats.m_nodesInLevel[m_pTree->m_stats.m_treeHeight - 1] = 2;
1148 id_type cParent = pathBuffer.top(); pathBuffer.pop();
1149 NodePtr ptrParent = m_pTree->readNode(cParent);
1155 for (child = 0; child != p->m_children; ++child)
1157 if (p->m_pIdentifier[child] == m_identifier)
break;
1160 if (m_children < minimumLoad)
1164 p->deleteEntry(child);
1166 toReinsert.push(ptrThis);
1171 *(p->m_ptrMBR[child]) = m_nodeMBR;
1178 p->m_nodeMBR.m_startTime = m_pTree->m_currentTime;
1180 for (uint32_t cDim = 0; cDim < p->m_nodeMBR.m_dimension; ++cDim)
1182 p->m_nodeMBR.m_pLow[cDim] = std::numeric_limits<double>::max();
1183 p->m_nodeMBR.m_pHigh[cDim] = -std::numeric_limits<double>::max();
1184 p->m_nodeMBR.m_pVLow[cDim] = std::numeric_limits<double>::max();
1185 p->m_nodeMBR.m_pVHigh[cDim] = -std::numeric_limits<double>::max();
1187 for (uint32_t cChild = 0; cChild < p->m_children; ++cChild)
1189 p->m_nodeMBR.m_pLow[cDim] = std::min(p->m_nodeMBR.m_pLow[cDim], p->m_ptrMBR[cChild]->getExtrapolatedLow(cDim, m_pTree->m_currentTime));
1190 p->m_nodeMBR.m_pHigh[cDim] = std::max(p->m_nodeMBR.m_pHigh[cDim], p->m_ptrMBR[cChild]->getExtrapolatedHigh(cDim, m_pTree->m_currentTime));
1191 p->m_nodeMBR.m_pVLow[cDim] = std::min(p->m_nodeMBR.m_pVLow[cDim], p->m_ptrMBR[cChild]->m_pVLow[cDim]);
1192 p->m_nodeMBR.m_pVHigh[cDim] = std::max(p->m_nodeMBR.m_pVHigh[cDim], p->m_ptrMBR[cChild]->m_pVHigh[cDim]);
1194 p->m_nodeMBR.m_pLow[cDim] -= 2.0 * std::numeric_limits<double>::epsilon();
1195 p->m_nodeMBR.m_pHigh[cDim] += 2.0 * std::numeric_limits<double>::epsilon();
1201 m_pTree->writeNode(p);
1203 p->condenseTree(toReinsert, pathBuffer, ptrParent);
void makeDimension(uint32_t dimension) override
virtual double getCenterDistanceInTime(const MovingRegion &r) const
double getAreaInTime() const override
virtual bool containsRegionAfterTime(double t, const MovingRegion &r) const
virtual double getIntersectingAreaInTime(const MovingRegion &r) const
virtual void combineRegionAfterTime(double t, const MovingRegion &r)
virtual double getProjectedSurfaceAreaInTime() const
void makeInfinite(uint32_t dimension) override
virtual double getExtrapolatedLow(uint32_t index, double t) const
virtual double getExtrapolatedHigh(uint32_t index, double t) const
uint32_t getLevel() const override
void getChildShape(uint32_t index, IShape **out) const override
void loadFromByteArray(const uint8_t *data) override
void storeToByteArray(uint8_t **data, uint32_t &len) override
void getChildData(uint32_t index, uint32_t &length, uint8_t **data) const override
bool isIndex() const override
Tools::IObject * clone() override
uint32_t getChildrenCount() const override
uint32_t getByteArraySize() override
void getShape(IShape **out) const override
id_type getChildIdentifier(uint32_t index) const override
bool isLeaf() const override
id_type getIdentifier() const override
Tools::PoolPointer< Node > NodePtr