/**
  * Calculates the span of bounds and returns it in a String. A span is two values which are
  * latitude and longitude length between each parts of bounds. Example : -SW.lat = 1 -SW.lng = 10
  * -NE.lat = 5 -NE.lng = 50 -> lat span = NE.lat - SW.lat = 5 - 1 = 4 -> lng span = NE.lng -
  * SW.lng = 50 - 10 = 40
  *
  * @return span formated in a string
  */
 public String toSpan() {
   return new StringBuffer("")
       .append(mNe.getLat() - mSw.getLat())
       .append(",")
       .append(mNe.getLng() - mSw.getLng())
       .toString();
 }
 /**
  * Returns if yes or not the given LatLng is contained in bounds.
  *
  * @param latlng LatLng to test
  * @return true if LatLng is contained, false otherwise
  */
 public boolean contains(LatLng latlng) {
   double lat = latlng.getLat();
   double lng = latlng.getLng();
   return (lat >= mSw.getLat()
       && lng >= mSw.getLng()
       && lat <= mNe.getLat()
       && lng <= mNe.getLng());
 }
 /**
  * Creates new SW and NE to create union with another entire LatLngBounds.
  *
  * @param other Other bounds to make union
  */
 public void union(LatLngBounds other) {
   mSw =
       new LatLng(
           Math.min(mSw.getLat(), other.getSw().getLat()),
           Math.min(mSw.getLng(), other.getSw().getLng()));
   mNe =
       new LatLng(
           Math.max(mNe.getLat(), other.getNe().getLat()),
           Math.max(mNe.getLng(), other.getNe().getLng()));
   calculateCenter();
 }
 /**
  * Extends bounds to the LatLng passed in parameter, if this one is not contained in bounds.
  *
  * @param point LatLng to include in bounds
  * @return LatLng
  */
 public void extend(LatLng point) {
   if (!contains(point)) {
     mSw =
         new LatLng(
             Math.min(mSw.getLat(), point.getLat()), Math.min(mSw.getLng(), point.getLng()));
     mNe =
         new LatLng(
             Math.max(mNe.getLat(), point.getLat()), Math.max(mNe.getLng(), point.getLng()));
     calculateCenter();
   }
 }
 public FloatLatLng(LatLng ll) {
   this.lat = ll.getLat();
   this.lng = ll.getLng();
 }
 @Override
 public LatLng calculateMidpoint(LatLng other) {
   return new FloatLatLng((lat + other.getLat()) / 2.0, (lng + other.getLng()) / 2.0);
 }
 /**
  * Calculates LatLng SW and NE when center and latSpanE6 and lngSpanE6 are known.
  *
  * @param latSpan Latitude span between SW lat and NE lat
  * @param latSpan Latitude span between SW lng and NE lng
  */
 private void calculateBounds(double latSpan, double lngSpan) {
   mSw = new LatLng(mCenter.getLat() - latSpan, mCenter.getLng() - lngSpan);
   mNe = new LatLng(mCenter.getLat() + latSpan, mCenter.getLng() + lngSpan);
 }
 /** Calculates LatLng center when SW and NE are known. */
 private void calculateCenter() {
   double latCenter = (mSw.getLat() + mNe.getLat()) / 2;
   double lngCenter = (mSw.getLng() + mNe.getLng()) / 2;
   ;
   mCenter = new LatLng(latCenter, lngCenter);
 }
 public int getLngSpanE6() {
   return (int) (Math.abs(mNe.getLng() - mSw.getLng()) * 1000000);
 }