Skip to content

Commit c04b68b

Browse files
hagbardMichael Bolin
authored andcommitted
Automatic refactoring to encapsulate fields of R2Vector.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=25130844
1 parent 33f4700 commit c04b68b

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/com/google/common/geometry/R2Vector.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
*
2323
*/
2424
public final strictfp class R2Vector {
25-
final double x;
26-
final double y;
25+
private final double x;
26+
private final double y;
2727

2828
public R2Vector() {
2929
this(0, 0);
@@ -42,6 +42,14 @@ public R2Vector(double[] coord) {
4242
y = coord[1];
4343
}
4444

45+
public double x() {
46+
return x;
47+
}
48+
49+
public double y() {
50+
return y;
51+
}
52+
4553
public double get(int index) {
4654
if (index > 1) {
4755
throw new ArrayIndexOutOfBoundsException(index);

src/com/google/common/geometry/S2Cell.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ public boolean contains(S2Point p) {
368368
if (uvPoint == null) {
369369
return false;
370370
}
371-
return (uvPoint.x >= uv[0][0] && uvPoint.x <= uv[0][1] && uvPoint.y >= uv[1][0]
372-
&& uvPoint.y <= uv[1][1]);
371+
return (uvPoint.x() >= uv[0][0] && uvPoint.x() <= uv[0][1]
372+
&& uvPoint.y() >= uv[1][0] && uvPoint.y() <= uv[1][1]);
373373
}
374374

375375
// The point 'p' does not need to be normalized.

src/com/google/common/geometry/S2CellId.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ public static S2CellId fromFacePosLevel(int face, long pos, int level) {
148148
public static S2CellId fromPoint(S2Point p) {
149149
int face = S2Projections.xyzToFace(p);
150150
R2Vector uv = S2Projections.validFaceXyzToUv(face, p);
151-
int i = stToIJ(S2Projections.uvToST(uv.x));
152-
int j = stToIJ(S2Projections.uvToST(uv.y));
151+
int i = stToIJ(S2Projections.uvToST(uv.x()));
152+
int j = stToIJ(S2Projections.uvToST(uv.y()));
153153
return fromFaceIJ(face, i, j);
154154
}
155155

@@ -866,7 +866,7 @@ private static S2CellId fromFaceIJWrap(int face, int i, int j) {
866866
S2Point p = S2Projections.faceUvToXyz(face, s, t);
867867
face = S2Projections.xyzToFace(p);
868868
R2Vector st = S2Projections.validFaceXyzToUv(face, p);
869-
return fromFaceIJ(face, stToIJ(st.x), stToIJ(st.y));
869+
return fromFaceIJ(face, stToIJ(st.x()), stToIJ(st.y()));
870870
}
871871

872872
/**

tests/com/google/common/geometry/S2CellIdTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ public void testContinuity() {
196196
S2Point p = id.toPointRaw();
197197
int face = S2Projections.xyzToFace(p);
198198
R2Vector uv = S2Projections.validFaceXyzToUv(face, p);
199-
assertDoubleNear(
200-
Math.IEEEremainder(S2Projections.uvToST(uv.x), 1.0 / (1 << MAX_WALK_LEVEL)), 0);
201-
assertDoubleNear(
202-
Math.IEEEremainder(S2Projections.uvToST(uv.y), 1.0 / (1 << MAX_WALK_LEVEL)), 0);
199+
assertDoubleNear(Math.IEEEremainder(
200+
S2Projections.uvToST(uv.x()), 1.0 / (1 << MAX_WALK_LEVEL)), 0);
201+
assertDoubleNear(Math.IEEEremainder(
202+
S2Projections.uvToST(uv.y()), 1.0 / (1 << MAX_WALK_LEVEL)), 0);
203203
}
204204
}
205205

0 commit comments

Comments
 (0)