libspatialindex API Reference  (git-trunk)
src/rtree/Index.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Project: libspatialindex - A C++ library for spatial indexing
3  * Author: Marios Hadjieleftheriou, mhadji@gmail.com
4  ******************************************************************************
5  * Copyright (c) 2002, Marios Hadjieleftheriou
6  *
7  * All rights reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26 ******************************************************************************/
27 
28 #pragma once
29 
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wcast-qual"
32 
33 namespace SpatialIndex
34 {
35  namespace RTree
36  {
37  class Index : public Node
38  {
39  public:
40  ~Index() override;
41 
42  protected:
43  Index(RTree* pTree, id_type id, uint32_t level);
44 
45  NodePtr chooseSubtree(const Region& mbr, uint32_t level, std::stack<id_type>& pathBuffer) override;
46  NodePtr findLeaf(const Region& mbr, id_type id, std::stack<id_type>& pathBuffer) override;
47 
48  void split(uint32_t dataLength, uint8_t* pData, Region& mbr, id_type id, NodePtr& left, NodePtr& right) override;
49 
50  uint32_t findLeastEnlargement(const Region&) const;
51  uint32_t findLeastOverlap(const Region&) const;
52 
53  void adjustTree(Node*, std::stack<id_type>&, bool force = false);
54  void adjustTree(Node*, Node*, std::stack<id_type>&, uint8_t* overflowTable);
55 
57  {
58  public:
59  uint32_t m_index;
60  double m_enlargement;
63  double m_oa;
64  double m_ca;
65 
66  static int compareEntries(const void* pv1, const void* pv2)
67  {
68  OverlapEntry* pe1 = * (OverlapEntry**) pv1;
69  OverlapEntry* pe2 = * (OverlapEntry**) pv2;
70 
71  if (pe1->m_enlargement < pe2->m_enlargement) return -1;
72  if (pe1->m_enlargement > pe2->m_enlargement) return 1;
73  return 0;
74  }
75  }; // OverlapEntry
76 
77  friend class RTree;
78  friend class Node;
79  friend class BulkLoader;
80  }; // Index
81  }
82 }
83 #pragma GCC diagnostic pop
static int compareEntries(const void *pv1, const void *pv2)
NodePtr findLeaf(const Region &mbr, id_type id, std::stack< id_type > &pathBuffer) override
Definition: rtree/Index.cc:84
void split(uint32_t dataLength, uint8_t *pData, Region &mbr, id_type id, NodePtr &left, NodePtr &right) override
Definition: rtree/Index.cc:104
NodePtr chooseSubtree(const Region &mbr, uint32_t level, std::stack< id_type > &pathBuffer) override
Definition: rtree/Index.cc:46
uint32_t findLeastEnlargement(const Region &) const
Definition: rtree/Index.cc:145
uint32_t findLeastOverlap(const Region &) const
Definition: rtree/Index.cc:176
void adjustTree(Node *, std::stack< id_type > &, bool force=false)
Definition: rtree/Index.cc:283
int64_t id_type
Definition: SpatialIndex.h:41