gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 line
4.7KB

  1. /**********************************************************************
  2. * $Id: cpl_quad_tree.h fcf615cbf6b2e03db17171af0ebba6da4b4a562d 2016-08-05 17:13:05Z Even Rouault $
  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. #ifndef CPL_QUAD_TREE_H_INCLUDED
  33. #define CPL_QUAD_TREE_H_INCLUDED
  34. #include "cpl_port.h"
  35. /**
  36. * \file cpl_quad_tree.h
  37. *
  38. * Quad tree implementation.
  39. *
  40. * A quadtree is a tree data structure in which each internal node
  41. * has up to four children. Quadtrees are most often used to partition
  42. * a two dimensional space by recursively subdividing it into four
  43. * quadrants or regions
  44. */
  45. CPL_C_START
  46. /* Types */
  47. /** Describe a rectangle */
  48. typedef struct {
  49. double minx; /**< Minimum x */
  50. double miny; /**< Minimum y */
  51. double maxx; /**< Maximum x */
  52. double maxy; /**< Maximum y */
  53. } CPLRectObj;
  54. /** Opaque type for a quad tree */
  55. typedef struct _CPLQuadTree CPLQuadTree;
  56. /** CPLQuadTreeGetBoundsFunc */
  57. typedef void (*CPLQuadTreeGetBoundsFunc)(const void* hFeature, CPLRectObj* pBounds);
  58. /** CPLQuadTreeForeachFunc */
  59. typedef int (*CPLQuadTreeForeachFunc)(void* pElt, void* pUserData);
  60. /** CPLQuadTreeDumpFeatureFunc */
  61. typedef void (*CPLQuadTreeDumpFeatureFunc)(const void* hFeature, int nIndentLevel, void* pUserData);
  62. /* Functions */
  63. CPLQuadTree CPL_DLL *CPLQuadTreeCreate(const CPLRectObj* pGlobalBounds,
  64. CPLQuadTreeGetBoundsFunc pfnGetBounds);
  65. void CPL_DLL CPLQuadTreeDestroy(CPLQuadTree *hQuadtree);
  66. void CPL_DLL CPLQuadTreeSetBucketCapacity(CPLQuadTree *hQuadtree,
  67. int nBucketCapacity);
  68. int CPL_DLL CPLQuadTreeGetAdvisedMaxDepth(int nExpectedFeatures);
  69. void CPL_DLL CPLQuadTreeSetMaxDepth(CPLQuadTree *hQuadtree,
  70. int nMaxDepth);
  71. void CPL_DLL CPLQuadTreeInsert(CPLQuadTree *hQuadtree,
  72. void* hFeature);
  73. void CPL_DLL CPLQuadTreeInsertWithBounds(CPLQuadTree *hQuadtree,
  74. void* hFeature,
  75. const CPLRectObj* psBounds);
  76. void CPL_DLL **CPLQuadTreeSearch(const CPLQuadTree *hQuadtree,
  77. const CPLRectObj* pAoi,
  78. int* pnFeatureCount);
  79. void CPL_DLL CPLQuadTreeForeach(const CPLQuadTree *hQuadtree,
  80. CPLQuadTreeForeachFunc pfnForeach,
  81. void* pUserData);
  82. void CPL_DLL CPLQuadTreeDump(const CPLQuadTree *hQuadtree,
  83. CPLQuadTreeDumpFeatureFunc pfnDumpFeatureFunc,
  84. void* pUserData);
  85. void CPL_DLL CPLQuadTreeGetStats(const CPLQuadTree *hQuadtree,
  86. int* pnFeatureCount,
  87. int* pnNodeCount,
  88. int* pnMaxDepth,
  89. int* pnMaxBucketCapacity);
  90. CPL_C_END
  91. #endif
上海开阖软件有限公司 沪ICP备12045867号-1