Skip to content

Commit 1670c2a

Browse files
committed
fix ap7 bug
1 parent 5d4cb29 commit 1670c2a

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
All changes are by Kevin Sahr, unless otherwise noted.
55

6+
## [8.2] - 2024-06-05
7+
### Fixed
8+
- bug binning some points that are very close to certain icosahedron edges into odd aperture 7 resolutions
9+
610
## [8.1b] - 2024-01-10
711
### Added
812
- pure aperture 7 hexagon grids (ISEA7H/FULLER7H) are now first class DGGS that support all operations (just like aperture 3 and 4 hexagon DGGS)

src/lib/dglib/lib/DgIDGGutil.cpp

+15-10
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,14 @@ dgcout << " ---> A. " << *loc << endl;
346346
dgcout << " ---> B. " << coord << endl;
347347
#endif
348348

349-
long long int edgeI = IDGG().maxI() + 1;
350-
long long int edgeJ = IDGG().maxJ() + 1;
351-
if (coord.i() > edgeI || coord.j() > edgeJ) { // maybe round-off error?
349+
long long int maxI = IDGG().maxI();
350+
long long int maxJ = IDGG().maxJ();
351+
long long int edgeI = maxI + 1;
352+
long long int edgeJ = maxJ + 1;
353+
long long int maxOverageI = (IDGG().aperture() == 7 && IDGG().isClassI()) ? edgeI + 1 : edgeI;
354+
long long int maxOverageJ = (IDGG().aperture() == 7 && IDGG().isClassI()) ? edgeJ + 1 : edgeJ;
355+
356+
if (coord.i() > maxOverageI || coord.j() > maxOverageJ) { // maybe round-off error?
352357

353358
DgDVec2D tmp(addIn.coord());
354359

@@ -366,35 +371,35 @@ dgcout << " ---> C. " << coord << endl;
366371
#endif
367372

368373
if (coord.i() < 0 || coord.j() < 0 ||
369-
coord.i() > edgeI || coord.j() > edgeJ) {
374+
coord.i() > maxOverageI || coord.j() > maxOverageJ) {
370375
report("DgQ2DDtoIConverter::convertTypedAddress(): "
371376
" coordinate out of range: " + (string) coord, DgBase::Fatal);
372-
} else if (coord.i() == edgeI || coord.j() == edgeJ) {
377+
} else if (coord.i() > maxI || coord.j() > maxJ) {
373378
const DgQuadEdgeCells& ec = IDGG().edgeTable(quadNum);
374379

375380
if (ec.isType0()) {
376-
if (coord.j() == edgeJ) {
381+
if (coord.j() > maxI) {
377382
if (coord.i() == 0) {
378383
quadNum = ec.loneVert();
379384
coord = DgIVec2D(0, 0);
380385
} else {
381386
quadNum = ec.upQuad();
382-
coord = DgIVec2D(0, edgeI - coord.i());
387+
coord = DgIVec2D((maxOverageI - edgeI), maxOverageI - coord.i());
383388
}
384389
} else { // i == edgeI
385390
quadNum = ec.rightQuad();
386391
coord.setI(0);
387392
}
388393
} else { // type 1
389-
if (coord.i() == edgeI) {
394+
if (coord.i() > maxI) {
390395
if (coord.j() == 0) {
391396
quadNum = ec.loneVert();
392397
coord = DgIVec2D(0, 0);
393398
} else {
394399
quadNum = ec.rightQuad();
395-
coord = DgIVec2D(edgeJ - coord.j(), 0);
400+
coord = DgIVec2D(maxOverageJ - coord.j(), (maxOverageJ - edgeJ));
396401
}
397-
} else { // j == edgeJ
402+
} else { // j > maxJ
398403
quadNum = ec.upQuad();
399404
coord.setJ(0);
400405
}

0 commit comments

Comments
 (0)