1
// Spatial Index Library
3
// Copyright (C) 2003 Navel Ltd.
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.
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.
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
22
#ifndef __spatialindex_h
23
#define __spatialindex_h
39
using namespace Tools::Geometry;
42
# define bzero(d, n) memset((d), 0, (n))
45
namespace SpatialIndex
47
//const std::string VERSION;
48
//const std::string DATE;
60
interface IEntry : public Tools::IObject
63
virtual long getIdentifier() const = 0;
64
virtual void getShape( IShape** out ) const = 0;
68
interface INode : public IEntry, public Tools::ISerializable
71
virtual unsigned long getChildrenCount() const = 0;
72
virtual long getChildIdentifier( unsigned long index ) const = 0;
73
virtual void getChildShape( unsigned long index, IShape** out ) const = 0;
74
virtual unsigned long getLevel() const = 0;
75
virtual bool isIndex() const = 0;
76
virtual bool isLeaf() const = 0;
80
interface IData : public IEntry
83
virtual void getData( unsigned long& len, byte** data ) const = 0;
87
interface IDataStream : public Tools::IObjectStream
90
virtual IData* getNext() = 0;
91
virtual ~IDataStream() {}
97
virtual void execute( const INode& in ) = 0;
98
virtual ~ICommand() {}
101
interface INearestNeighborComparator
104
virtual double getMinimumDistance( const IShape& query, const IShape& entry ) = 0;
105
virtual double getMinimumDistance( const IShape& query, const IData& data ) = 0;
106
virtual ~INearestNeighborComparator() {}
107
}; // INearestNeighborComparator
109
interface IStorageManager
112
virtual void loadByteArray( const long id, unsigned long& len, byte** data ) = 0;
113
virtual void storeByteArray( long& id, const unsigned long len, const byte* const data ) = 0;
114
virtual void deleteByteArray( const long id ) = 0;
115
virtual ~IStorageManager() {}
116
}; // IStorageManager
121
virtual void visitNode( const INode& in ) = 0;
122
virtual void visitData( const IData& in ) = 0;
123
virtual void visitData( std::vector<const IData*>& v ) = 0;
124
virtual ~IVisitor() {}
127
interface IQueryStrategy
130
virtual void getNextEntry( const IEntry& previouslyFetched, long& nextEntryToFetch, bool& bFetchNextEntry ) = 0;
131
virtual ~IQueryStrategy() {}
134
interface IStatistics
137
virtual unsigned long getReads() const = 0;
138
virtual unsigned long getWrites() const = 0;
139
virtual unsigned long getNumberOfNodes() const = 0;
140
virtual unsigned long getNumberOfData() const = 0;
141
virtual ~IStatistics() {}
144
interface ISpatialIndex
147
virtual void insertData( unsigned long len, const byte* pData, const IShape& shape, long shapeIdentifier ) = 0;
148
virtual bool deleteData( const IShape& shape, long shapeIdentifier ) = 0;
149
virtual void containsWhatQuery( const IShape& query, IVisitor& v ) = 0;
150
virtual void intersectsWithQuery( const IShape& query, IVisitor& v ) = 0;
151
virtual void pointLocationQuery( const Tools::Geometry::Point& query, IVisitor& v ) = 0;
152
virtual void nearestNeighborQuery( long k, const IShape& query, IVisitor& v, INearestNeighborComparator& nnc ) = 0;
153
virtual void nearestNeighborQuery( long k, const IShape& query, IVisitor& v ) = 0;
154
virtual void selfJoinQuery( const IShape& s, IVisitor& v ) = 0;
155
virtual void queryStrategy( IQueryStrategy& qs ) = 0;
156
virtual void getIndexProperties( Tools::PropertySet& out ) const = 0;
157
virtual void addCommand( ICommand* in, CommandType ct ) = 0;
158
virtual bool isIndexValid() = 0;
159
virtual void getStatistics( IStatistics** out ) const = 0;
160
virtual ~ISpatialIndex() {}
163
namespace StorageManager
165
enum StorageManagerConstants
171
interface IBuffer : public IStorageManager
174
virtual unsigned long getHits() = 0;
175
virtual void clear() = 0;
176
virtual ~IBuffer() {}
179
extern IStorageManager* returnMemoryStorageManager( Tools::PropertySet& in );
180
extern IStorageManager* createNewMemoryStorageManager();
182
extern IStorageManager* returnDiskStorageManager( Tools::PropertySet& in );
183
extern IStorageManager* createNewDiskStorageManager( std::string& baseName, unsigned long pageSize );
184
extern IStorageManager* loadDiskStorageManager( std::string& baseName );
187
// MSVC didn't like the difference in parameter names between declaration
189
extern IBuffer* returnRandomEvictionsBuffer( IStorageManager& sm, Tools::PropertySet& ps );
191
extern IBuffer* returnRandomEvictionsBuffer( IStorageManager& in0, Tools::PropertySet& in1 );
193
extern IBuffer* createNewRandomEvictionsBuffer( IStorageManager& in, unsigned int capacity, bool bWriteThrough );
199
extern std::ostream& operator<<( std::ostream&, const ISpatialIndex& );
200
extern std::ostream& operator<<( std::ostream&, const IStatistics& );
203
//#include "TimePoint.h"
204
//#include "TimeRegion.h"
205
//#include "MovingPoint.h"
206
//#include "MovingRegion.h"
208
//#include "MVRTree.h"
209
//#include "TPRTree.h"
211
#endif /*__spatialindex_h*/