summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java18
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java12
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java116
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java148
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java46
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java45
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java31
7 files changed, 343 insertions, 73 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
index 1af8e7cfc7..07df87af3a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
@@ -1,12 +1,28 @@
package com.mapbox.mapboxsdk.geometry;
/**
- * Describes a latitude, longitude point.
+ * Describes a latitude, longitude, and altitude tuple.
*/
public interface ILatLng {
+
+ /**
+ * Get the latitude, in degrees.
+ *
+ * @return the latitude value in degrees
+ */
double getLatitude();
+ /**
+ * Get the longitude, in degrees.
+ *
+ * @return the longitude value in degrees
+ */
double getLongitude();
+ /**
+ * Get the altitude, in meters.
+ *
+ * @return the altitude value in meters
+ */
double getAltitude();
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
index 694c935143..db459d7cbb 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
@@ -4,7 +4,19 @@ package com.mapbox.mapboxsdk.geometry;
* Describes a projection in Mercator meters.
*/
public interface IProjectedMeters {
+
+ /**
+ * Get the north projection, in meters.
+ *
+ * @return the projected meters in north direction
+ */
double getNorthing();
+ /**
+ * Get the east projection, in meters.
+ *
+ * @return the projected meters in east direction
+ */
double getEasting();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
index ca2d3673b2..eb57241196 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.geometry;
import android.location.Location;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.annotation.FloatRange;
import com.mapbox.services.android.telemetry.constants.GeoConstants;
import com.mapbox.services.android.telemetry.utils.MathUtils;
@@ -21,6 +22,9 @@ import com.mapbox.services.android.telemetry.utils.MathUtils;
*/
public class LatLng implements ILatLng, Parcelable {
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator<LatLng> CREATOR = new Parcelable.Creator<LatLng>() {
public LatLng createFromParcel(Parcel in) {
return new LatLng(in);
@@ -44,7 +48,7 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Construct a new latitude, longitude point given float arguments
+ * Construct a new latitude, longitude point given double arguments
*
* @param latitude Latitude in degrees
* @param longitude Longitude in degrees
@@ -55,7 +59,7 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Construct a new latitude, longitude, altitude point given float arguments
+ * Construct a new latitude, longitude, altitude point given double arguments
*
* @param latitude Latitude in degrees
* @param longitude Longitude in degress
@@ -68,7 +72,7 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Transform a Location into a LatLng point
+ * Construct a new latitude, longitude, altitude point given location argument
*
* @param location Android Location
*/
@@ -77,23 +81,40 @@ public class LatLng implements ILatLng, Parcelable {
}
/**
- * Clone an existing latitude longitude point
+ * Construct a new latitude, longitude, altitude point given another latitude, longitude, altitude point.
*
- * @param aLatLng LatLng
+ * @param latLng LatLng to be cloned.
*/
- public LatLng(LatLng aLatLng) {
- this.latitude = aLatLng.latitude;
- this.longitude = aLatLng.longitude;
- this.altitude = aLatLng.altitude;
+ public LatLng(LatLng latLng) {
+ this.latitude = latLng.latitude;
+ this.longitude = latLng.longitude;
+ this.altitude = latLng.altitude;
}
+ /**
+ * Constructs a new latitude, longitude, altitude tuple given a parcel.
+ *
+ * @param in the parcel containing the latitude, longitude, altitude values
+ */
protected LatLng(Parcel in) {
setLatitude(in.readDouble());
setLongitude(in.readDouble());
setAltitude(in.readDouble());
}
- public void setLatitude(double latitude) {
+ /**
+ * Set the latitude, in degrees.
+ * <p>
+ * This value is in the range of [-85.05112878, 85.05112878], see {@link GeoConstants#MIN_LATITUDE} and
+ * {@link GeoConstants#MAX_LATITUDE}
+ * </p>
+ *
+ * @param latitude the latitude value in degrees
+ * @see GeoConstants#MIN_LATITUDE
+ * @see GeoConstants#MAX_LATITUDE
+ */
+ public void setLatitude(
+ @FloatRange(from = GeoConstants.MIN_LATITUDE, to = GeoConstants.MAX_LATITUDE) double latitude) {
if (Double.isNaN(latitude)) {
throw new IllegalArgumentException("latitude must not be NaN");
}
@@ -103,12 +124,35 @@ public class LatLng implements ILatLng, Parcelable {
this.latitude = latitude;
}
+ /**
+ * Get the latitude, in degrees.
+ * <p>
+ * This value is in the range of [-85.05112878, 85.05112878], see {@link GeoConstants#MIN_LATITUDE} and
+ * {@link GeoConstants#MAX_LATITUDE}
+ * </p>
+ *
+ * @return the latitude value in degrees
+ * @see GeoConstants#MIN_LATITUDE
+ * @see GeoConstants#MAX_LATITUDE
+ */
@Override
public double getLatitude() {
return latitude;
}
- public void setLongitude(double longitude) {
+ /**
+ * Set the longitude, in degrees.
+ * <p>
+ * This value is in the range of [-180, 180], see {@link GeoConstants#MIN_LONGITUDE} and
+ * {@link GeoConstants#MAX_LONGITUDE}
+ * </p>
+ *
+ * @param longitude the longitude value in degrees
+ * @see GeoConstants#MIN_LONGITUDE
+ * @see GeoConstants#MAX_LONGITUDE
+ */
+ public void setLongitude(@FloatRange(from = GeoConstants.MIN_LONGITUDE, to = GeoConstants.MAX_LONGITUDE)
+ double longitude) {
if (Double.isNaN(longitude)) {
throw new IllegalArgumentException("longitude must not be NaN");
}
@@ -118,15 +162,36 @@ public class LatLng implements ILatLng, Parcelable {
this.longitude = longitude;
}
+ /**
+ * Get the longitude, in degrees.
+ * <p>
+ * This value is in the range of [-180, 180], see {@link GeoConstants#MIN_LONGITUDE} and
+ * {@link GeoConstants#MAX_LONGITUDE}
+ * </p>
+ *
+ * @return the longitude value in degrees
+ * @see GeoConstants#MIN_LONGITUDE
+ * @see GeoConstants#MAX_LONGITUDE
+ */
@Override
public double getLongitude() {
return longitude;
}
+ /**
+ * Set the altitude, in meters.
+ *
+ * @param altitude the altitude in meters
+ */
public void setAltitude(double altitude) {
this.altitude = altitude;
}
+ /**
+ * Get the altitude, in meters.
+ *
+ * @return the altitude value in meters
+ */
@Override
public double getAltitude() {
return altitude;
@@ -136,13 +201,19 @@ public class LatLng implements ILatLng, Parcelable {
* Return a new LatLng object with a wrapped Longitude. This allows original data object
* to remain unchanged.
*
- * @return New LatLng object with wrapped Longitude
+ * @return new LatLng object with wrapped Longitude
*/
public LatLng wrap() {
longitude = MathUtils.wrap(longitude, GeoConstants.MIN_LONGITUDE, GeoConstants.MAX_LONGITUDE);
return this;
}
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param object The object to compare
+ * @return True if equal, false if not
+ */
@Override
public boolean equals(Object object) {
if (this == object) {
@@ -158,6 +229,11 @@ public class LatLng implements ILatLng, Parcelable {
&& Double.compare(latLng.longitude, longitude) == 0;
}
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code value
+ */
@Override
public int hashCode() {
int result;
@@ -171,16 +247,32 @@ public class LatLng implements ILatLng, Parcelable {
return result;
}
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return the string representation
+ */
@Override
public String toString() {
return "LatLng [latitude=" + latitude + ", longitude=" + longitude + ", altitude=" + altitude + "]";
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@Override
public int describeContents() {
return 0;
}
+ /**
+ * Flatten this object in to a Parcel.
+ *
+ * @param out The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeDouble(latitude);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
index 4a4e2a30aa..505b2db192 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.geometry;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException;
import com.mapbox.services.android.telemetry.constants.GeoConstants;
@@ -18,10 +19,10 @@ import java.util.List;
*/
public class LatLngBounds implements Parcelable {
- private final double mLatNorth;
- private final double mLatSouth;
- private final double mLonEast;
- private final double mLonWest;
+ private final double latitudeNorth;
+ private final double latitudeSouth;
+ private final double longitudeEast;
+ private final double longitudeWest;
/**
* Construct a new LatLngBounds based on its corners, given in NESW
@@ -34,10 +35,10 @@ public class LatLngBounds implements Parcelable {
*/
LatLngBounds(final double northLatitude, final double eastLongitude, final double southLatitude,
final double westLongitude) {
- this.mLatNorth = northLatitude;
- this.mLonEast = eastLongitude;
- this.mLatSouth = southLatitude;
- this.mLonWest = westLongitude;
+ this.latitudeNorth = northLatitude;
+ this.longitudeEast = eastLongitude;
+ this.latitudeSouth = southLatitude;
+ this.longitudeWest = westLongitude;
}
/**
@@ -59,8 +60,8 @@ public class LatLngBounds implements Parcelable {
* @return LatLng center of this LatLngBounds
*/
public LatLng getCenter() {
- return new LatLng((this.mLatNorth + this.mLatSouth) / 2,
- (this.mLonEast + this.mLonWest) / 2);
+ return new LatLng((this.latitudeNorth + this.latitudeSouth) / 2,
+ (this.longitudeEast + this.longitudeWest) / 2);
}
/**
@@ -69,7 +70,7 @@ public class LatLngBounds implements Parcelable {
* @return double latitude value for north
*/
public double getLatNorth() {
- return this.mLatNorth;
+ return this.latitudeNorth;
}
/**
@@ -78,7 +79,7 @@ public class LatLngBounds implements Parcelable {
* @return double latitude value for south
*/
public double getLatSouth() {
- return this.mLatSouth;
+ return this.latitudeSouth;
}
/**
@@ -87,7 +88,7 @@ public class LatLngBounds implements Parcelable {
* @return double longitude value for east
*/
public double getLonEast() {
- return this.mLonEast;
+ return this.longitudeEast;
}
/**
@@ -96,7 +97,7 @@ public class LatLngBounds implements Parcelable {
* @return double longitude value for west
*/
public double getLonWest() {
- return this.mLonWest;
+ return this.longitudeWest;
}
/**
@@ -105,7 +106,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the south west corner
*/
public LatLng getSouthWest() {
- return new LatLng(mLatSouth, mLonWest);
+ return new LatLng(latitudeSouth, longitudeWest);
}
/**
@@ -114,7 +115,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the north east corner
*/
public LatLng getNorthEast() {
- return new LatLng(mLatNorth, mLonEast);
+ return new LatLng(latitudeNorth, longitudeEast);
}
/**
@@ -123,7 +124,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the south east corner
*/
public LatLng getSouthEast() {
- return new LatLng(mLatSouth, mLonEast);
+ return new LatLng(latitudeSouth, longitudeEast);
}
/**
@@ -132,7 +133,7 @@ public class LatLngBounds implements Parcelable {
* @return LatLng of the north west corner
*/
public LatLng getNorthWest() {
- return new LatLng(mLatNorth, mLonWest);
+ return new LatLng(latitudeNorth, longitudeWest);
}
/**
@@ -151,7 +152,7 @@ public class LatLngBounds implements Parcelable {
* @return Span distance
*/
public double getLatitudeSpan() {
- return Math.abs(this.mLatNorth - this.mLatSouth);
+ return Math.abs(this.latitudeNorth - this.latitudeSouth);
}
/**
@@ -161,7 +162,7 @@ public class LatLngBounds implements Parcelable {
* @return Span distance
*/
public double getLongitudeSpan() {
- return Math.abs(this.mLonEast - this.mLonWest);
+ return Math.abs(this.longitudeEast - this.longitudeWest);
}
@@ -174,9 +175,15 @@ public class LatLngBounds implements Parcelable {
return getLongitudeSpan() == 0.0 || getLatitudeSpan() == 0.0;
}
+ /**
+ * Returns a string representaton of the object.
+ *
+ * @return the string representation
+ */
@Override
public String toString() {
- return "N:" + this.mLatNorth + "; E:" + this.mLonEast + "; S:" + this.mLatSouth + "; W:" + this.mLonWest;
+ return "N:" + this.latitudeNorth + "; E:" + this.longitudeEast + "; S:" + this.latitudeSouth
+ + "; W:" + this.longitudeWest;
}
/**
@@ -241,10 +248,10 @@ public class LatLngBounds implements Parcelable {
}
if (o instanceof LatLngBounds) {
LatLngBounds other = (LatLngBounds) o;
- return mLatNorth == other.getLatNorth()
- && mLatSouth == other.getLatSouth()
- && mLonEast == other.getLonEast()
- && mLonWest == other.getLonWest();
+ return latitudeNorth == other.getLatNorth()
+ && latitudeSouth == other.getLatSouth()
+ && longitudeEast == other.getLonEast()
+ && longitudeWest == other.getLonWest();
}
return false;
}
@@ -258,10 +265,10 @@ public class LatLngBounds implements Parcelable {
public boolean contains(final ILatLng latLng) {
final double latitude = latLng.getLatitude();
final double longitude = latLng.getLongitude();
- return ((latitude <= this.mLatNorth)
- && (latitude >= this.mLatSouth))
- && ((longitude <= this.mLonEast)
- && (longitude >= this.mLonWest));
+ return ((latitude <= this.latitudeNorth)
+ && (latitude >= this.latitudeSouth))
+ && ((longitude <= this.longitudeEast)
+ && (longitude >= this.longitudeWest));
}
/**
@@ -295,10 +302,10 @@ public class LatLngBounds implements Parcelable {
* @return BoundingBox
*/
public LatLngBounds union(final double lonNorth, final double latEast, final double lonSouth, final double latWest) {
- return new LatLngBounds((this.mLatNorth < lonNorth) ? lonNorth : this.mLatNorth,
- (this.mLonEast < latEast) ? latEast : this.mLonEast,
- (this.mLatSouth > lonSouth) ? lonSouth : this.mLatSouth,
- (this.mLonWest > latWest) ? latWest : this.mLonWest);
+ return new LatLngBounds((this.latitudeNorth < lonNorth) ? lonNorth : this.latitudeNorth,
+ (this.longitudeEast < latEast) ? latEast : this.longitudeEast,
+ (this.latitudeSouth > lonSouth) ? lonSouth : this.latitudeSouth,
+ (this.longitudeWest > latWest) ? latWest : this.longitudeWest);
}
/**
@@ -307,6 +314,7 @@ public class LatLngBounds implements Parcelable {
* @param box LatLngBounds to intersect with
* @return LatLngBounds
*/
+ @Nullable
public LatLngBounds intersect(LatLngBounds box) {
double minLatWest = Math.max(getLonWest(), box.getLonWest());
double maxLatEast = Math.min(getLonEast(), box.getLonEast());
@@ -334,6 +342,9 @@ public class LatLngBounds implements Parcelable {
return intersect(new LatLngBounds(northLatitude, eastLongitude, southLatitude, westLongitude));
}
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator<LatLngBounds> CREATOR =
new Parcelable.Creator<LatLngBounds>() {
@Override
@@ -347,25 +358,41 @@ public class LatLngBounds implements Parcelable {
}
};
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code
+ */
@Override
public int hashCode() {
- return (int) ((mLatNorth + 90)
- + ((mLatSouth + 90) * 1000)
- + ((mLonEast + 180) * 1000000)
- + ((mLonEast + 180) * 1000000000));
+ return (int) ((latitudeNorth + 90)
+ + ((latitudeSouth + 90) * 1000)
+ + ((longitudeEast + 180) * 1000000)
+ + ((longitudeEast + 180) * 1000000000));
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@Override
public int describeContents() {
return 0;
}
+ /**
+ * Flatten this object in to a Parcel.
+ *
+ * @param out The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written
+ */
@Override
- public void writeToParcel(final Parcel out, final int arg1) {
- out.writeDouble(this.mLatNorth);
- out.writeDouble(this.mLonEast);
- out.writeDouble(this.mLatSouth);
- out.writeDouble(this.mLonWest);
+ public void writeToParcel(final Parcel out, final int flags) {
+ out.writeDouble(this.latitudeNorth);
+ out.writeDouble(this.longitudeEast);
+ out.writeDouble(this.latitudeSouth);
+ out.writeDouble(this.longitudeWest);
}
private static LatLngBounds readFromParcel(final Parcel in) {
@@ -381,28 +408,51 @@ public class LatLngBounds implements Parcelable {
*/
public static final class Builder {
- private List<LatLng> mLatLngList;
+ private List<LatLng> latLngList;
+ /**
+ * Constructs a builder to compose LatLng objects to a LatLngBounds.
+ */
public Builder() {
- mLatLngList = new ArrayList<>();
+ latLngList = new ArrayList<>();
}
+ /**
+ * Builds a new LatLngBounds.
+ * <p>
+ * Throws an {@link InvalidLatLngBoundsException} when no LatLngBounds can be created.
+ * </p>
+ *
+ * @return the build LatLngBounds
+ */
public LatLngBounds build() {
- if (mLatLngList.size() < 2) {
- throw new InvalidLatLngBoundsException(mLatLngList.size());
+ if (latLngList.size() < 2) {
+ throw new InvalidLatLngBoundsException(latLngList.size());
}
- return LatLngBounds.fromLatLngs(mLatLngList);
+ return LatLngBounds.fromLatLngs(latLngList);
}
+ /**
+ * Adds a LatLng object to the LatLngBounds.Builder.
+ *
+ * @param latLngs the List of LatLng objects to be added
+ * @return this
+ */
public Builder includes(List<LatLng> latLngs) {
for (LatLng point : latLngs) {
- mLatLngList.add(point);
+ latLngList.add(point);
}
return this;
}
+ /**
+ * Adds a LatLng object to the LatLngBounds.Builder.
+ *
+ * @param latLng the LatLng to be added
+ * @return this
+ */
public Builder include(@NonNull LatLng latLng) {
- mLatLngList.add(latLng);
+ latLngList.add(latLng);
return this;
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java
index d00ccdb9b8..322c7dfb74 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngSpan.java
@@ -64,19 +64,28 @@ public class LatLngSpan implements Parcelable {
mLongitudeSpan = longitudeSpan;
}
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param object The object to compare
+ * @return True if equal, false if not
+ */
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object object) {
+ if (this == object) {
return true;
}
- if (o instanceof LatLngSpan) {
- LatLngSpan other = (LatLngSpan) o;
+ if (object instanceof LatLngSpan) {
+ LatLngSpan other = (LatLngSpan) object;
return mLongitudeSpan == other.getLongitudeSpan()
&& mLatitudeSpan == other.getLatitudeSpan();
}
return false;
}
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator<LatLngSpan> CREATOR =
new Parcelable.Creator<LatLngSpan>() {
@Override
@@ -90,14 +99,41 @@ public class LatLngSpan implements Parcelable {
}
};
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@Override
public int describeContents() {
return 0;
}
+ /**
+ * Flatten this object in to a Parcel.
+ *
+ * @param out Parcel in which the object should be written
+ * @param flags Additional flags about how the object should be written
+ */
@Override
- public void writeToParcel(Parcel out, int arg1) {
+ public void writeToParcel(Parcel out, int flags) {
out.writeDouble(mLatitudeSpan);
out.writeDouble(mLongitudeSpan);
}
+
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return hash code value of this
+ */
+ @Override
+ public int hashCode() {
+ int result;
+ long temp;
+ temp = Double.doubleToLongBits(mLatitudeSpan);
+ result = (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(mLongitudeSpan);
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
+ return result;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
index 761d8f2a8b..fa84c33b2b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
@@ -13,6 +13,9 @@ import android.os.Parcelable;
*/
public class ProjectedMeters implements IProjectedMeters, Parcelable {
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Creator<ProjectedMeters> CREATOR = new Creator<ProjectedMeters>() {
public ProjectedMeters createFromParcel(Parcel in) {
return new ProjectedMeters(in);
@@ -47,6 +50,12 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable {
this.easting = projectedMeters.easting;
}
+ /**
+ * Creates a ProjectedMeters from a Parcel.
+ *
+ * @param in The parcel to create from
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
private ProjectedMeters(Parcel in) {
northing = in.readDouble();
easting = in.readDouble();
@@ -72,22 +81,32 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable {
return easting;
}
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param other The object to compare this to
+ * @return true if equal, false if not
+ */
@Override
- public boolean equals(Object o) {
- if (this == o) {
+ public boolean equals(Object other) {
+ if (this == other) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if (other == null || getClass() != other.getClass()) {
return false;
}
- ProjectedMeters projectedMeters = (ProjectedMeters) o;
+ ProjectedMeters projectedMeters = (ProjectedMeters) other;
return Double.compare(projectedMeters.easting, easting) == 0
&& Double.compare(projectedMeters.northing, northing) == 0;
-
}
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code of this
+ */
@Override
public int hashCode() {
int result;
@@ -99,16 +118,32 @@ public class ProjectedMeters implements IProjectedMeters, Parcelable {
return result;
}
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return the string representation of this
+ */
@Override
public String toString() {
return "ProjectedMeters [northing=" + northing + ", easting=" + easting + "]";
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@Override
public int describeContents() {
return 0;
}
+ /**
+ * Flatten this object in to a Parcel.
+ *
+ * @param out The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeDouble(northing);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java
index c5b8ad3077..c09c00fced 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/VisibleRegion.java
@@ -37,6 +37,11 @@ public class VisibleRegion implements Parcelable {
*/
public final LatLngBounds latLngBounds;
+ /**
+ * Creates a VisibleRegion from a Parcel.
+ *
+ * @param in The Parcel to create this from
+ */
private VisibleRegion(Parcel in) {
this.farLeft = in.readParcelable(LatLng.class.getClassLoader());
this.farRight = in.readParcelable(LatLng.class.getClassLoader());
@@ -46,7 +51,7 @@ public class VisibleRegion implements Parcelable {
}
/**
- * Creates a new VisibleRegion given the four corners of the camera.
+ * Creates a VisibleRegion given the four corners of the camera.
*
* @param farLeft A LatLng object containing the latitude and longitude of the near left corner of the region.
* @param farRight A LatLng object containing the latitude and longitude of the near left corner of the region.
@@ -88,12 +93,22 @@ public class VisibleRegion implements Parcelable {
&& latLngBounds.equals(visibleRegion.latLngBounds);
}
+ /**
+ * The string representation of the object.
+ *
+ * @return the string representation of this
+ */
@Override
public String toString() {
return "[farLeft [" + farLeft + "], farRight [" + farRight + "], nearLeft [" + nearLeft + "], nearRight ["
+ nearRight + "], latLngBounds [" + latLngBounds + "]]";
}
+ /**
+ * Returns a hash code value for the object.
+ *
+ * @return the hash code
+ */
@Override
public int hashCode() {
return ((farLeft.hashCode() + 90)
@@ -102,11 +117,22 @@ public class VisibleRegion implements Parcelable {
+ ((nearRight.hashCode() + 180) * 1000000000));
}
+ /**
+ * Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
+ *
+ * @return a bitmask indicating the set of special object types marshaled by this Parcelable object instance.
+ */
@Override
public int describeContents() {
return 0;
}
+ /**
+ * Flatten this object in to a Parcel.
+ *
+ * @param out The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written
+ */
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(farLeft, flags);
@@ -116,6 +142,9 @@ public class VisibleRegion implements Parcelable {
out.writeParcelable(latLngBounds, flags);
}
+ /**
+ * Inner class responsible for recreating Parcels into objects.
+ */
public static final Parcelable.Creator<VisibleRegion> CREATOR =
new Parcelable.Creator<VisibleRegion>() {
public VisibleRegion createFromParcel(Parcel in) {