diff --git a/src/com/google/android/gms/maps/model/CircleOptions.java b/src/com/google/android/gms/maps/model/CircleOptions.java
index e022467..82f2af5 100644
--- a/src/com/google/android/gms/maps/model/CircleOptions.java
+++ b/src/com/google/android/gms/maps/model/CircleOptions.java
@@ -211,8 +211,8 @@ public class CircleOptions implements SafeParcelable {
}
@Override
- public void writeToParcel(Parcel dest, int flags) {
- SafeParcelUtil.writeObject(this, dest, flags);
+ public void writeToParcel(Parcel out, int flags) {
+ SafeParcelUtil.writeObject(this, out, flags);
}
/**
diff --git a/src/com/google/android/gms/maps/model/GroundOverlayOptions.java b/src/com/google/android/gms/maps/model/GroundOverlayOptions.java
index 856ec8a..0792a82 100644
--- a/src/com/google/android/gms/maps/model/GroundOverlayOptions.java
+++ b/src/com/google/android/gms/maps/model/GroundOverlayOptions.java
@@ -335,8 +335,8 @@ public class GroundOverlayOptions implements SafeParcelable {
}
@Override
- public void writeToParcel(Parcel dest, int flags) {
- SafeParcelUtil.writeObject(this, dest, flags);
+ public void writeToParcel(Parcel out, int flags) {
+ SafeParcelUtil.writeObject(this, out, flags);
}
/**
diff --git a/src/com/google/android/gms/maps/model/LatLng.java b/src/com/google/android/gms/maps/model/LatLng.java
index 225828a..0844021 100644
--- a/src/com/google/android/gms/maps/model/LatLng.java
+++ b/src/com/google/android/gms/maps/model/LatLng.java
@@ -21,16 +21,47 @@ import org.microg.safeparcel.SafeParcelUtil;
import org.microg.safeparcel.SafeParcelable;
import org.microg.safeparcel.SafeParceled;
-public class LatLng implements SafeParcelable {
+/**
+ * An immutable class representing a pair of latitude and longitude coordinates, stored as degrees.
+ */
+public final class LatLng implements SafeParcelable {
@SafeParceled(1)
- private int versionCode;
+ private final int versionCode;
+ /**
+ * Latitude, in degrees. This value is in the range [-90, 90].
+ */
@SafeParceled(2)
- public double latitude;
+ public final double latitude;
+ /**
+ * Longitude, in degrees. This value is in the range [-180, 180).
+ */
@SafeParceled(3)
- public double longitude;
+ public final double longitude;
- public LatLng(int versionCode, double latitude, double longitude) {
- this.versionCode = versionCode;
+ /**
+ * This constructor is dirty setting the final fields to make the compiler happy.
+ * In fact, those are replaced by their real values later using SafeParcelUtil.
+ */
+ private LatLng() {
+ versionCode = -1;
+ latitude = longitude = 0;
+ }
+
+ private LatLng(Parcel in) {
+ this();
+ SafeParcelUtil.readObject(this, in);
+ }
+
+ /**
+ * Constructs a LatLng with the given latitude and longitude, measured in degrees.
+ *
+ * @param latitude The point's latitude. This will be clamped to between -90 degrees and
+ * +90 degrees inclusive.
+ * @param longitude The point's longitude. This will be normalized to be within -180 degrees
+ * inclusive and +180 degrees exclusive.
+ */
+ public LatLng(double latitude, double longitude) {
+ this.versionCode = 1;
this.latitude = Math.max(-90, Math.min(90, latitude));
if ((-180 <= longitude) && (longitude < 180)) {
this.longitude = longitude;
@@ -39,12 +70,28 @@ public class LatLng implements SafeParcelable {
}
}
- private LatLng(Parcel in) {
- SafeParcelUtil.readObject(this, in);
- }
+ /**
+ * Tests if this LatLng is equal to another.
+ *
+ * Two points are considered equal if and only if their latitudes are bitwise equal and their
+ * longitudes are bitwise equal. This means that two {@link LatLng}s that are very near, in
+ * terms of geometric distance, might not be considered {@code .equal()}.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
- public LatLng(double latitude, double longitude) {
- this(1, latitude, longitude);
+ LatLng latLng = (LatLng) o;
+
+ if (Double.compare(latLng.latitude, latitude) != 0)
+ return false;
+ if (Double.compare(latLng.longitude, longitude) != 0)
+ return false;
+
+ return true;
}
@Override
@@ -66,8 +113,8 @@ public class LatLng implements SafeParcelable {
}
@Override
- public void writeToParcel(Parcel dest, int flags) {
- SafeParcelUtil.writeObject(this, dest, flags);
+ public void writeToParcel(Parcel out, int flags) {
+ SafeParcelUtil.writeObject(this, out, flags);
}
public static Creator CREATOR = new Creator() {
diff --git a/src/com/google/android/gms/maps/model/LatLngBounds.java b/src/com/google/android/gms/maps/model/LatLngBounds.java
index 371facb..b864857 100644
--- a/src/com/google/android/gms/maps/model/LatLngBounds.java
+++ b/src/com/google/android/gms/maps/model/LatLngBounds.java
@@ -21,28 +21,43 @@ import org.microg.safeparcel.SafeParcelUtil;
import org.microg.safeparcel.SafeParcelable;
import org.microg.safeparcel.SafeParceled;
-public class LatLngBounds implements SafeParcelable {
+/**
+ * An immutable class representing a latitude/longitude aligned rectangle.
+ */
+public final class LatLngBounds implements SafeParcelable {
@SafeParceled(1)
- private int versionCode;
+ private final int versionCode;
+ /**
+ * Southwest corner of the bound.
+ */
@SafeParceled(2)
- public LatLng southWest;
+ public final LatLng southwest;
+ /**
+ * Northeast corner of the bound.
+ */
@SafeParceled(3)
- public LatLng northEast;
+ public final LatLng northeast;
- public LatLngBounds(int versionCode, LatLng southWest, LatLng northEast) {
- this.versionCode = versionCode;
- this.southWest = southWest;
- this.northEast = northEast;
- }
-
- public LatLngBounds(LatLng southWest, LatLng northEast) {
- this(1, southWest, northEast);
+ /**
+ * This constructor is dirty setting the final fields to make the compiler happy.
+ * In fact, those are replaced by their real values later using SafeParcelUtil.
+ */
+ private LatLngBounds() {
+ this.versionCode = -1;
+ southwest = northeast = null;
}
private LatLngBounds(Parcel in) {
+ this();
SafeParcelUtil.readObject(this, in);
}
+ public LatLngBounds(LatLng southwest, LatLng northeast) throws IllegalArgumentException {
+ this.versionCode = 1;
+ this.southwest = southwest;
+ this.northeast = northeast;
+ }
+
@Override
public int describeContents() {
return 0;
diff --git a/src/com/google/android/gms/maps/model/PolylineOptions.java b/src/com/google/android/gms/maps/model/PolylineOptions.java
index 6cc21ac..ee92793 100644
--- a/src/com/google/android/gms/maps/model/PolylineOptions.java
+++ b/src/com/google/android/gms/maps/model/PolylineOptions.java
@@ -17,50 +17,47 @@
package com.google.android.gms.maps.model;
import android.os.Parcel;
-import android.os.Parcelable;
import org.microg.safeparcel.SafeParcelUtil;
import org.microg.safeparcel.SafeParcelable;
import org.microg.safeparcel.SafeParceled;
-import java.util.ArrayList;
import java.util.List;
public class PolylineOptions implements SafeParcelable {
- @SafeParceled(1)
- private int versionCode;
- // TODO
- private List points;
- private float width;
- private int color;
- private float zIndex;
- private boolean visible;
- private boolean geodesic;
+ @SafeParceled(1)
+ private int versionCode;
+ // TODO
+ private List points;
+ private float width;
+ private int color;
+ private float zIndex;
+ private boolean visible;
+ private boolean geodesic;
+ public PolylineOptions() {
+ }
- public PolylineOptions() {
- }
+ private PolylineOptions(Parcel in) {
+ SafeParcelUtil.readObject(this, in);
+ }
- private PolylineOptions(Parcel in) {
- SafeParcelUtil.readObject(this, in);
- }
+ @Override
+ public int describeContents() {
+ return 0;
+ }
- @Override
- public int describeContents() {
- return 0;
- }
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ SafeParcelUtil.writeObject(this, dest, flags);
+ }
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- SafeParcelUtil.writeObject(this, dest, flags);
- }
+ public static Creator CREATOR = new Creator() {
+ public PolylineOptions createFromParcel(Parcel source) {
+ return new PolylineOptions(source);
+ }
- public static Creator CREATOR = new Creator() {
- public PolylineOptions createFromParcel(Parcel source) {
- return new PolylineOptions(source);
- }
-
- public PolylineOptions[] newArray(int size) {
- return new PolylineOptions[size];
- }
- };
+ public PolylineOptions[] newArray(int size) {
+ return new PolylineOptions[size];
+ }
+ };
}
diff --git a/src/com/google/android/gms/maps/model/VisibleRegion.java b/src/com/google/android/gms/maps/model/VisibleRegion.java
index 76f2342..7f96402 100644
--- a/src/com/google/android/gms/maps/model/VisibleRegion.java
+++ b/src/com/google/android/gms/maps/model/VisibleRegion.java
@@ -55,8 +55,8 @@ public class VisibleRegion implements SafeParcelable {
* orientated top view
*/
public VisibleRegion(LatLngBounds bounds) {
- this(bounds.southWest, new LatLng(bounds.southWest.latitude, bounds.northEast.longitude),
- new LatLng(bounds.northEast.latitude, bounds.southWest.longitude), bounds.northEast,
+ this(bounds.southwest, new LatLng(bounds.southwest.latitude, bounds.northeast.longitude),
+ new LatLng(bounds.northeast.latitude, bounds.southwest.longitude), bounds.northeast,
bounds);
}