diff options
author | David Beaumont <dbeaumont@google.com> | 2011-11-08 11:05:51 -0500 |
---|---|---|
committer | Michael Bolin <bolinfest@google.com> | 2011-11-08 11:05:51 -0500 |
commit | c04b68bf3197a9c34082327eeb3aec7ab7c85da1 (patch) | |
tree | eeb2df04d39a12c696381239d04366436323b5e3 | |
parent | 33f470054f67665c0d535ba3b11e5e9cedfcc8f2 (diff) | |
download | s2-geometry-library-java-c04b68bf3197a9c34082327eeb3aec7ab7c85da1.tar.gz |
Automatic refactoring to encapsulate fields of R2Vector.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=25130844
-rw-r--r-- | src/com/google/common/geometry/R2Vector.java | 12 | ||||
-rw-r--r-- | src/com/google/common/geometry/S2Cell.java | 4 | ||||
-rw-r--r-- | src/com/google/common/geometry/S2CellId.java | 6 | ||||
-rw-r--r-- | tests/com/google/common/geometry/S2CellIdTest.java | 8 |
4 files changed, 19 insertions, 11 deletions
diff --git a/src/com/google/common/geometry/R2Vector.java b/src/com/google/common/geometry/R2Vector.java index 2198d1f..77a3591 100644 --- a/src/com/google/common/geometry/R2Vector.java +++ b/src/com/google/common/geometry/R2Vector.java @@ -22,8 +22,8 @@ package com.google.common.geometry; * */ public final strictfp class R2Vector { - final double x; - final double y; + private final double x; + private final double y; public R2Vector() { this(0, 0); @@ -42,6 +42,14 @@ public final strictfp class R2Vector { y = coord[1]; } + public double x() { + return x; + } + + public double y() { + return y; + } + public double get(int index) { if (index > 1) { throw new ArrayIndexOutOfBoundsException(index); diff --git a/src/com/google/common/geometry/S2Cell.java b/src/com/google/common/geometry/S2Cell.java index dea2b4f..dc5bb88 100644 --- a/src/com/google/common/geometry/S2Cell.java +++ b/src/com/google/common/geometry/S2Cell.java @@ -368,8 +368,8 @@ public final strictfp class S2Cell implements S2Region { if (uvPoint == null) { return false; } - return (uvPoint.x >= uv[0][0] && uvPoint.x <= uv[0][1] && uvPoint.y >= uv[1][0] - && uvPoint.y <= uv[1][1]); + return (uvPoint.x() >= uv[0][0] && uvPoint.x() <= uv[0][1] + && uvPoint.y() >= uv[1][0] && uvPoint.y() <= uv[1][1]); } // The point 'p' does not need to be normalized. diff --git a/src/com/google/common/geometry/S2CellId.java b/src/com/google/common/geometry/S2CellId.java index 00b93fe..4d108e5 100644 --- a/src/com/google/common/geometry/S2CellId.java +++ b/src/com/google/common/geometry/S2CellId.java @@ -148,8 +148,8 @@ public final strictfp class S2CellId implements Comparable<S2CellId> { public static S2CellId fromPoint(S2Point p) { int face = S2Projections.xyzToFace(p); R2Vector uv = S2Projections.validFaceXyzToUv(face, p); - int i = stToIJ(S2Projections.uvToST(uv.x)); - int j = stToIJ(S2Projections.uvToST(uv.y)); + int i = stToIJ(S2Projections.uvToST(uv.x())); + int j = stToIJ(S2Projections.uvToST(uv.y())); return fromFaceIJ(face, i, j); } @@ -866,7 +866,7 @@ public final strictfp class S2CellId implements Comparable<S2CellId> { S2Point p = S2Projections.faceUvToXyz(face, s, t); face = S2Projections.xyzToFace(p); R2Vector st = S2Projections.validFaceXyzToUv(face, p); - return fromFaceIJ(face, stToIJ(st.x), stToIJ(st.y)); + return fromFaceIJ(face, stToIJ(st.x()), stToIJ(st.y())); } /** diff --git a/tests/com/google/common/geometry/S2CellIdTest.java b/tests/com/google/common/geometry/S2CellIdTest.java index 9a959e7..c7a8b02 100644 --- a/tests/com/google/common/geometry/S2CellIdTest.java +++ b/tests/com/google/common/geometry/S2CellIdTest.java @@ -196,10 +196,10 @@ public strictfp class S2CellIdTest extends GeometryTestCase { S2Point p = id.toPointRaw(); int face = S2Projections.xyzToFace(p); R2Vector uv = S2Projections.validFaceXyzToUv(face, p); - assertDoubleNear( - Math.IEEEremainder(S2Projections.uvToST(uv.x), 1.0 / (1 << MAX_WALK_LEVEL)), 0); - assertDoubleNear( - Math.IEEEremainder(S2Projections.uvToST(uv.y), 1.0 / (1 << MAX_WALK_LEVEL)), 0); + assertDoubleNear(Math.IEEEremainder( + S2Projections.uvToST(uv.x()), 1.0 / (1 << MAX_WALK_LEVEL)), 0); + assertDoubleNear(Math.IEEEremainder( + S2Projections.uvToST(uv.y()), 1.0 / (1 << MAX_WALK_LEVEL)), 0); } } |