use of com.google.firebase.firestore.GeoPoint in project firebase-android-sdk by firebase.
the class ValuesTest method testCanonicalIds.
@Test
public void testCanonicalIds() {
assertCanonicalId(TestUtil.wrap(null), "null");
assertCanonicalId(TestUtil.wrap(true), "true");
assertCanonicalId(TestUtil.wrap(false), "false");
assertCanonicalId(TestUtil.wrap(1), "1");
assertCanonicalId(TestUtil.wrap(1.0), "1.0");
assertCanonicalId(TestUtil.wrap(new Timestamp(30, 1000)), "time(30,1000)");
assertCanonicalId(TestUtil.wrap("a"), "a");
assertCanonicalId(TestUtil.wrap(blob(1, 2, 3)), "010203");
assertCanonicalId(wrapRef(dbId("p1", "d1"), key("c1/doc1")), "c1/doc1");
assertCanonicalId(TestUtil.wrap(new GeoPoint(30, 60)), "geo(30.0,60.0)");
assertCanonicalId(TestUtil.wrap(Arrays.asList(1, 2, 3)), "[1,2,3]");
assertCanonicalId(TestUtil.wrap(map("a", 1, "b", 2, "c", "3")), "{a:1,b:2,c:3}");
assertCanonicalId(TestUtil.wrap(map("a", Arrays.asList("b", map("c", new GeoPoint(30, 60))))), "{a:[b,{c:geo(30.0,60.0)}]}");
}
use of com.google.firebase.firestore.GeoPoint in project firebase-android-sdk by firebase.
the class ValuesTest method testValueEquality.
@Test
public void testValueEquality() {
GeoPoint geoPoint1 = new GeoPoint(1, 0);
GeoPoint geoPoint2 = new GeoPoint(0, 2);
Timestamp timestamp1 = new Timestamp(date1);
Timestamp timestamp2 = new Timestamp(date2);
new EqualsTester().addEqualityGroup(wrap(true), wrap(true)).addEqualityGroup(wrap(false), wrap(false)).addEqualityGroup(wrap((Object) null), wrap(Values.NULL_VALUE)).addEqualityGroup(wrap(0.0 / 0.0), wrap(Double.longBitsToDouble(0x7ff8000000000000L)), wrap(Values.NAN_VALUE)).addEqualityGroup(wrap(-0.0)).addEqualityGroup(wrap(0.0)).addEqualityGroup(wrap(1), wrap(1)).addEqualityGroup(wrap(1.0), wrap(1.0)).addEqualityGroup(wrap(1.1), wrap(1.1)).addEqualityGroup(wrap(blob(0, 1, 2)), wrap(blob(0, 1, 2))).addEqualityGroup(wrap(blob(0, 1))).addEqualityGroup(wrap("string"), wrap("string")).addEqualityGroup(wrap("strin")).addEqualityGroup(wrap("e\u0301b")).addEqualityGroup(wrap("\u00e9a")).addEqualityGroup(wrap(date1), wrap(timestamp1)).addEqualityGroup(wrap(timestamp2)).addEqualityGroup(wrap(ServerTimestamps.valueOf(new Timestamp(date1), null)), wrap(ServerTimestamps.valueOf(new Timestamp(date1), null))).addEqualityGroup(wrap(ServerTimestamps.valueOf(new Timestamp(date2), null))).addEqualityGroup(wrap(geoPoint1), wrap(new GeoPoint(1, 0))).addEqualityGroup(wrap(geoPoint2)).addEqualityGroup(wrap(ref("coll/doc1")), wrap(wrapRef(dbId("project"), key("coll/doc1")))).addEqualityGroup(wrap(wrapRef(dbId("project", "bar"), key("coll/doc2")))).addEqualityGroup(wrap(wrapRef(dbId("project", "baz"), key("coll/doc2")))).addEqualityGroup(wrap(Arrays.asList("foo", "bar")), wrap(Arrays.asList("foo", "bar"))).addEqualityGroup(wrap(Arrays.asList("foo", "bar", "baz"))).addEqualityGroup(wrap(Arrays.asList("foo"))).addEqualityGroup(wrap(map("bar", 1, "foo", 2)), wrap(map("foo", 2, "bar", 1))).addEqualityGroup(wrap(map("bar", 2, "foo", 1))).addEqualityGroup(wrap(map("bar", 1))).addEqualityGroup(wrap(map("foo", 1))).testEquals();
}
use of com.google.firebase.firestore.GeoPoint in project turtleparties by CMPUT301W22T21.
the class MapsActivity method addQRMarkers.
public void addQRMarkers(@NonNull GoogleMap googleMap) {
mMap = googleMap;
db.collection("QR codes").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot doc : task.getResult()) {
String qrname = doc.getId();
db.collection("QR codes").document(qrname).get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot doc = task.getResult();
Integer score = ((Number) doc.getData().get("score")).intValue();
GeoPoint qrGeoPoint = (GeoPoint) doc.getData().get("geolocation");
Double latval = 0.0;
Double longval = 0.0;
try {
latval = qrGeoPoint.getLatitude();
longval = qrGeoPoint.getLongitude();
} catch (Exception e) {
Log.d(TAG, "EMPTY GEOPOINT");
}
Log.d(TAG, latval + " " + longval + " " + score);
LatLng thisMarker = new LatLng(latval, longval);
mMap.addMarker(new MarkerOptions().position(thisMarker).title(String.valueOf(score)));
}
}
});
}
} else {
Log.d(TAG, "Error getting documents: ", task.getException());
}
}
});
}
use of com.google.firebase.firestore.GeoPoint in project turtleparties by CMPUT301W22T21.
the class QRCodesTest method checkHasGeoPoint.
@Test
public void checkHasGeoPoint() {
GeoPoint gp = new GeoPoint(12, 12);
testQR.setGeolocation(gp);
assertTrue(testQR.hasGeoLocation());
}
use of com.google.firebase.firestore.GeoPoint in project turtleparties by CMPUT301W22T21.
the class QRCodesTest method checkCorrectGeoPointReturned.
@Test
public void checkCorrectGeoPointReturned() {
GeoPoint gp = new GeoPoint(12, 12);
testQR.setGeolocation(gp);
GeoPoint ap = testQR.getGeolocation();
assertEquals(ap, gp);
}
Aggregations