Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2012-09-07 12:00:10 +02:00
commit b4734ca136
9 changed files with 37 additions and 27 deletions

View file

@ -10,6 +10,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.R;
import net.osmand.plus.SpecialPhrases;
import net.osmand.plus.activities.ApplicationMode;
import android.content.Context;
public class OsmAndFormatter {
@ -97,16 +98,21 @@ public class OsmAndFormatter {
public static String getFormattedSpeed(float metersperseconds, Context ctx) {
OsmandSettings settings = ((OsmandApplication) ctx.getApplicationContext()).getSettings();
MetricsConstants mc = settings.METRIC_SYSTEM.get();
ApplicationMode am = settings.getApplicationMode();
float kmh = metersperseconds * 3.6f;
if(mc == MetricsConstants.KILOMETERS_AND_METERS){
return ((int) kmh) + " " + ctx.getString(R.string.km_h);
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
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 {
float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
if(mph >= 10) {
return ((int) (mph)) + " "+ ctx.getString(R.string.mile_per_hour);
if (mph >= 10) {
return ((int) (mph)) + " " + ctx.getString(R.string.mile_per_hour);
} else {
mph = ((int)mph*10f)/10f;
return mph + " "+ ctx.getString(R.string.mile_per_hour);
mph = ((int) mph * 10f) / 10f;
return mph + " " + ctx.getString(R.string.mile_per_hour);
}
}
}

View file

@ -932,7 +932,10 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
} else {
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);
}

View file

@ -467,7 +467,7 @@ public class MapActivityActions implements DialogProvider {
settings.FOLLOW_THE_ROUTE.set(false);
settings.FOLLOW_THE_GPX_ROUTE.set(null);
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_GPX_ROUTE.set(null);
routingHelper.setFollowingMode(true);
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), current);
routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), current, null);
dialog.dismiss();
getMyApplication().showDialogInitializingCommandPlayer(mapActivity);
}

View file

@ -409,7 +409,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* @return
*/
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 true;

View file

@ -316,6 +316,7 @@ public class MapRenderRepositories {
searchFilter = null;
}
boolean ocean = false;
boolean land = false;
MapIndex mi = null;
searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, searchFilter);
for (BinaryMapIndexReader c : files.values()) {
@ -353,8 +354,10 @@ public class MapRenderRepositories {
if (searchRequest.isOcean()) {
mi = c.getMapIndexes().get(0);
ocean = true;
} else if (searchRequest.isLand()) {
}
if (searchRequest.isLand()) {
mi = c.getMapIndexes().get(0);
land = true;
}
}
@ -379,7 +382,7 @@ public class MapRenderRepositories {
}
if(addBasemapCoastlines && mi != null){
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);
tempResult.add(o);
}

View file

@ -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){
clearCurrentRoute(finalLocation);

View file

@ -308,11 +308,13 @@ public class RouteInfoControls {
public boolean updateInfo() {
// draw speed
if (map.getLastKnownLocation() != null && map.getLastKnownLocation().hasSpeed()) {
// .3 mps == 1.08 kph
float minDelta = .3f;
// .1 mps == 0.36 kph
float minDelta = .1f;
// Update more often at walk/run speeds, since we give higher resolution
// 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) {
cachedSpeed = map.getLastKnownLocation().getSpeed();
String ds = OsmAndFormatter.getFormattedSpeed(cachedSpeed, map);
@ -601,7 +603,7 @@ public class RouteInfoControls {
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 true;

View file

@ -744,7 +744,7 @@ bool searchMapTreeBounds(CodedInputStream* input, MapTreeBounds* current, MapTre
if(current->ocean){
req->ocean = true;
} else {
req->land = true;
req->mixed = true;
}
break;
}
@ -882,7 +882,6 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
map<std::string, BinaryMapFile*>::iterator i = openFiles.begin();
UNORDERED(set)<long long> ids;
int count = 0;
bool ocean = false;
std::vector<MapDataObject*> basemapResult;
std::vector<MapDataObject*> tempResult;
std::vector<MapDataObject*> coastLines;
@ -941,9 +940,7 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
}
}
}
if (q->ocean) {
ocean = true;
}
if (!q->publisher->isCancelled()) {
std::vector<MapDataObject*>::iterator r = q->publisher->result.begin();
tempResult.reserve((size_t)(q->publisher->result.size() + tempResult.size()));
@ -982,6 +979,8 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
deleteObjects(basemapCoastLines);
deleteObjects(basemapResult);
} else {
bool ocean = q->ocean;
bool land = q->mixed;
bool addBasemapCoastlines = true;
bool emptyData = q->zoom > BASEMAP_ZOOM && tempResult.empty() && coastLines.empty();
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->left, q->bottom));
o->points.push_back(int_pair(q->left, q->top));
if (ocean) {
if (ocean && !land) {
o->types.push_back(tag_value("natural", "coastline"));
} else {
o->types.push_back(tag_value("natural", "land"));

View file

@ -221,7 +221,7 @@ struct SearchQuery {
coordinates cacheCoordinates;
bool ocean;
bool land;
bool mixed;
int numberOfVisitedObjects;
int numberOfAcceptedObjects;
@ -232,7 +232,7 @@ struct SearchQuery {
req(req), left(l), right(r), top(t), bottom(b),publisher(publisher) {
numberOfAcceptedObjects = numberOfVisitedObjects = 0;
numberOfAcceptedSubtrees = numberOfReadSubtrees = 0;
ocean = land = false;
ocean = mixed = false;
}
SearchQuery(int l, int r, int t, int b) :
req(req), left(l), right(r), top(t), bottom(b) {