Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
8 changes: 8 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/IOsmAndAidlInterface.aidl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.osmand.aidlapi;

import net.osmand.aidlapi.map.ALatLon;
import net.osmand.aidlapi.map.APosition;
import net.osmand.aidlapi.map.SetMapLocationParams;

import net.osmand.aidlapi.favorite.group.AFavoriteGroup;
Expand Down Expand Up @@ -836,6 +837,13 @@ interface IOsmAndAidlInterface {
*/
boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params);

/**
* Method to get position of various objects
*
* @params positionType (int) - type of position to get
*/
boolean getPosition(in int positionType, out APosition position);
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.

New aidl methods must be added to the end of the file or following methods will be broken.

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.

Thanks, acknowledged )


boolean importProfile(in ProfileSettingsParams params);

boolean executeQuickAction(in QuickActionParams params);
Expand Down
3 changes: 3 additions & 0 deletions OsmAnd-api/src/net/osmand/aidlapi/map/APosition.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidlapi.map;

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

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

public class APosition implements Parcelable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. APosition > ALocation
  2. ALocation immutable
  3. ALocation extends AidlParams
  4. positionType > locationType and it should be explained in the method's description

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


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 APosition(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 APosition(Parcel in) {
readFromParcel(in);
}

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

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

public APosition() {
}

@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;

APosition other = (APosition) 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);
}

public void writeToParcel(Parcel out, int flags) {
out.writeDouble(latitude);
out.writeDouble(longitude);
out.writeDouble(altitude);
out.writeDouble(speed);
out.writeDouble(bearing);
}

public void readFromParcel(Parcel in) {
latitude = in.readDouble();
longitude = in.readDouble();
altitude = in.readDouble();
speed = in.readDouble();
bearing = in.readDouble();
}

public int describeContents() {
return 0;
}
}
8 changes: 8 additions & 0 deletions OsmAnd/src/net/osmand/aidl/IOsmAndAidlInterface.aidl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.osmand.aidl;

import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.map.APosition;
import net.osmand.aidl.map.SetMapLocationParams;

import net.osmand.aidl.favorite.group.AFavoriteGroup;
Expand Down Expand Up @@ -837,6 +838,13 @@ interface IOsmAndAidlInterface {
*/
boolean removeAllActiveMapMarkers(in RemoveMapMarkersParams params);

/**
* Method to get position of various objects
*
* @params positionType (int) - type of position to get
*/
boolean getPosition(in int positionType, out APosition position);

/**
* Method to get color name for gpx.
*
Expand Down
18 changes: 18 additions & 0 deletions OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.GPXTrackAnalysis;
import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.PlatformUtil;
import net.osmand.aidl.gpx.AGpxFile;
import net.osmand.aidl.gpx.AGpxFileDetails;
import net.osmand.aidl.gpx.ASelectedGpxFile;
import net.osmand.aidl.map.APosition;
import net.osmand.aidl.navigation.ADirectionInfo;
import net.osmand.aidl.navigation.OnVoiceNavigationParams;
import net.osmand.aidl.quickaction.QuickActionInfoParams;
Expand Down Expand Up @@ -1003,6 +1005,22 @@ boolean removeAllActiveMapMarkers() {
return true;
}

public APosition getPosition(int positionType) {
switch (positionType) {
case 0: {
RoutingHelper rh = app.getRoutingHelper();
Location location = rh.getLastFixedLocation();
return new APosition(
location.getLatitude(),
location.getLongitude(),
location.getAltitude(),
location.getSpeed(),
location.getBearing()
);
}
}
return null;
}

boolean updateMapMarker(String prevName, LatLon prevLatLon, String newName, LatLon newLatLon, boolean ignoreCoordinates) {
LatLon latLon = new LatLon(prevLatLon.getLatitude(), prevLatLon.getLongitude());
Expand Down
20 changes: 20 additions & 0 deletions OsmAnd/src/net/osmand/aidl/OsmandAidlService.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.osmand.aidl.gpx.StartGpxRecordingParams;
import net.osmand.aidl.gpx.StopGpxRecordingParams;
import net.osmand.aidl.map.ALatLon;
import net.osmand.aidl.map.APosition;
import net.osmand.aidl.map.SetMapLocationParams;
import net.osmand.aidl.maplayer.AddMapLayerParams;
import net.osmand.aidl.maplayer.RemoveMapLayerParams;
Expand Down Expand Up @@ -1278,6 +1279,25 @@ public boolean removeAllActiveMapMarkers(RemoveMapMarkersParams params) {
}
}

@Override
public boolean getPosition(int positionType, APosition position) {
try {
OsmandAidlApi api = getApi("getPosition");
if (api != null) {
APosition p = api.getPosition(positionType);
position.setLatitude(p.getLatitude());
position.setLongitude(p.getLongitude());
position.setAltitude(p.getAltitude());
position.setSpeed(p.getSpeed());
position.setBearing(p.getBearing());
return true;
}
} catch (Exception e) {
handleException(e);
}
return false;
}

@Override
public boolean getGpxColor(GpxColorParams params) {
try {
Expand Down
20 changes: 20 additions & 0 deletions OsmAnd/src/net/osmand/aidl/OsmandAidlServiceV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.osmand.aidl.OsmandAidlApi.GpxBitmapCreatedCallback;
import net.osmand.aidl.OsmandAidlApi.OsmandAppInitCallback;
import net.osmand.aidl.OsmandAidlApi.SearchCompleteCallback;
import net.osmand.aidlapi.map.APosition;
import net.osmand.aidlapi.IOsmAndAidlCallback;
import net.osmand.aidlapi.IOsmAndAidlInterface;
import net.osmand.aidlapi.calculateroute.CalculateRouteParams;
Expand Down Expand Up @@ -1227,6 +1228,25 @@ public boolean removeAllActiveMapMarkers(RemoveMapMarkersParams params) {
}
}

@Override
public boolean getPosition(int positionType, APosition position) {
try {
OsmandAidlApi api = getApi("getPosition");
if (api != null) {
net.osmand.aidl.map.APosition p = api.getPosition(positionType);
position.setLatitude(p.getLatitude());
position.setLongitude(p.getLongitude());
position.setAltitude(p.getAltitude());
position.setSpeed(p.getSpeed());
position.setBearing(p.getBearing());
return true;
}
} catch (Exception e) {
handleException(e);
}
return false;
}

@Override
public boolean importProfile(ProfileSettingsParams params) {
try {
Expand Down
3 changes: 3 additions & 0 deletions OsmAnd/src/net/osmand/aidl/map/APosition.aidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.osmand.aidl.map;

parcelable APosition;
Loading