h3v 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
_h3v_core.py ADDED
@@ -0,0 +1,197 @@
1
+ """Shared H3V format constants, validation, and exact radial arithmetic.
2
+
3
+ Internal support only: this module imports no API category or facade.
4
+ """
5
+
6
+ from numbers import Rational
7
+ import math
8
+
9
+ from h3.api import basic_int as h3
10
+
11
+
12
+
13
+
14
+ _AUTHALIC_EARTH_RADIUS_KM = 6371.007180918475
15
+ RADIAL_BASE_STEP = _AUTHALIC_EARTH_RADIUS_KM
16
+ MAX_RADIAL_RESOLUTION = 10
17
+ _RADIAL_BASE_CELLS = 256
18
+
19
+ MAX_ALTITUDE = (_RADIAL_BASE_CELLS - 1) * _AUTHALIC_EARTH_RADIUS_KM
20
+
21
+ _EARTH_RADIUS_NUMERATOR, _EARTH_RADIUS_DENOMINATOR = (
22
+ _AUTHALIC_EARTH_RADIUS_KM.as_integer_ratio()
23
+ )
24
+ _MAX_SURFACE_RESOLUTION = 15
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+ _HALF_BITS = 64
41
+ _PACKED_BITS = 2 * _HALF_BITS
42
+ _BITS_PER_DIGIT = 4
43
+ _DIGIT_MASK = 0xF
44
+ _RADIAL_DIGIT_SLOTS = 10
45
+ _BASE_SHIFT = _BITS_PER_DIGIT * _RADIAL_DIGIT_SLOTS
46
+ _BASE_MASK = 0xFF
47
+ _RESOLUTION_SHIFT = _BASE_SHIFT + 8
48
+ _FORMAT_SHIFT = 60
49
+ _FORMAT_VERSION = 4
50
+ _HEADER = _FORMAT_VERSION << _FORMAT_SHIFT
51
+ _UNUSED_DIGITS = (1 << _BASE_SHIFT) - 1
52
+ _MASK64 = (1 << _HALF_BITS) - 1
53
+ _RADIAL_DIRECTION_SHIFT = _RESOLUTION_SHIFT + _BITS_PER_DIGIT
54
+ _RADIAL_DIRECTION_MASK = 3 << _RADIAL_DIRECTION_SHIFT
55
+ _RADIAL_RESERVED_SHIFT = _RADIAL_DIRECTION_SHIFT + 2
56
+ _RADIAL_RESERVED_MASK = ((1 << (_FORMAT_SHIFT - _RADIAL_RESERVED_SHIFT)) - 1) << _RADIAL_RESERVED_SHIFT
57
+
58
+
59
+ _RADIAL_METADATA_MASK = (
60
+ (0xF << _FORMAT_SHIFT) | _RADIAL_RESERVED_MASK | _RADIAL_DIRECTION_MASK
61
+ )
62
+
63
+
64
+ def _resolution(value, maximum, name):
65
+ """Require an ordinary integer level; reject booleans as well as floats."""
66
+ if type(value) is not int or not 0 <= value <= maximum:
67
+ raise ValueError(f"{name} must be an integer from 0 to {maximum}")
68
+ return value
69
+
70
+
71
+ def _number_ratio(value, name):
72
+ """Return a supported finite number as two exact integers, without rational objects.
73
+
74
+ Rational accepts Python integer/rational inputs without importing fractions.
75
+ Normalize components to Python int before arithmetic to avoid fixed-width overflow.
76
+ Floats supply their own exact as_integer_ratio() conversion.
77
+ """
78
+ if isinstance(value, bool) or not isinstance(value, (Rational, float)):
79
+ raise ValueError(f"{name} must be a finite number")
80
+ if isinstance(value, Rational):
81
+ return int(value.numerator), int(value.denominator)
82
+ try:
83
+ return value.as_integer_ratio()
84
+ except (ValueError, OverflowError) as exc:
85
+ raise ValueError(f"{name} must be finite") from exc
86
+
87
+
88
+ def _ratio(numerator, denominator):
89
+ """Reduce an exact ratio; all internal denominators are positive."""
90
+ divisor = math.gcd(numerator, denominator)
91
+ return numerator // divisor, denominator // divisor
92
+
93
+
94
+ def _sum_ratios(left, right):
95
+ """Add integer ratios using a common denominator without unnecessary growth."""
96
+ left_numerator, left_denominator = left
97
+ right_numerator, right_denominator = right
98
+ divisor = math.gcd(left_denominator, right_denominator)
99
+ return _ratio(
100
+ left_numerator * (right_denominator // divisor)
101
+ + right_numerator * (left_denominator // divisor),
102
+ left_denominator * (right_denominator // divisor),
103
+ )
104
+
105
+
106
+ def _pack_radial(bin_number, resolution):
107
+ """Pack a radius-based logical bin coordinate, increasing with physical radius."""
108
+ _resolution(resolution, MAX_RADIAL_RESOLUTION, "radial resolution")
109
+ base_bin, refinement = divmod(bin_number, 7**resolution)
110
+ if not 0 <= base_bin < _RADIAL_BASE_CELLS:
111
+ raise ValueError("unsupported radial base number")
112
+
113
+ digit_bits = _UNUSED_DIGITS
114
+
115
+
116
+ for level in range(resolution - 1, -1, -1):
117
+ refinement, position = divmod(refinement, 7)
118
+ shift = _BITS_PER_DIGIT * (_RADIAL_DIGIT_SLOTS - 1 - level)
119
+ digit_bits = (digit_bits & ~(_DIGIT_MASK << shift)) | (position << shift)
120
+ return (
121
+ _HEADER
122
+ | (resolution << _RESOLUTION_SHIFT)
123
+ | (base_bin << _BASE_SHIFT)
124
+ | digit_bits
125
+ )
126
+
127
+
128
+ def _read_radial(radial_index):
129
+ """Validate and return (resolution, radius-based logical bin coordinate)."""
130
+ if type(radial_index) is not int or not 0 <= radial_index < 1 << _HALF_BITS:
131
+ raise ValueError("radial index must be an unsigned 64-bit integer")
132
+ if radial_index & _RADIAL_METADATA_MASK != _HEADER:
133
+ raise ValueError("radial format version must be 4; direction and reserved bits must be zero")
134
+ resolution = _resolution(
135
+ (radial_index >> _RESOLUTION_SHIFT) & _DIGIT_MASK,
136
+ MAX_RADIAL_RESOLUTION,
137
+ "radial resolution",
138
+ )
139
+ bin_number = (radial_index >> _BASE_SHIFT) & _BASE_MASK
140
+ for level in range(_RADIAL_DIGIT_SLOTS):
141
+ shift = _BITS_PER_DIGIT * (_RADIAL_DIGIT_SLOTS - 1 - level)
142
+ digit = (radial_index >> shift) & _DIGIT_MASK
143
+ if level < resolution:
144
+ if not 0 <= digit <= 6:
145
+ raise ValueError("active radial digits must be 0..6")
146
+ bin_number = bin_number * 7 + digit
147
+ elif digit != _DIGIT_MASK:
148
+ raise ValueError("unused radial digits must be f")
149
+ return resolution, bin_number
150
+
151
+
152
+ def _read_index(index):
153
+ """Validate and return surface, radial, radial level, and radius-based logical bin."""
154
+ if type(index) is not int or not 0 <= index < 1 << _PACKED_BITS:
155
+ raise ValueError("packed index must be an unsigned 128-bit integer")
156
+ surface = index & _MASK64
157
+ radial = index >> _HALF_BITS
158
+ if not h3.is_valid_cell(surface):
159
+ raise ValueError("surface index must be a valid unsigned 64-bit H3 cell")
160
+ resolution, bin_number = _read_radial(radial)
161
+ return surface, radial, resolution, bin_number
162
+
163
+
164
+ def _read_directed_edge(index):
165
+ """Validate an edge and return its (origin voxel, destination voxel)."""
166
+ if type(index) is not int or not 0 <= index < 1 << _PACKED_BITS:
167
+ raise ValueError("packed edge must be an unsigned 128-bit integer")
168
+ surface = index & _MASK64
169
+ marked_radial = index >> _HALF_BITS
170
+ direction = (marked_radial & _RADIAL_DIRECTION_MASK) >> _RADIAL_DIRECTION_SHIFT
171
+ radial = marked_radial & ~_RADIAL_DIRECTION_MASK
172
+ resolution, bin_number = _read_radial(radial)
173
+ if direction == 0:
174
+ if not h3.is_valid_directed_edge(surface):
175
+ raise ValueError("lateral edge requires a valid H3 directed edge")
176
+ origin, destination = h3.directed_edge_to_cells(surface)
177
+ return (radial << _HALF_BITS) | origin, (radial << _HALF_BITS) | destination
178
+ if direction == 3 or not h3.is_valid_cell(surface):
179
+ raise ValueError("radial edge requires one radial direction and an H3 cell")
180
+ destination_bin = bin_number + (-1 if direction == 1 else 1)
181
+ if not 0 <= destination_bin < _RADIAL_BASE_CELLS * 7**resolution:
182
+ raise ValueError("radial edge destination is outside the domain")
183
+ destination_radial = _pack_radial(destination_bin, resolution)
184
+ return (radial << _HALF_BITS) | surface, (destination_radial << _HALF_BITS) | surface
185
+
186
+
187
+ def _validate_object(index):
188
+ """Validate a voxel or directed edge without relaxing voxel validation."""
189
+ if type(index) is not int or not 0 <= index < 1 << _PACKED_BITS:
190
+ raise ValueError("packed index must be an unsigned 128-bit integer")
191
+ if (index >> _HALF_BITS) & _RADIAL_DIRECTION_MASK or not h3.is_valid_cell(index & _MASK64):
192
+ _read_directed_edge(index)
193
+ else:
194
+ _read_index(index)
195
+
196
+
197
+ __all__ = []
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: h3v
3
+ Version: 0.1.0
4
+ Summary: Packed 128-bit H3 volume indices with independent surface and radial resolutions
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Repository, https://github.com/piglabsai/h3v
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Requires-Dist: h3==4.5.0
13
+ Provides-Extra: docs
14
+ Requires-Dist: sphinx<9,>=7.4; extra == "docs"
15
+ Requires-Dist: myst-parser<5,>=3; extra == "docs"
16
+ Requires-Dist: sphinx-book-theme<2,>=1.1; extra == "docs"
17
+ Dynamic: license-file
18
+
19
+ # H3V: H3 cells with altitude
20
+
21
+ **Experimental preview 0.1.0.** Public API and serialized-index compatibility
22
+ are not yet guaranteed. Record the H3V package version alongside persisted
23
+ voxel IDs. The encoded format version is currently 4.
24
+
25
+ **A voxel is H3V's equivalent of an H3 cell: a region with an ID.**
26
+ An H3 cell covers an area on Earth's surface. An H3V voxel combines that
27
+ cell with an altitude interval, giving it a vertical extent as well.
28
+
29
+ The starting operation is **latitude + longitude + altitude -> voxel ID**, using
30
+ `latlngalt_to_voxel()`. It works like H3's `latlng_to_cell()`, with altitude
31
+ and a separate radial resolution (altitude detail) added.
32
+
33
+ Use H3V to group positions by voxel, change grid detail, get boundaries for
34
+ drawing, calculate volumes, or measure straight lines between voxel centers.
35
+ Convert Earth-centered, Earth-fixed (ECEF) coordinates in kilometres using
36
+ `ecef_to_voxel()` and `voxel_to_ecef()`. ECEF indexing defaults to surface
37
+ resolution 15 and radial resolution 10; decoding returns the voxel center.
38
+
39
+ ## Install
40
+
41
+ From a checkout of this repository, with Python 3.10 or later:
42
+
43
+ ```console
44
+ python -m pip install .
45
+ ```
46
+
47
+ The H3 dependency is installed automatically.
48
+
49
+ ## First example
50
+
51
+ Find the voxel containing a point at latitude 52 degrees, longitude 13 degrees,
52
+ and altitude 1 km:
53
+
54
+ ```python
55
+ import h3v
56
+
57
+ voxel = h3v.latlngalt_to_voxel(
58
+ 52, 13, 1, surface_resolution=9, radial_resolution=7
59
+ )
60
+ print(h3v.get_resolution(voxel)) # (9, 7)
61
+
62
+ latitude, longitude, altitude_km = h3v.voxel_to_latlngalt(voxel)
63
+ print(round(altitude_km, 4)) # 1.0018
64
+ ```
65
+
66
+ The integer `voxel` identifies a region, not the original point. Decoding
67
+ returns the voxel center, so its altitude can differ from the input.
68
+
69
+ `surface_resolution` controls horizontal detail. `radial_resolution` controls
70
+ altitude thickness; level 7 is about 7.74 m thick. The two choices are independent.
71
+
72
+ ## What to know
73
+
74
+ - Latitude and longitude use degrees; altitude uses kilometres.
75
+ - Altitudes refer to a spherical Earth surface with an Earth radius of about
76
+ 6,371 km, not terrain or an ellipsoid.
77
+ - Every voxel ID represents a positive-volume voxel, including at altitude zero.
78
+ Both resolutions are required; bare H3 cells and old-format IDs are invalid.
79
+ Format v4 uses unsigned radial bases 0..255 and child digits 0..6 with `f` padding.
80
+ Base 0 covers Earth's interior; the exact altitude domain is `-R < h < 255*R`,
81
+ where `R` is the exact ratio represented by `authalic_earth_radius()`.
82
+ - Higher radial resolution divides thickness by seven, up to level 10
83
+ (about 0.0226 m). Surface resolution follows standard H3 levels 0 through 15.
84
+ - H3 footprint extraction uses H3's integer API. Voxel IDs are Python integers;
85
+ use `int_to_str()` and `str_to_int()` to exchange them as strings.
86
+
87
+ H3V is a project-specific extension, not an official H3 format.
88
+
89
+ ## Documentation
90
+
91
+ - [Understand the grid](docs/concepts.md): voxels, altitude, and resolution.
92
+ - [Usage guide](docs/usage.md): common tasks with runnable examples.
93
+ - [API quick reference](docs/api_quick.md): find a function by task.
94
+ - [API reference](docs/api_reference.md): parameters, units, and return values.
95
+ - [Format specification](docs/format.md): exact interval rules and encoding.
96
+ - [Contributing](docs/contributing.md): tests, documentation builds, and local preview.
97
+
98
+ Build the documentation locally with Python 3.12 or later:
99
+
100
+ ```powershell
101
+ .\.venv\Scripts\python.exe -m pip install -e ".[docs]"
102
+ .\.venv\Scripts\python.exe -m sphinx -b html -n -W --keep-going docs docs/_build/html
103
+ ```
104
+
105
+ Open `docs/_build/html/index.html`, or follow the contributor guide to serve it
106
+ on localhost. Documentation sources are tracked by Git; the generated HTML is
107
+ not. The current workflow checks documentation without publishing it.
108
+
109
+ The repository is <https://github.com/piglabsai/h3v>.
110
+ Licensed under the [Apache License 2.0](LICENSE).
@@ -0,0 +1,17 @@
1
+ _h3v_core.py,sha256=vN_bE6LHQdRDptkmfeL6iUj963vFO1C7gXsjp6zwd4k,7475
2
+ h3v.py,sha256=eToC__3rlHSq_LNFrJvFNlQTfswRrPu8AcN75uUpJP0,2284
3
+ h3v_directed_edges.py,sha256=zFx3serFnCGYT6NR5r_LvPpeou2qbqbQl0uO93USus0,5954
4
+ h3v_geometry.py,sha256=vzwu4xO_djzZ3gaahWsgL2xXol3BeWvX5ISYrtybzyw,20450
5
+ h3v_hierarchy.py,sha256=WCxyWzCrhdWlkUjIa25QDADk9BdOR0T2EQzolY-iuzM,4934
6
+ h3v_indexing.py,sha256=zYKux-zT7OyGLYdGOtQD1kp0LQupUPZ1peuD4pN3XAg,16229
7
+ h3v_inspection.py,sha256=RIuqzHgYKu-xC0lnxLPEUXNn421Z8aHSWJCLH0GKxpw,4731
8
+ h3v_miscellaneous.py,sha256=FhcxpQ-Xs-W7GrB1AS0GU87i2zX-VnRHoULsbfZ5XA0,1358
9
+ h3v_regions.py,sha256=Qnwq6A3_bqIOoIvtZrvrQg2-dN8s7SMCYX0UFFGApK0,88
10
+ h3v_traversal.py,sha256=nrFaD64WFaEsVzvg9p9Cke82LD0Cohy9soLMxy3WCr0,4979
11
+ h3v_vertexes.py,sha256=PQ8zyhxa-3ehV3R4z4gjmdxtDijuYDOd2758Oo3Rfx0,89
12
+ h3v-0.1.0.dist-info/licenses/LICENSE,sha256=x9ojFkiG3QSO2INDLO4tyhtQqkqf8LLicIaFT_aKylQ,11540
13
+ h3v-0.1.0.dist-info/licenses/NOTICE,sha256=-meAH9kkLlS6-r3J3ZlD9U53FWixWyGrAThWriLRofM,410
14
+ h3v-0.1.0.dist-info/METADATA,sha256=_rvXvy7PT08qHChkYRDaypx6JXc9lqF6ixZcIJ1UbCQ,4607
15
+ h3v-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
16
+ h3v-0.1.0.dist-info/top_level.txt,sha256=fjdkWvhgcv2LuHFd7PckEVONOXrAXTObnDGulLUz8gs,145
17
+ h3v-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Piglabs
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ H3V
2
+ Copyright 2026 H3V contributors
3
+
4
+ Licensed under the Apache License, Version 2.0. See LICENSE.
5
+
6
+ H3V is an independent extension and is not an official H3 format.
7
+ H3V depends on H3 through h3-py, projects maintained by Uber Technologies
8
+ and their contributors and distributed separately under Apache License 2.0.
9
+ The authalic Earth radius follows H3's EARTH_RADIUS_KM constant:
10
+ 6371.007180918475 kilometres.
@@ -0,0 +1,11 @@
1
+ _h3v_core
2
+ h3v
3
+ h3v_directed_edges
4
+ h3v_geometry
5
+ h3v_hierarchy
6
+ h3v_indexing
7
+ h3v_inspection
8
+ h3v_miscellaneous
9
+ h3v_regions
10
+ h3v_traversal
11
+ h3v_vertexes
h3v.py ADDED
@@ -0,0 +1,66 @@
1
+ """H3V: a 3D grid whose voxels are the equivalent of H3 surface cells.
2
+
3
+ A voxel combines an H3 cell with an altitude interval.
4
+ Find a voxel from latitude, longitude, and altitude. Read its center, change
5
+ its resolutions, get outlines for drawing, or measure volumes and straight
6
+ lines between voxel centers. A voxel ID is an ordinary Python integer.
7
+ Convert spherical Earth-centered, Earth-fixed (ECEF) coordinates to voxels,
8
+ or return a voxel center as Cartesian coordinates in kilometres.
9
+
10
+ Latitude and longitude are degrees; altitude is kilometres above the spherical
11
+ reference Earth surface. Earth radius is about 6,371 km, matching H3.
12
+ Surface resolution controls horizontal detail. Altitude resolution (the API's
13
+ radial_resolution) controls vertical thickness, dividing it by seven per level.
14
+
15
+ Every voxel has positive radial thickness and volume, including at altitude zero.
16
+ The Earth center is excluded. Public functions raise ValueError for invalid
17
+ arguments; validation predicates return False instead. See the usage guide and
18
+ format specification for examples and the exact geometry contract.
19
+ """
20
+
21
+ from h3v_indexing import *
22
+ from h3v_inspection import *
23
+ from h3v_traversal import *
24
+ from h3v_hierarchy import *
25
+ from h3v_regions import *
26
+ from h3v_directed_edges import *
27
+ from h3v_vertexes import *
28
+ from h3v_geometry import *
29
+ from h3v_miscellaneous import *
30
+
31
+
32
+ __all__ = [
33
+ 'latlngalt_to_voxel',
34
+ 'voxel_to_latlngalt',
35
+ 'ecef_to_voxel',
36
+ 'voxel_to_ecef',
37
+ 'voxel_to_altitude_bounds',
38
+ 'voxel_to_boundary',
39
+ 'get_resolution',
40
+ 'is_valid_voxel',
41
+ 'voxel_to_cell',
42
+ 'int_to_str',
43
+ 'str_to_int',
44
+ 'grid_distance',
45
+ 'grid_ring',
46
+ 'grid_disk',
47
+ 'voxel_to_parent',
48
+ 'voxel_to_children',
49
+ 'are_neighbor_voxels',
50
+ 'voxels_to_directed_edge',
51
+ 'is_valid_directed_edge',
52
+ 'get_directed_edge_origin',
53
+ 'get_directed_edge_destination',
54
+ 'directed_edge_to_voxels',
55
+ 'origin_to_directed_edges',
56
+ 'reverse_directed_edge',
57
+ 'voxel_volume',
58
+ 'voxels_to_line',
59
+ 'voxels_to_vector_ecef',
60
+ 'voxels_to_great_circle',
61
+ 'visibility_cap_radius',
62
+ 'authalic_earth_radius',
63
+ 'RADIAL_BASE_STEP',
64
+ 'MAX_RADIAL_RESOLUTION',
65
+ 'MAX_ALTITUDE',
66
+ ]