~ubuntu-branches/ubuntu/raring/qgis/raring

« back to all changes in this revision

Viewing changes to src/core/spatialindex/rtree/Index.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Spatial Index Library
 
2
//
 
3
// Copyright (C) 2002 Navel Ltd.
 
4
//
 
5
// This library is free software; you can redistribute it and/or
 
6
// modify it under the terms of the GNU Lesser General Public
 
7
// License as published by the Free Software Foundation; either
 
8
// version 2.1 of the License, or (at your option) any later version.
 
9
//
 
10
// This library is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
// Lesser General Public License for more details.
 
14
//
 
15
// You should have received a copy of the GNU Lesser General Public
 
16
// License along with this library; if not, write to the Free Software
 
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
//
 
19
//  Email:
 
20
//    mhadji@gmail.com
 
21
 
 
22
#ifndef __spatialindex_rtree_index_h
 
23
#define __spatialindex_rtree_index_h
 
24
 
 
25
namespace SpatialIndex
 
26
{
 
27
  namespace RTree
 
28
  {
 
29
    class Index : public Node
 
30
    {
 
31
      public:
 
32
        virtual ~Index();
 
33
 
 
34
      private:
 
35
        Index( RTree* pTree, long id, unsigned long level );
 
36
 
 
37
        virtual NodePtr chooseSubtree( const Region& mbr, unsigned long level, std::stack<long>& pathBuffer );
 
38
        virtual NodePtr findLeaf( const Region& mbr, long id, std::stack<long>& pathBuffer );
 
39
 
 
40
        virtual void split( unsigned long dataLength, byte* pData, Region& mbr, long id, NodePtr& left, NodePtr& right );
 
41
 
 
42
        long findLeastEnlargement( const Region& ) const;
 
43
        long findLeastOverlap( const Region& ) const;
 
44
 
 
45
        void adjustTree( Node*, std::stack<long>& );
 
46
        void adjustTree( Node*, Node*, std::stack<long>&, byte* overflowTable );
 
47
 
 
48
        class OverlapEntry
 
49
        {
 
50
          public:
 
51
            unsigned long m_id;
 
52
            double m_enlargement;
 
53
            RegionPtr m_original;
 
54
            RegionPtr m_combined;
 
55
            double m_oa;
 
56
            double m_ca;
 
57
 
 
58
            static int compareEntries( const void* pv1, const void* pv2 )
 
59
            {
 
60
              OverlapEntry* pe1 = * ( OverlapEntry** ) pv1;
 
61
              OverlapEntry* pe2 = * ( OverlapEntry** ) pv2;
 
62
 
 
63
              if ( pe1->m_enlargement < pe2->m_enlargement ) return -1;
 
64
              if ( pe1->m_enlargement > pe2->m_enlargement ) return 1;
 
65
              return 0;
 
66
            }
 
67
        }; // OverlapEntry
 
68
 
 
69
        friend class RTree;
 
70
        friend class Node;
 
71
        friend class BulkLoader;
 
72
    }; // Index
 
73
  }
 
74
}
 
75
 
 
76
#endif /*__spatialindex_rtree_index_h*/
 
77