Skip to content

Commit 1a496e4

Browse files
2.1.1 Point Fractions via Integer arithmetic
1 parent c41d0f1 commit 1a496e4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/mapcode/Encoder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ private static String encodeExtension(final Point pointToEncode, final int extra
143143

144144
double factorx = Point.MAX_PRECISION_FACTOR * dividerx4;
145145
double factory = Point.MAX_PRECISION_FACTOR * dividery;
146-
double valx = (Point.MAX_PRECISION_FACTOR * extrax4) + pointToEncode.LonFractions();
147-
double valy = (Point.MAX_PRECISION_FACTOR * extray ) + (ydirection * pointToEncode.LatFractions());
146+
double valx = (Point.MAX_PRECISION_FACTOR * extrax4) + pointToEncode.getLonFractions();
147+
double valy = (Point.MAX_PRECISION_FACTOR * extray ) + (ydirection * pointToEncode.getLatFractions());
148148

149149
String s = "-";
150150

@@ -310,7 +310,7 @@ private static String encodeAutoHeader(final Point pointToEncode, final int this
310310
int extray = (maxy - pointToEncode.getLatMicroDeg()) % dividery;
311311

312312
int value = (vx / 168) * (h / 176);
313-
if ((extray==0) && (pointToEncode.LatFractions() > 0)) {
313+
if ((extray==0) && (pointToEncode.getLatFractions() > 0)) {
314314
vy--;
315315
extray += dividery;
316316
}
@@ -377,7 +377,7 @@ private static String encodeNameless(final Point pointToEncode, final int index,
377377
final int miny = Data.getBoundaries(index).getMinY();
378378

379379
final int dividerx4 = xDivider(miny, maxy);
380-
final int xFracture = (int) (pointToEncode.LonFractions() / Point.MAX_PRECISION_FACTOR);
380+
final int xFracture = pointToEncode.getLonFractions() / 810000;
381381
final int dminx = pointToEncode.getLonMicroDeg() - minx;
382382
final int dx = ((4 * dminx) + xFracture) / dividerx4;
383383
final int extrax4 = (4 * dminx) - (dx * dividerx4); // like modulus, but with floating point value
@@ -387,7 +387,7 @@ private static String encodeNameless(final Point pointToEncode, final int index,
387387
int dy = dmaxy / dividery;
388388
int extray = dmaxy % dividery;
389389

390-
if ((extray == 0) && (pointToEncode.LatFractions()>0)) {
390+
if ((extray == 0) && (pointToEncode.getLatFractions() > 0)) {
391391
dy--;
392392
extray += dividery;
393393
}

0 commit comments

Comments
 (0)