GEOS  3.13.0dev
MortonCode.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 
33 
67 class GEOS_DLL MortonCode {
68 
69 public:
70 
74  static constexpr int MAX_LEVEL = 16;
75 
84  static uint32_t encode(int x, int y);
85 
93  static geom::Coordinate decode(uint32_t index);
94 
102  static uint32_t levelSize(uint32_t level);
103 
112  static uint32_t maxOrdinate(uint32_t level);
113 
121  static uint32_t level(uint32_t numPoints);
122 
123 
124 private:
125 
126  static void checkLevel(uint32_t level) ;
127 
128  static uint32_t interleave(uint32_t x);
129 
130  static uint32_t deinterleave(uint32_t x);
131 
132 };
133 
134 
135 } // namespace geos.shape.fractal
136 } // namespace geos.shape
137 } // namespace geos
138 
139 
140 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
Definition: MortonCode.h:67
static uint32_t encode(int x, int y)
static uint32_t maxOrdinate(uint32_t level)
static geom::Coordinate decode(uint32_t index)
static uint32_t levelSize(uint32_t level)
static uint32_t level(uint32_t numPoints)
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25