Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.osmand.aidlapi;

import net.osmand.aidlapi.map.ALatLon;
import net.osmand.aidlapi.map.ALocation;
import net.osmand.aidlapi.map.ALocationType;
import net.osmand.aidlapi.map.SetMapLocationParams;

import net.osmand.aidlapi.favorite.group.AFavoriteGroup;
Expand All @@ -19,6 +21,7 @@ import net.osmand.aidlapi.mapmarker.RemoveMapMarkerParams;
import net.osmand.aidlapi.mapmarker.UpdateMapMarkerParams;

import net.osmand.aidlapi.calculateroute.CalculateRouteParams;
import net.osmand.aidlapi.calculateroute.CalculatedRoute;

import net.osmand.aidlapi.gpx.ImportGpxParams;
import net.osmand.aidlapi.gpx.ShowGpxParams;
Expand All @@ -43,6 +46,7 @@ import net.osmand.aidlapi.maplayer.UpdateMapLayerParams;

import net.osmand.aidlapi.navigation.NavigateParams;
import net.osmand.aidlapi.navigation.NavigateGpxParams;
import net.osmand.aidlapi.navigation.NavigationStatus;

import net.osmand.aidlapi.note.TakePhotoNoteParams;
import net.osmand.aidlapi.note.StartVideoRecordingParams;
Expand Down Expand Up @@ -864,4 +868,29 @@ interface IOsmAndAidlInterface {
long registerForKeyEvents(in AKeyEventsParams params, IOsmAndAidlCallback callback);

AppInfoParams getAppInfo();
}

/**
* Method to get position of various objects
*
* @params locationType (ALocationType) - type of position to get (CURRENT - last fixed, PROJECTION - last projection, ROUTE_END end of the route)
*/
boolean getLocation(in ALocationType locationType, out ALocation location);

/**
* Method to get application mode
*
*/
String getApplicationMode();

/**
* Method to get current navigation status
*
*/
boolean getNavigationStatus(out NavigationStatus status);

/**
* Method to get calculated route
*
*/
boolean getCalculatedRoute(out CalculatedRoute route);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be refactored into 3 differnet methods:

  1. getCalculatedRoute - information about calculated routes, geometry, appmode, time, etc
  2. getApplicationMode - current app mode
  3. getNavigationStatus - progress, currentSegment, leftDistance, leftTime, etc

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in latest commit

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.calculateroute;

parcelable CalculatedRoute;
133 changes: 133 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/calculateroute/CalculatedRoute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package net.osmand.aidlapi.calculateroute;

import android.os.Bundle;
import android.os.Parcel;

import net.osmand.aidlapi.AidlParams;
import net.osmand.aidlapi.map.ALatLon;

import java.util.ArrayList;

