Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b4734ca136
9 changed files with 37 additions and 27 deletions
|
@ -10,6 +10,7 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SpecialPhrases;
|
import net.osmand.plus.SpecialPhrases;
|
||||||
|
import net.osmand.plus.activities.ApplicationMode;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
public class OsmAndFormatter {
|
public class OsmAndFormatter {
|
||||||
|
@ -97,16 +98,21 @@ public class OsmAndFormatter {
|
||||||
public static String getFormattedSpeed(float metersperseconds, Context ctx) {
|
public static String getFormattedSpeed(float metersperseconds, Context ctx) {
|
||||||
OsmandSettings settings = ((OsmandApplication) ctx.getApplicationContext()).getSettings();
|
OsmandSettings settings = ((OsmandApplication) ctx.getApplicationContext()).getSettings();
|
||||||
MetricsConstants mc = settings.METRIC_SYSTEM.get();
|
MetricsConstants mc = settings.METRIC_SYSTEM.get();
|
||||||
|
ApplicationMode am = settings.getApplicationMode();
|
||||||
float kmh = metersperseconds * 3.6f;
|
float kmh = metersperseconds * 3.6f;
|
||||||
if(mc == MetricsConstants.KILOMETERS_AND_METERS){
|
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
|
||||||
return ((int) kmh) + " " + ctx.getString(R.string.km_h);
|
if (kmh >= 15 || (am == ApplicationMode.CAR)) {
|
||||||
|
return ((int) kmh) + " " + ctx.getString(R.string.km_h);
|
||||||
|
}
|
||||||
|
kmh = ((int) kmh * 10f) / 10f;
|
||||||
|
return kmh + " " + ctx.getString(R.string.km_h);
|
||||||
} else {
|
} else {
|
||||||
float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
|
float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
|
||||||
if(mph >= 10) {
|
if (mph >= 10) {
|
||||||
return ((int) (mph)) + " "+ ctx.getString(R.string.mile_per_hour);
|
return ((int) (mph)) + " " + ctx.getString(R.string.mile_per_hour);
|
||||||
} else {
|
} else {
|
||||||
mph = ((int)mph*10f)/10f;
|
mph = ((int) mph * 10f) / 10f;
|
||||||
return mph + " "+ ctx.getString(R.string.mile_per_hour);
|
return mph + " " + ctx.getString(R.string.mile_per_hour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -932,7 +932,10 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
} else {
|
} else {
|
||||||
settings.clearPointToNavigate();
|
settings.clearPointToNavigate();
|
||||||
}
|
}
|
||||||
routingHelper.setFinalAndCurrentLocation(point, getLastKnownLocation(), routingHelper.getCurrentGPXRoute());
|
if(routingHelper.isRouteBeingCalculated() || routingHelper.isRouteCalculated() ||
|
||||||
|
routingHelper.isFollowingMode()) {
|
||||||
|
routingHelper.setFinalAndCurrentLocation(point, getLastKnownLocation(), routingHelper.getCurrentGPXRoute());
|
||||||
|
}
|
||||||
mapLayers.getNavigationLayer().setPointToNavigate(point);
|
mapLayers.getNavigationLayer().setPointToNavigate(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,7 +467,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
settings.FOLLOW_THE_ROUTE.set(false);
|
settings.FOLLOW_THE_ROUTE.set(false);
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||||
routingHelper.setFollowingMode(false);
|
routingHelper.setFollowingMode(false);
|
||||||
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), from);
|
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), from, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
settings.FOLLOW_THE_ROUTE.set(true);
|
settings.FOLLOW_THE_ROUTE.set(true);
|
||||||
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
settings.FOLLOW_THE_GPX_ROUTE.set(null);
|
||||||
routingHelper.setFollowingMode(true);
|
routingHelper.setFollowingMode(true);
|
||||||
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), current);
|
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), current, null);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
getMyApplication().showDialogInitializingCommandPlayer(mapActivity);
|
getMyApplication().showDialogInitializingCommandPlayer(mapActivity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean distChanged(int oldDist, int dist){
|
private boolean distChanged(int oldDist, int dist){
|
||||||
if(oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist)/oldDist) < 0.01){
|
if(oldDist != 0 && oldDist - dist < 30){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -316,6 +316,7 @@ public class MapRenderRepositories {
|
||||||
searchFilter = null;
|
searchFilter = null;
|
||||||
}
|
}
|
||||||
boolean ocean = false;
|
boolean ocean = false;
|
||||||
|
boolean land = false;
|
||||||
MapIndex mi = null;
|
MapIndex mi = null;
|
||||||
searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, searchFilter);
|
searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, searchFilter);
|
||||||
for (BinaryMapIndexReader c : files.values()) {
|
for (BinaryMapIndexReader c : files.values()) {
|
||||||
|
@ -353,8 +354,10 @@ public class MapRenderRepositories {
|
||||||
if (searchRequest.isOcean()) {
|
if (searchRequest.isOcean()) {
|
||||||
mi = c.getMapIndexes().get(0);
|
mi = c.getMapIndexes().get(0);
|
||||||
ocean = true;
|
ocean = true;
|
||||||
} else if (searchRequest.isLand()) {
|
}
|
||||||
|
if (searchRequest.isLand()) {
|
||||||
mi = c.getMapIndexes().get(0);
|
mi = c.getMapIndexes().get(0);
|
||||||
|
land = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +382,7 @@ public class MapRenderRepositories {
|
||||||
}
|
}
|
||||||
if(addBasemapCoastlines && mi != null){
|
if(addBasemapCoastlines && mi != null){
|
||||||
BinaryMapDataObject o = new BinaryMapDataObject(new int[] { leftX, topY, rightX, topY, rightX, bottomY, leftX, bottomY, leftX,
|
BinaryMapDataObject o = new BinaryMapDataObject(new int[] { leftX, topY, rightX, topY, rightX, bottomY, leftX, bottomY, leftX,
|
||||||
topY }, new int[] { ocean ? mi.coastlineEncodingType : (mi.landEncodingType) }, null, -1);
|
topY }, new int[] { ocean && !land ? mi.coastlineEncodingType : (mi.landEncodingType) }, null, -1);
|
||||||
o.setMapIndex(mi);
|
o.setMapIndex(mi);
|
||||||
tempResult.add(o);
|
tempResult.add(o);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,9 +88,6 @@ public class RoutingHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setFinalAndCurrentLocation(LatLon finalLocation, Location currentLocation){
|
|
||||||
setFinalAndCurrentLocation(finalLocation, currentLocation, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, Location currentLocation, GPXRouteParams gpxRoute){
|
public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, Location currentLocation, GPXRouteParams gpxRoute){
|
||||||
clearCurrentRoute(finalLocation);
|
clearCurrentRoute(finalLocation);
|
||||||
|
|
|
@ -308,11 +308,13 @@ public class RouteInfoControls {
|
||||||
public boolean updateInfo() {
|
public boolean updateInfo() {
|
||||||
// draw speed
|
// draw speed
|
||||||
if (map.getLastKnownLocation() != null && map.getLastKnownLocation().hasSpeed()) {
|
if (map.getLastKnownLocation() != null && map.getLastKnownLocation().hasSpeed()) {
|
||||||
// .3 mps == 1.08 kph
|
// .1 mps == 0.36 kph
|
||||||
float minDelta = .3f;
|
float minDelta = .1f;
|
||||||
// Update more often at walk/run speeds, since we give higher resolution
|
// Update more often at walk/run speeds, since we give higher resolution
|
||||||
// and use .02 instead of .03 to account for rounding effects.
|
// and use .02 instead of .03 to account for rounding effects.
|
||||||
if (cachedSpeed < 6) minDelta = .015f;
|
if (cachedSpeed < 6) {
|
||||||
|
minDelta = .015f;
|
||||||
|
}
|
||||||
if (Math.abs(map.getLastKnownLocation().getSpeed() - cachedSpeed) > minDelta) {
|
if (Math.abs(map.getLastKnownLocation().getSpeed() - cachedSpeed) > minDelta) {
|
||||||
cachedSpeed = map.getLastKnownLocation().getSpeed();
|
cachedSpeed = map.getLastKnownLocation().getSpeed();
|
||||||
String ds = OsmAndFormatter.getFormattedSpeed(cachedSpeed, map);
|
String ds = OsmAndFormatter.getFormattedSpeed(cachedSpeed, map);
|
||||||
|
@ -601,7 +603,7 @@ public class RouteInfoControls {
|
||||||
|
|
||||||
|
|
||||||
public boolean distChanged(int oldDist, int dist){
|
public boolean distChanged(int oldDist, int dist){
|
||||||
if(oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist)/oldDist) < 0.01){
|
if(oldDist != 0 && oldDist - dist < 10){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -744,7 +744,7 @@ bool searchMapTreeBounds(CodedInputStream* input, MapTreeBounds* current, MapTre
|
||||||
if(current->ocean){
|
if(current->ocean){
|
||||||
req->ocean = true;
|
req->ocean = true;
|
||||||
} else {
|
} else {
|
||||||
req->land = true;
|
req->mixed = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -882,7 +882,6 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
|
||||||
map<std::string, BinaryMapFile*>::iterator i = openFiles.begin();
|
map<std::string, BinaryMapFile*>::iterator i = openFiles.begin();
|
||||||
UNORDERED(set)<long long> ids;
|
UNORDERED(set)<long long> ids;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool ocean = false;
|
|
||||||
std::vector<MapDataObject*> basemapResult;
|
std::vector<MapDataObject*> basemapResult;
|
||||||
std::vector<MapDataObject*> tempResult;
|
std::vector<MapDataObject*> tempResult;
|
||||||
std::vector<MapDataObject*> coastLines;
|
std::vector<MapDataObject*> coastLines;
|
||||||
|
@ -941,9 +940,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (q->ocean) {
|
|
||||||
ocean = true;
|
|
||||||
}
|
|
||||||
if (!q->publisher->isCancelled()) {
|
if (!q->publisher->isCancelled()) {
|
||||||
std::vector<MapDataObject*>::iterator r = q->publisher->result.begin();
|
std::vector<MapDataObject*>::iterator r = q->publisher->result.begin();
|
||||||
tempResult.reserve((size_t)(q->publisher->result.size() + tempResult.size()));
|
tempResult.reserve((size_t)(q->publisher->result.size() + tempResult.size()));
|
||||||
|
@ -982,6 +979,8 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
|
||||||
deleteObjects(basemapCoastLines);
|
deleteObjects(basemapCoastLines);
|
||||||
deleteObjects(basemapResult);
|
deleteObjects(basemapResult);
|
||||||
} else {
|
} else {
|
||||||
|
bool ocean = q->ocean;
|
||||||
|
bool land = q->mixed;
|
||||||
bool addBasemapCoastlines = true;
|
bool addBasemapCoastlines = true;
|
||||||
bool emptyData = q->zoom > BASEMAP_ZOOM && tempResult.empty() && coastLines.empty();
|
bool emptyData = q->zoom > BASEMAP_ZOOM && tempResult.empty() && coastLines.empty();
|
||||||
bool basemapMissing = q->zoom <= BASEMAP_ZOOM && basemapCoastLines.empty() && !basemapExists;
|
bool basemapMissing = q->zoom <= BASEMAP_ZOOM && basemapCoastLines.empty() && !basemapExists;
|
||||||
|
@ -1006,7 +1005,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
|
||||||
o->points.push_back(int_pair(q->right, q->bottom));
|
o->points.push_back(int_pair(q->right, q->bottom));
|
||||||
o->points.push_back(int_pair(q->left, q->bottom));
|
o->points.push_back(int_pair(q->left, q->bottom));
|
||||||
o->points.push_back(int_pair(q->left, q->top));
|
o->points.push_back(int_pair(q->left, q->top));
|
||||||
if (ocean) {
|
if (ocean && !land) {
|
||||||
o->types.push_back(tag_value("natural", "coastline"));
|
o->types.push_back(tag_value("natural", "coastline"));
|
||||||
} else {
|
} else {
|
||||||
o->types.push_back(tag_value("natural", "land"));
|
o->types.push_back(tag_value("natural", "land"));
|
||||||
|
|
|
@ -221,7 +221,7 @@ struct SearchQuery {
|
||||||
|
|
||||||
coordinates cacheCoordinates;
|
coordinates cacheCoordinates;
|
||||||
bool ocean;
|
bool ocean;
|
||||||
bool land;
|
bool mixed;
|
||||||
|
|
||||||
int numberOfVisitedObjects;
|
int numberOfVisitedObjects;
|
||||||
int numberOfAcceptedObjects;
|
int numberOfAcceptedObjects;
|
||||||
|
@ -232,7 +232,7 @@ struct SearchQuery {
|
||||||
req(req), left(l), right(r), top(t), bottom(b),publisher(publisher) {
|
req(req), left(l), right(r), top(t), bottom(b),publisher(publisher) {
|
||||||
numberOfAcceptedObjects = numberOfVisitedObjects = 0;
|
numberOfAcceptedObjects = numberOfVisitedObjects = 0;
|
||||||
numberOfAcceptedSubtrees = numberOfReadSubtrees = 0;
|
numberOfAcceptedSubtrees = numberOfReadSubtrees = 0;
|
||||||
ocean = land = false;
|
ocean = mixed = false;
|
||||||
}
|
}
|
||||||
SearchQuery(int l, int r, int t, int b) :
|
SearchQuery(int l, int r, int t, int b) :
|
||||||
req(req), left(l), right(r), top(t), bottom(b) {
|
req(req), left(l), right(r), top(t), bottom(b) {
|
||||||
|
|
Loading…
Reference in a new issue