Back to project page smartnavi.
The source code is released under:
Apache License
If you think the Android project smartnavi listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.osmdroid.bonuspack.routing; //w w w . ja v a 2 s . co m import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import org.osmdroid.bonuspack.utils.BonusPackHelper; import java.util.ArrayList; /** * Road Leg is the portion of the road between 2 waypoints (intermediate points requested) * * @author M.Kergall */ public class RoadLeg implements Parcelable { public static final Parcelable.Creator<RoadLeg> CREATOR = new Parcelable.Creator<RoadLeg>() { @Override public RoadLeg createFromParcel(Parcel source) { return new RoadLeg(source); } @Override public RoadLeg[] newArray(int size) { return new RoadLeg[size]; } }; /** * in km */ public double mLength; /** * in sec */ public double mDuration; /** * starting node of the leg, as index in nodes array */ public int mStartNodeIndex; /** * and ending node */ public int mEndNodeIndex; public RoadLeg() { mLength = mDuration = 0.0; mStartNodeIndex = mEndNodeIndex = 0; } //--- Parcelable implementation public RoadLeg(int startNodeIndex, int endNodeIndex, ArrayList<RoadNode> nodes) { mStartNodeIndex = startNodeIndex; mEndNodeIndex = endNodeIndex; mLength = mDuration = 0.0; for (int i = startNodeIndex; i <= endNodeIndex; i++) { RoadNode node = nodes.get(i); mLength += node.mLength; mDuration += node.mDuration; } Log.d(BonusPackHelper.LOG_TAG, "Leg: " + startNodeIndex + "-" + endNodeIndex + ", length=" + mLength + "km, duration=" + mDuration + "s"); } private RoadLeg(Parcel in) { mLength = in.readDouble(); mDuration = in.readDouble(); mStartNodeIndex = in.readInt(); mEndNodeIndex = in.readInt(); } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel out, int flags) { out.writeDouble(mLength); out.writeDouble(mDuration); out.writeInt(mStartNodeIndex); out.writeInt(mEndNodeIndex); } }