public class CalculatedRoute extends AidlParams {

private boolean isRouteCalculated;

private String appMode;

private ArrayList<ALatLon> routePoints;
private int routeDistance;

private float routingTime;
private long creationTime;

private float calculationTime;

public CalculatedRoute() {

}

public CalculatedRoute(boolean isRouteCalculated, String appMode, ArrayList<ALatLon> routePoints, int routeDistance, float routingTime, long creationTime, float calculationTime) {
this.isRouteCalculated = isRouteCalculated;
this.appMode = appMode;
this.routePoints = routePoints;
this.routeDistance = routeDistance;
this.routingTime = routingTime;
this.creationTime = creationTime;
this.calculationTime = calculationTime;
}

protected CalculatedRoute(Parcel in) {
readFromParcel(in);
}

public static final Creator<CalculatedRoute> CREATOR = new Creator<CalculatedRoute>() {
@Override
public CalculatedRoute createFromParcel(Parcel in) {
return new CalculatedRoute(in);
}

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

public boolean isRouteCalculated() {
return isRouteCalculated;
}

public String getAppMode() {
return appMode;
}

public ArrayList<ALatLon> getRoutePoints() {
return routePoints;
}

public int getRouteDistance() {
return routeDistance;
}

public float getRoutingTime() {
return routingTime;
}

public long getCreationTime() {
return creationTime;
}

public float getCalculationTime() {
return calculationTime;
}

public void setRouteCalculated(boolean routeCalculated) {
isRouteCalculated = routeCalculated;
}

public void setAppMode(String appMode) {
this.appMode = appMode;
}

public void setRoutePoints(ArrayList<ALatLon> routePoints) {
this.routePoints = routePoints;
}

public void setRouteDistance(int routeDistance) {
this.routeDistance = routeDistance;
}

public void setRoutingTime(float routingTime) {
this.routingTime = routingTime;
}

public void setCreationTime(long creationTime) {
this.creationTime = creationTime;
}

public void setCalculationTime(float calculationTime) {
this.calculationTime = calculationTime;
}

@Override
protected void readFromBundle(Bundle bundle) {
bundle.setClassLoader(ALatLon.class.getClassLoader());
isRouteCalculated = bundle.getBoolean("isRouteCalculated");
appMode = bundle.getString("appMode");
routePoints = bundle.getParcelableArrayList("routePoints");
routeDistance = bundle.getInt("routeDistance");
routingTime = bundle.getFloat("routingTime");
creationTime = bundle.getLong("creationTime");
calculationTime = bundle.getFloat("calculationTime");
}

@Override
protected void writeToBundle(Bundle bundle) {
bundle.putBoolean("isRouteCalculated", isRouteCalculated);
bundle.putString("appMode", appMode);
bundle.putParcelableArrayList("routePoints", routePoints);
bundle.putInt("routeDistance", routeDistance);
bundle.putFloat("routingTime", routingTime);
bundle.putLong("creationTime", creationTime);
bundle.putFloat("calculationTime", calculationTime);
}
}
3 changes: 3 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.map;

parcelable ALocation;
139 changes: 139 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/ALocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package net.osmand.aidlapi.map;

import android.os.Bundle;
import android.os.Parcel;

import net.osmand.aidlapi.AidlParams;

public class ALocation extends AidlParams {

public double getLatitude() {
return latitude;
}

public void setLatitude(double latitude) {
this.latitude = latitude;
}

public double getLongitude() {
return longitude;
}

public void setLongitude(double longitude) {
this.longitude = longitude;
}

public double getAltitude() {
return altitude;
}

public void setAltitude(double altitude) {
this.altitude = altitude;
}

public double getSpeed() {
return speed;
}

public void setSpeed(double speed) {
this.speed = speed;
}

public double getBearing() {
return bearing;
}

public void setBearing(double bearing) {
this.bearing = bearing;
}

private double latitude;
private double longitude;
private double altitude;
private double speed;
private double bearing;

public ALocation(double latitude, double longitude, double altitude, double speed, double bearing) {
this.latitude = latitude;
this.longitude = longitude;
this.altitude = altitude;
this.speed = speed;
this.bearing = bearing;
}

public ALocation(Parcel in) {
readFromParcel(in);
}

public static final Creator<ALocation> CREATOR = new
Creator<ALocation>() {
public ALocation createFromParcel(Parcel in) {
return new ALocation(in);
}

public ALocation[] newArray(int size) {
return new ALocation[size];
}
};

public ALocation() {
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
int temp;
temp = (int)Math.floor(latitude * 10000);
result = prime * result + temp;
temp = (int)Math.floor(longitude * 10000);
result = prime * result + temp;
temp = (int)Math.floor(altitude * 10000);
result = prime * result + temp;
temp = (int)Math.floor(speed * 10000);
result = prime * result + temp;
temp = (int)Math.floor(bearing * 10000);
result = prime * result + temp;
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;

ALocation other = (ALocation) obj;
return Math.abs(latitude - other.latitude) < 0.00001
&& Math.abs(longitude - other.longitude) < 0.00001
&& Math.abs(altitude - other.altitude) < 1
&& Math.abs(speed - other.speed) < 1;
}

@Override
public String toString() {
return "Lat " + ((float)latitude) + " Lon " + ((float)longitude) + " Alt " + ((float)altitude);
}


@Override
protected void readFromBundle(Bundle bundle) {
latitude = bundle.getDouble("latitude", latitude);
longitude = bundle.getDouble("longitude", longitude);
altitude = bundle.getDouble("altitude", altitude);
speed = bundle.getDouble("speed", speed);
bearing = bundle.getDouble("bearing", bearing);
}

@Override
protected void writeToBundle(Bundle bundle) {
bundle.putDouble("latitude", latitude);
bundle.putDouble("longitude", longitude);
bundle.putDouble("altitude", altitude);
bundle.putDouble("speed", speed);
bundle.putDouble("bearing", bearing);
}
}
3 changes: 3 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/ALocationType.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.map;

parcelable ALocationType;
43 changes: 43 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/ALocationType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package net.osmand.aidlapi.map;

import android.os.Parcel;
import android.os.Parcelable;

public enum ALocationType implements Parcelable {
CURRENT(0),
PROJECTION(1),
ROUTE_END(2),
;

final int value;

ALocationType(int value) {
this.value = value;
}

public static final Creator<ALocationType> CREATOR = new Creator<ALocationType>() {
@Override
public ALocationType createFromParcel(Parcel in) {
return ALocationType.valueOf(in.readString());
}

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

public int getValue() {
return value;
}

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

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(name());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.navigation;

parcelable NavigationStatus;
Loading