[ADD] longitude latitude doubles in location
This commit is contained in:
@@ -15,6 +15,10 @@ public class Location {
|
||||
@NonNull
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* coordinates will be saved as for example: 2.434343,4.65656;3.656565,6.43434
|
||||
* so lat1,long1;lat2,long2
|
||||
*/
|
||||
private String coordinates;
|
||||
private String description;
|
||||
|
||||
@@ -29,6 +33,10 @@ public class Location {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public Location(@NotNull String name, double startLat, double startLong, double endLat, double endLong, String description, @Nullable String imageUrl) {
|
||||
this(name,getStringFromCoordinates(startLat,startLong,endLat,endLong),description,imageUrl);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -63,4 +71,19 @@ public class Location {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public double[] getCoordinatesAsDoubles() {
|
||||
double[] res = new double[4];
|
||||
String[] locations = this.coordinates.split(";");
|
||||
res[0] =Double.parseDouble(locations[0].split(",")[0]);
|
||||
res[1] = Double.parseDouble(locations[0].split(",")[1]);
|
||||
res[2] = Double.parseDouble(locations[1].split(",")[0]);
|
||||
res[3] = Double.parseDouble(locations[1].split(",")[1]);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static String getStringFromCoordinates(double lat1, double long1, double lat2, double long2) {
|
||||
return lat1 + "," + long1 + ";" + lat2 + "," + long2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user