summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngQuad.java
blob: 4629d8dad44a3b07f0904c9d141a5c00caa3b446 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.mapbox.mapboxsdk.geometry;

import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;

/**
 * A geographical area representing a non-aligned quadrilateral
 * <p>
 * This class does not wrap values to the world bounds
 * </p>
 */
public class LatLngQuad implements Parcelable {

  @Keep
  private final LatLng topLeft;
  @Keep
  private final LatLng topRight;
  @Keep
  private final LatLng bottomRight;
  @Keep
  private final LatLng bottomLeft;

  /**
   * Construct a new LatLngQuad based on its corners,
   * in order top left, top right, bottom left, bottom right
   */
  @Keep
  public LatLngQuad(final LatLng topLeft, final LatLng topRight, final LatLng bottomRight, final LatLng bottomLeft) {
    this.topLeft = topLeft;
    this.topRight = topRight;
    this.bottomRight = bottomRight;
    this.bottomLeft = bottomLeft;
  }

  public LatLng getTopLeft() {
    return this.topLeft;
  }

  public LatLng getTopRight() {
    return this.topRight;
  }

  public LatLng getBottomRight() {
    return this.bottomRight;
  }

  public LatLng getBottomLeft() {
    return this.bottomLeft;
  }

  public static final Parcelable.Creator<LatLngQuad> CREATOR = new Parcelable.Creator<LatLngQuad>() {
    @Override
    public LatLngQuad createFromParcel(@NonNull final Parcel in) {
      return readFromParcel(in);
    }

    @Override
    public LatLngQuad[] newArray(final int size) {
      return new LatLngQuad[size];
    }
  };

  @Override
  public int hashCode() {
    int code = topLeft.hashCode();
    code = (code ^ code >>> 31) + topRight.hashCode();
    code = (code ^ code >>> 31) + bottomRight.hashCode();
    code = (code ^ code >>> 31) + bottomLeft.hashCode();
    return code;
  }

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(@NonNull final Parcel out, final int arg1) {
    topLeft.writeToParcel(out, arg1);
    topRight.writeToParcel(out, arg1);
    bottomRight.writeToParcel(out, arg1);
    bottomLeft.writeToParcel(out, arg1);
  }

  private static LatLngQuad readFromParcel(@NonNull final Parcel in) {
    final LatLng topLeft = new LatLng(in);
    final LatLng topRight = new LatLng(in);
    final LatLng bottomRight = new LatLng(in);
    final LatLng bottomLeft = new LatLng(in);
    return new LatLngQuad(topLeft, topRight, bottomRight, bottomLeft);
  }
}