GEOS  3.13.0dev
HilbertCode.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************/
14 
15 
16 #pragma once
17 
18 #include <geos/export.h>
19 #include <string>
20 #include <cstdint>
21 
22 // Forward declarations
23 namespace geos {
24 namespace geom {
25 class Coordinate;
26 }
27 }
28 
29 namespace geos {
30 namespace shape { // geos.shape
31 namespace fractal { // geos.shape.fractal
32 
65 class GEOS_DLL HilbertCode {
66 
67 public:
68 
72  static constexpr int MAX_LEVEL = 16;
73 
74  static geom::Coordinate decode(uint32_t level, uint32_t i);
75 
76  static uint32_t encode(uint32_t level, uint32_t x, uint32_t y);
77 
85  static uint32_t levelSize(uint32_t level);
86 
95  static uint32_t maxOrdinate(uint32_t level);
96 
104  static uint32_t level(uint32_t numPoints);
105 
106 
107 private:
108 
109  static uint32_t deinterleave(uint32_t x);
110 
111  static uint32_t interleave(uint32_t x);
112 
113  static uint32_t prefixScan(uint32_t x);
114 
115  static uint32_t descan(uint32_t x);
116 
117  static void checkLevel(uint32_t level);
118 
119 
120 };
121 
122 
123 } // namespace geos.shape.fractal
124 } // namespace geos.shape
125 } // namespace geos
126 
127 
128 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
Definition: HilbertCode.h:65
static uint32_t maxOrdinate(uint32_t level)
static uint32_t level(uint32_t numPoints)
static uint32_t levelSize(uint32_t level)
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25