GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

cpl_quad_tree.h
Go to the documentation of this file.
1 /**********************************************************************
2 * $Id: cpl_quad_tree.h 33666 2016-03-07 05:21:07Z goatbar $
3 *
4 * Project: CPL - Common Portability Library
5 * Purpose: Implementation of quadtree building and searching functions.
6 * Derived from shapelib and mapserver implementations
7 * Author: Frank Warmerdam, warmerdam@pobox.com
8 * Even Rouault, <even dot rouault at mines dash paris dot org>
9 *
10 ******************************************************************************
11 * Copyright (c) 1999-2008, Frank Warmerdam
12 * Copyright (c) 2008-2014, Even Rouault <even dot rouault at mines-paris dot org>
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 * DEALINGS IN THE SOFTWARE.
31 ****************************************************************************/
32
33 #ifndef CPL_QUAD_TREE_H_INCLUDED
34 #define CPL_QUAD_TREE_H_INCLUDED
35
36 #include "cpl_port.h"
37
49 CPL_C_START
50
51 /* Types */
52
53 typedef struct {
54 double minx, miny, maxx, maxy;
55 } CPLRectObj;
56
57 typedef struct _CPLQuadTree CPLQuadTree;
58
59 typedef void (*CPLQuadTreeGetBoundsFunc)(const void* hFeature, CPLRectObj* pBounds);
60 typedef int (*CPLQuadTreeForeachFunc)(void* pElt, void* pUserData);
61 typedef void (*CPLQuadTreeDumpFeatureFunc)(const void* hFeature, int nIndentLevel, void* pUserData);
62
63 /* Functions */
64
65 CPLQuadTree CPL_DLL *CPLQuadTreeCreate(const CPLRectObj* pGlobalBounds,
66 CPLQuadTreeGetBoundsFunc pfnGetBounds);
67 void CPL_DLL CPLQuadTreeDestroy(CPLQuadTree *hQuadtree);
68
69 void CPL_DLL CPLQuadTreeSetBucketCapacity(CPLQuadTree *hQuadtree,
70 int nBucketCapacity);
71 int CPL_DLL CPLQuadTreeGetAdvisedMaxDepth(int nExpectedFeatures);
72 void CPL_DLL CPLQuadTreeSetMaxDepth(CPLQuadTree *hQuadtree,
73 int nMaxDepth);
74
75 void CPL_DLL CPLQuadTreeInsert(CPLQuadTree *hQuadtree,
76 void* hFeature);
77 void CPL_DLL CPLQuadTreeInsertWithBounds(CPLQuadTree *hQuadtree,
78 void* hFeature,
79 const CPLRectObj* psBounds);
80
81 void CPL_DLL **CPLQuadTreeSearch(const CPLQuadTree *hQuadtree,
82 const CPLRectObj* pAoi,
83 int* pnFeatureCount);
84
85 void CPL_DLL CPLQuadTreeForeach(const CPLQuadTree *hQuadtree,
86 CPLQuadTreeForeachFunc pfnForeach,
87 void* pUserData);
88
89 void CPL_DLL CPLQuadTreeDump(const CPLQuadTree *hQuadtree,
90 CPLQuadTreeDumpFeatureFunc pfnDumpFeatureFunc,
91 void* pUserData);
92 void CPL_DLL CPLQuadTreeGetStats(const CPLQuadTree *hQuadtree,
93 int* pnFeatureCount,
94 int* pnNodeCount,
95 int* pnMaxDepth,
96 int* pnMaxBucketCapacity);
97
98 CPL_C_END
99
100 #endif
CPLQuadTreeInsert
void CPLQuadTreeInsert(CPLQuadTree *hQuadtree, void *hFeature)
Insert a feature into a quadtree.
Definition: cpl_quad_tree.cpp:269
cpl_port.h
Core portability definitions for CPL.
CPLQuadTreeGetAdvisedMaxDepth
int CPLQuadTreeGetAdvisedMaxDepth(int nExpectedFeatures)
Returns the optimal depth of a quadtree to hold nExpectedFeatures.
Definition: cpl_quad_tree.cpp:185
CPLQuadTreeCreate
CPLQuadTree * CPLQuadTreeCreate(const CPLRectObj *pGlobalBounds, CPLQuadTreeGetBoundsFunc pfnGetBounds)
Create a new quadtree.
Definition: cpl_quad_tree.cpp:146
CPLRectObj
Definition: cpl_quad_tree.h:53
CPLQuadTreeSearch
void ** CPLQuadTreeSearch(const CPLQuadTree *hQuadtree, const CPLRectObj *pAoi, int *pnFeatureCount)
Returns all the elements inserted whose bounding box intersects the provided area of interest...
Definition: cpl_quad_tree.cpp:682
CPLQuadTreeSetMaxDepth
void CPLQuadTreeSetMaxDepth(CPLQuadTree *hQuadtree, int nMaxDepth)
Set the maximum depth of a quadtree.
Definition: cpl_quad_tree.cpp:234
CPLQuadTreeInsertWithBounds
void CPLQuadTreeInsertWithBounds(CPLQuadTree *hQuadtree, void *hFeature, const CPLRectObj *psBounds)
Insert a feature into a quadtree.
Definition: cpl_quad_tree.cpp:294
CPLQuadTreeSetBucketCapacity
void CPLQuadTreeSetBucketCapacity(CPLQuadTree *hQuadtree, int nBucketCapacity)
Set the maximum capacity of a node of a quadtree.
Definition: cpl_quad_tree.cpp:252
CPLQuadTreeDestroy
void CPLQuadTreeDestroy(CPLQuadTree *hQuadtree)
Destroy a quadtree.
Definition: cpl_quad_tree.cpp:334
CPLQuadTreeForeach
void CPLQuadTreeForeach(const CPLQuadTree *hQuadtree, CPLQuadTreeForeachFunc pfnForeach, void *pUserData)
Walk through the quadtree and runs the provided function on all the elements.
Definition: cpl_quad_tree.cpp:746

Generated for GDAL by 1.8.8.