Skip to content

Commit

Permalink
fix ap7 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sahrkm committed Jun 5, 2024
1 parent 5d4cb29 commit 1670c2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

All changes are by Kevin Sahr, unless otherwise noted.

## [8.2] - 2024-06-05
### Fixed
- bug binning some points that are very close to certain icosahedron edges into odd aperture 7 resolutions

## [8.1b] - 2024-01-10
### Added
- pure aperture 7 hexagon grids (ISEA7H/FULLER7H) are now first class DGGS that support all operations (just like aperture 3 and 4 hexagon DGGS)
Expand Down
25 changes: 15 additions & 10 deletions src/lib/dglib/lib/DgIDGGutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,14 @@ dgcout << " ---> A. " << *loc << endl;
dgcout << " ---> B. " << coord << endl;
#endif

long long int edgeI = IDGG().maxI() + 1;
long long int edgeJ = IDGG().maxJ() + 1;
if (coord.i() > edgeI || coord.j() > edgeJ) { // maybe round-off error?
long long int maxI = IDGG().maxI();
long long int maxJ = IDGG().maxJ();
long long int edgeI = maxI + 1;
long long int edgeJ = maxJ + 1;
long long int maxOverageI = (IDGG().aperture() == 7 && IDGG().isClassI()) ? edgeI + 1 : edgeI;
long long int maxOverageJ = (IDGG().aperture() == 7 && IDGG().isClassI()) ? edgeJ + 1 : edgeJ;

if (coord.i() > maxOverageI || coord.j() > maxOverageJ) { // maybe round-off error?

DgDVec2D tmp(addIn.coord());

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

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

if (ec.isType0()) {
if (coord.j() == edgeJ) {
if (coord.j() > maxI) {
if (coord.i() == 0) {
quadNum = ec.loneVert();
coord = DgIVec2D(0, 0);
} else {
quadNum = ec.upQuad();
coord = DgIVec2D(0, edgeI - coord.i());
coord = DgIVec2D((maxOverageI - edgeI), maxOverageI - coord.i());
}
} else { // i == edgeI
quadNum = ec.rightQuad();
coord.setI(0);
}
} else { // type 1
if (coord.i() == edgeI) {
if (coord.i() > maxI) {
if (coord.j() == 0) {
quadNum = ec.loneVert();
coord = DgIVec2D(0, 0);
} else {
quadNum = ec.rightQuad();
coord = DgIVec2D(edgeJ - coord.j(), 0);
coord = DgIVec2D(maxOverageJ - coord.j(), (maxOverageJ - edgeJ));
}
} else { // j == edgeJ
} else { // j > maxJ
quadNum = ec.upQuad();
coord.setJ(0);
}
Expand Down

0 comments on commit 1670c2a

Please sign in to comment.