Skip to content

Commit

Permalink
Merge pull request #333 from skedgo/dev
Browse files Browse the repository at this point in the history
Release 1.22.0
  • Loading branch information
thuutin authored Nov 25, 2018
2 parents 3aad6e5 + 2610efb commit ed369f9
Show file tree
Hide file tree
Showing 32 changed files with 1,303 additions and 692 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## [Version 1.22.0] - 2018-11-25
### Fixed
- Remove google maps dependency
- Return tralvelled and non-travelled trip line separately
### Added
- Add localCost to TripSegment
3 changes: 0 additions & 3 deletions CommonCoreLegacy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ dependencies {
testImplementation libs.jodaTimeTzdb
testImplementation libs.kluent

// See https://github.com/skedgo/android-maps-utils.
implementation libs.androidMapsUtils
implementation libs.supportAnnotations
implementation libs.playServicesMaps
implementation libs.jodaTimeAndroid
implementation libs.rxjava
implementation libs.rxAndroid
Expand Down
4 changes: 3 additions & 1 deletion CommonCoreLegacy/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-keep class com.skedgo.android.common.model.** { *; }
-keep class skedgo.tripkit.routing.ModeInfo { *; }
-keep class skedgo.tripkit.routing.SegmentType { *; }
-keep class skedgo.tripkit.routing.SegmentType { *; }
-keep class skedgo.tripkit.routing.TurnByTurn { *; }
-keep class skedgo.tripkit.routing.LocalCostAccuracy { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,7 @@
@Value.Immutable
@Value.Style(passAnnotations = JsonAdapter.class)
@JsonAdapter(GsonAdaptersBooking.class)
public abstract class Booking implements Parcelable {
public static final Creator<Booking> CREATOR = new Creator<Booking>() {
@SuppressWarnings("unchecked")
@Override public Booking createFromParcel(Parcel in) {
final ArrayList<String> externalActions = in.readArrayList(ArrayList.class.getClassLoader());
return ImmutableBooking.builder()
.externalActions(externalActions)
.title(in.readString())
.url(in.readString())
.quickBookingsUrl(in.readString())
.confirmation((BookingConfirmation) in.readParcelable(BookingConfirmation.class.getClassLoader()))
.build();
}

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

@Override public void writeToParcel(Parcel dest, int flags) {
dest.writeList(getExternalActions());
dest.writeString(getTitle());
dest.writeString(getUrl());
dest.writeString(getQuickBookingsUrl());
dest.writeParcelable(getConfirmation(), flags);

}

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

public abstract class Booking {
@SerializedName("externalActions") @Nullable public abstract List<String> getExternalActions();
@SerializedName("title") @Nullable public abstract String getTitle();
@SerializedName("url") @Nullable public abstract String getUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import androidx.annotation.Nullable;
import android.text.TextUtils;

import com.google.android.gms.maps.model.LatLng;
import com.google.gson.annotations.SerializedName;
import com.skedgo.android.common.util.StringUtils;

Expand Down Expand Up @@ -154,10 +153,6 @@ public Location(Location other) {
fillFrom(other);
}

public Location(LatLng ll) {
this(ll == null ? 0.0 : ll.latitude, ll == null ? 0.0 : ll.longitude);
}

public Location(double lat, double lon) {
this();
this.lat = lat;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.skedgo.android.common.util;
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import static java.lang.Math.*;

/**
* Utility functions that are used my both PolyUtil and SphericalUtil.
*/
class MathUtil {
/**
* The earth's radius, in meters.
* Mean radius as defined by IUGG.
*/
static final double EARTH_RADIUS = 6371009;

/**
* Restrict x to the range [low, high].
*/
static double clamp(double x, double low, double high) {
return x < low ? low : (x > high ? high : x);
}

/**
* Wraps the given value into the inclusive-exclusive interval between min and max.
* @param n The value to wrap.
* @param min The minimum.
* @param max The maximum.
*/
static double wrap(double n, double min, double max) {
return (n >= min && n < max) ? n : (mod(n - min, max - min) + min);
}

/**
* Returns the non-negative remainder of x / m.
* @param x The operand.
* @param m The modulus.
*/
static double mod(double x, double m) {
return ((x % m) + m) % m;
}

/**
* Returns mercator Y corresponding to latitude.
* See http://en.wikipedia.org/wiki/Mercator_projection .
*/
static double mercator(double lat) {
return log(tan(lat * 0.5 + PI/4));
}

/**
* Returns latitude from mercator Y.
*/
static double inverseMercator(double y) {
return 2 * atan(exp(y)) - PI / 2;
}

/**
* Returns haversine(angle-in-radians).
* hav(x) == (1 - cos(x)) / 2 == sin(x / 2)^2.
*/
static double hav(double x) {
double sinHalf = sin(x * 0.5);
return sinHalf * sinHalf;
}

/**
* Computes inverse haversine. Has good numerical stability around 0.
* arcHav(x) == acos(1 - 2 * x) == 2 * asin(sqrt(x)).
* The argument must be in [0, 1], and the result is positive.
*/
static double arcHav(double x) {
return 2 * asin(sqrt(x));
}

// Given h==hav(x), returns sin(abs(x)).
static double sinFromHav(double h) {
return 2 * sqrt(h * (1 - h));
}

// Returns hav(asin(x)).
static double havFromSin(double x) {
double x2 = x * x;
return x2 / (1 + sqrt(1 - x2)) * .5;
}

// Returns sin(arcHav(x) + arcHav(y)).
static double sinSumFromHav(double x, double y) {
double a = sqrt(x * (1 - x));
double b = sqrt(y * (1 - y));
return 2 * (a + b - 2 * (a * y + b * x));
}

/**
* Returns hav() of distance from (lat1, lng1) to (lat2, lng2) on the unit sphere.
*/
static double havDistance(double lat1, double lat2, double dLng) {
return hav(lat1 - lat2) + hav(dLng) * cos(lat1) * cos(lat2);
}
}
Loading

0 comments on commit ed369f9

Please sign in to comment.